Esempio n. 1
0
 internal void Clear()
 {
     DeallocateProxies();
     SortingKeys = null;
     VertexLayout1 = VertexLayoutId.NULL;
     VertexShaderFlags = MyShaderUnifiedFlags.NONE;
     Distance = float.MinValue;
 }
Esempio n. 2
0
 internal void Clear()
 {
     DeallocateProxies();
     SortingKeys       = null;
     VertexLayout1     = VertexLayoutId.NULL;
     VertexShaderFlags = MyShaderUnifiedFlags.NONE;
     Distance          = float.MinValue;
 }
Esempio n. 3
0
 internal static void Init()
 {
     OneAndOnlySupportedVertexLayout = MyVertexLayouts.GetLayout(
         new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED),
         new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
         new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
         new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)
         );
 }
Esempio n. 4
0
 internal static void Init()
 {
     OneAndOnlySupportedVertexLayout = MyVertexLayouts.GetLayout(
         new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED),
         new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
         new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
         new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)
         );
 }
        internal static VertexLayoutId GetLayout(params MyVertexInputComponent[] components)
        {
            if (components == null || components.Length == 0)
            {
                return(Empty);
            }

            var hash = 0;

            foreach (var c in components)
            {
                MyHashHelper.Combine(ref hash, c.GetHashCode());
            }

            if (HashIndex.ContainsKey(hash))
            {
                return(HashIndex[hash]);
            }

            var id = new VertexLayoutId {
                Index = Layouts.Allocate()
            };

            HashIndex[hash] = id;

            var declarationBuilder = new StringBuilder();
            var sourceBuilder      = new StringBuilder();
            var semanticDict       = new Dictionary <string, int>();

            // Might save some allocations when each AddComponent only adds one element as then we can use GetInternalArray and Capacity set does nothing
            var elementsList = new List <InputElement>(components.Length);

            foreach (var component in components)
            {
                MyVertexInputLayout.m_mapComponent[component.Type].AddComponent(component, elementsList, semanticDict, declarationBuilder, sourceBuilder);
            }

            elementsList.Capacity = elementsList.Count;
            Debug.Assert(elementsList.Count == elementsList.Capacity);

            Layouts.Data[id.Index] = new MyVertexLayoutInfo {
                Components         = components,
                Elements           = elementsList.GetInternalArray(),
                SourceDataMove     = sourceBuilder.ToString(),
                SourceDeclarations = new StringBuilder().AppendFormat("struct __VertexInput {{ \n {0} \n }};", declarationBuilder.ToString()).ToString(),
                HasBonesInfo       = components.Any(x => x.Type == MyVertexInputComponentType.BLEND_INDICES)
            };

            return(id);
        }
        internal static VertexLayoutId GetLayout(VertexLayoutId firstLayout, VertexLayoutId secondLayout)
        {
            VertexLayoutId combinedLayout = VertexLayoutId.NULL;
            List <MyVertexInputComponent> firstComponents = new List <MyVertexInputComponent>(firstLayout.Info.Components);

            MyVertexInputComponent[] secondComponents = secondLayout.Info.Components;

            firstComponents.AddArray(secondComponents);

            Debug.Assert(firstComponents.Count == firstComponents.Capacity);
            firstComponents.Capacity = firstComponents.Count;

            combinedLayout = GetLayout(firstComponents.GetInternalArray());
            return(combinedLayout);
        }
        static MyVertexLayouts()
        {
            var id = new VertexLayoutId {
                Index = Layouts.Allocate()
            };

            HashIndex[0]           = id;
            Layouts.Data[id.Index] = new MyVertexLayoutInfo
            {
                Elements = new InputElement[0],
                Macros   = new ShaderMacro[0],
            };

            Empty = id;
        }
Esempio n. 8
0
        internal static void Init()
        {
            var id = new VertexLayoutId {
                Index = Layouts.Allocate()
            };

            HashIndex[0]           = id;
            Layouts.Data[id.Index] = new MyVertexLayoutInfo
            {
                Elements           = new InputElement[0],
                SourceDeclarations = "struct __VertexInput { \n \n \n };",
                SourceDataMove     = ""
            };

            Empty = id;
        }
Esempio n. 9
0
        internal static InputLayoutId CreateIL(ShaderBytecodeId bytecode, VertexLayoutId layout)
        {
            var id = new InputLayoutId {
                Index = InputLayouts.Allocate()
            };

            MyArrayHelpers.Reserve(ref ILObjects, id.Index + 1);

            InputLayouts.Data[id.Index] = new InputLayoutInfo
            {
                BytecodeId = bytecode,
                VLayoutId  = layout
            };

            ILObjects[id.Index] = null;

            InitIL(id);
            ILIndex.Add(id);

            return(id);
        }
        internal static MyMaterialShadersBundleId Get(MyStringId material, MyStringId materialPass,
                                                      VertexLayoutId vertexLayout, MyShaderUnifiedFlags flags, MyFileTextureEnum textureTypes)
        {
            int hash = 0;

            MyHashHelper.Combine(ref hash, material.GetHashCode());
            MyHashHelper.Combine(ref hash, materialPass.GetHashCode());
            MyHashHelper.Combine(ref hash, vertexLayout.GetHashCode());
            MyHashHelper.Combine(ref hash, unchecked ((int)flags));

            if (HashIndex.ContainsKey(hash))
            {
                return(HashIndex[hash]);
            }

            var id = new MyMaterialShadersBundleId {
                Index = BundleInfo.Allocate()
            };

            MyArrayHelpers.Reserve(ref Bundles, id.Index + 1);

            HashIndex[hash]           = id;
            BundleInfo.Data[id.Index] = new MyMaterialShadersInfo
            {
                Material     = material,
                Pass         = materialPass,
                Layout       = vertexLayout,
                Flags        = flags,
                TextureTypes = textureTypes,
            };
            Bundles[id.Index] = new MyMaterialShadersBundle {
            };

            InitBundle(id);

            return(id);
        }
Esempio n. 11
0
 internal static InputElement[] GetElements(VertexLayoutId id)
 {
     return(Layouts.Data[id.Index].Elements);
 }
Esempio n. 12
0
        internal static VertexLayoutId GetLayout(params MyVertexInputComponent [] components)
        {
            if(components == null || components.Length == 0)
            {
                return Empty;
            }

            var hash = 0;
            foreach(var c in components)
            {
                MyHashHelper.Combine(ref hash, c.GetHashCode());
            }

            if(HashIndex.ContainsKey(hash))
            {
                return HashIndex[hash];
            }


            var id = new VertexLayoutId { Index = Layouts.Allocate() };
            HashIndex[hash] = id;


            var declarationBuilder = new StringBuilder();
            var sourceBuilder = new StringBuilder();
            var elementsList = new List<InputElement>();
            var semanticDict = new Dictionary<string, int>();

            foreach (var component in components)
            {
                MyVertexInputLayout.m_mapComponent[component.Type].AddComponent(component, elementsList, semanticDict, declarationBuilder, sourceBuilder);
            }

            Layouts.Data[id.Index] = new MyVertexLayoutInfo {
                Components = components,
                Elements = elementsList.ToArray(),
                SourceDataMove = sourceBuilder.ToString(),
                SourceDeclarations = new StringBuilder().AppendFormat("struct __VertexInput {{ \n {0} \n }};", declarationBuilder.ToString()).ToString(),
                HasBonesInfo = components.Any(x => x.Type == MyVertexInputComponentType.BLEND_INDICES)
            };

            return id;
        }
Esempio n. 13
0
 internal static VertexLayoutId GetLayout(VertexLayoutId a, VertexLayoutId b)
 {
     return GetLayout(a.Info.Components.Concat(b.Info.Components).ToArray());
 }
Esempio n. 14
0
        internal static void Init()
        {
            var id = new VertexLayoutId { Index = Layouts.Allocate() };
            HashIndex[0] = id;
            Layouts.Data[id.Index] = new MyVertexLayoutInfo 
            { 
                Elements = new InputElement[0], 
                SourceDeclarations = "struct __VertexInput { \n \n \n };",
                SourceDataMove = ""
            };

            Empty = id;
        }
Esempio n. 15
0
 internal static InputElement[] GetElements(VertexLayoutId id)
 {
     return Layouts.Data[id.Index].Elements;
 }
Esempio n. 16
0
        internal static VertexLayoutId GetLayout(params MyVertexInputComponent[] components)
        {
            if(components == null || components.Length == 0)
            {
                return Empty;
            }

            var hash = 0;
            foreach(var c in components)
            {
                MyHashHelper.Combine(ref hash, c.GetHashCode());
            }

            if(HashIndex.ContainsKey(hash))
            {
                return HashIndex[hash];
            }

            var id = new VertexLayoutId { Index = Layouts.Allocate() };
            HashIndex[hash] = id;

            var declarationBuilder = new StringBuilder();
            var sourceBuilder = new StringBuilder();
            var semanticDict = new Dictionary<string, int>();

            // Might save some allocations when each AddComponent only adds one element as then we can use GetInternalArray and Capacity set does nothing
            var elementsList = new List<InputElement>(components.Length);

            foreach (var component in components)
            {
                MyVertexInputLayout.m_mapComponent[component.Type].AddComponent(component, elementsList, semanticDict, declarationBuilder, sourceBuilder);
            }

            elementsList.Capacity = elementsList.Count;
            Debug.Assert(elementsList.Count == elementsList.Capacity);

            Layouts.Data[id.Index] = new MyVertexLayoutInfo {
                Components = components,
                Elements = elementsList.GetInternalArray(),
                Macros = MyComponent.GetComponentMacros(declarationBuilder.ToString(), sourceBuilder.ToString()),
                HasBonesInfo = components.Any(x => x.Type == MyVertexInputComponentType.BLEND_INDICES)
            };

            return id;
        }
 public static string GetShaderDescriptor(string shaderFilename, string material, string pass, VertexLayoutId layout)
 {
     return(String.Format("{0}, {1}_{2}_{3}", shaderFilename, material, pass, layout.Info.Components.GetString()));
 }
Esempio n. 18
0
 public static string GetShaderDescriptor(string shaderFilename, string material, string pass, VertexLayoutId layout)
 {
     return String.Format("{0}, {1}_{2}_{3}", shaderFilename, material, pass, layout.Info.Components.GetString());
 }
Esempio n. 19
0
        internal static MyMaterialShadersBundleId Get(MyStringId material, MyStringId materialPass, VertexLayoutId vertexLayout, MyShaderUnifiedFlags flags)
        {
            int hash = 0;
            MyHashHelper.Combine(ref hash, material.GetHashCode());
            MyHashHelper.Combine(ref hash, materialPass.GetHashCode());
            MyHashHelper.Combine(ref hash, vertexLayout.GetHashCode());
            MyHashHelper.Combine(ref hash, unchecked((int)flags));

            if(HashIndex.ContainsKey(hash))
            {
                return HashIndex[hash];
            }

            var id = new MyMaterialShadersBundleId { Index = BundleInfo.Allocate() };
            MyArrayHelpers.Reserve(ref Bundles, id.Index + 1);

            HashIndex[hash] = id;
            BundleInfo.Data[id.Index] = new MyMaterialShadersInfo
            {
                Material = material,
                Pass = materialPass,
                Layout = vertexLayout,
                Flags = flags
            };
            Bundles[id.Index] = new MyMaterialShadersBundle { };

            InitBundle(id);

            return id;
        }
Esempio n. 20
0
 internal static VertexLayoutId GetLayout(VertexLayoutId a, VertexLayoutId b)
 {
     return(GetLayout(a.Info.Components.Concat(b.Info.Components).ToArray()));
 }
Esempio n. 21
0
        internal static VertexLayoutId GetLayout(VertexLayoutId firstLayout, VertexLayoutId secondLayout)
        {
            VertexLayoutId combinedLayout = VertexLayoutId.NULL;
            List<MyVertexInputComponent> firstComponents = new List<MyVertexInputComponent>(firstLayout.Info.Components);
            MyVertexInputComponent[] secondComponents = secondLayout.Info.Components;
           
            firstComponents.AddArray(secondComponents);

            Debug.Assert(firstComponents.Count == firstComponents.Capacity);
            firstComponents.Capacity = firstComponents.Count;

            combinedLayout = GetLayout(firstComponents.GetInternalArray());
            return combinedLayout;
        }
Esempio n. 22
0
        internal static InputLayoutId CreateIL(ShaderBytecodeId bytecode, VertexLayoutId layout)
        {
            var id = new InputLayoutId { Index = InputLayouts.Allocate() };
            MyArrayHelpers.Reserve(ref ILObjects, id.Index + 1);

            InputLayouts.Data[id.Index] = new InputLayoutInfo
            {
                BytecodeId = bytecode,
                VLayoutId = layout
            };

            ILObjects[id.Index] = null;

            InitIL(id);
            ILIndex.Add(id);

            return id;
        }
Esempio n. 23
0
        static MyVertexLayouts()
        {
            var id = new VertexLayoutId { Index = Layouts.Allocate() };
            HashIndex[0] = id;
            Layouts.Data[id.Index] = new MyVertexLayoutInfo 
            { 
                Elements = new InputElement[0],
                Macros = new ShaderMacro[0],
            };

            Empty = id;
        }