コード例 #1
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);
        }
コード例 #2
0
 public override int GetHashCode()
 {
     return((int)((((uint)TypeId.GetHashCode()) << 16) ^ ((uint)SubtypeId.GetHashCode())));
 }
コード例 #3
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;
        }