Exemplo n.º 1
0
        public UsCmd CreateTextureCmd()
        {
            UsCmd usCmd = new UsCmd();

            usCmd.WriteNetCmd(eNetCmd.SV_FrameData_Texture);
            usCmd.WriteInt32(this.VisibleTextures.Count);
            using (Dictionary <Texture, HashSet <Material> > .Enumerator enumerator1 = this.VisibleTextures.GetEnumerator())
            {
                while (enumerator1.MoveNext())
                {
                    KeyValuePair <Texture, HashSet <Material> > current1 = enumerator1.Current;
                    usCmd.WriteInt32(((Object)current1.Key).GetInstanceID());
                    usCmd.WriteStringStripped(((Object)current1.Key).get_name());
                    usCmd.WriteString(string.Format("{0}x{1}", (object)current1.Key.get_width(), (object)current1.Key.get_height()));
                    usCmd.WriteString(UsTextureUtil.FormatSizeString(this._textureSizeLut[current1.Key] / 1024));
                    usCmd.WriteInt32(current1.Value.Count);
                    using (HashSet <Material> .Enumerator enumerator2 = current1.Value.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            Material current2 = enumerator2.Current;
                            usCmd.WriteInt32(((Object)current2).GetInstanceID());
                        }
                    }
                }
            }
            return(usCmd);
        }
Exemplo n.º 2
0
 public static int CalculateTextureSizeBytes(Texture tTexture)
 {
   int width = tTexture.get_width();
   int height = tTexture.get_height();
   switch (tTexture)
   {
     case Texture2D _:
       Texture2D texture2D = tTexture as Texture2D;
       int bitsPerPixel1 = UsTextureUtil.GetBitsPerPixel(texture2D.get_format());
       int mipmapCount = texture2D.get_mipmapCount();
       int num1 = 1;
       int num2 = 0;
       for (; num1 <= mipmapCount; ++num1)
       {
         num2 += width * height * bitsPerPixel1 / 8;
         width /= 2;
         height /= 2;
       }
       return num2;
     case Cubemap _:
       int bitsPerPixel2 = UsTextureUtil.GetBitsPerPixel((tTexture as Cubemap).get_format());
       return width * height * 6 * bitsPerPixel2 / 8;
     default:
       return 0;
   }
 }
Exemplo n.º 3
0
        private void AddVisibleTexture(Texture texture, Material ownerMat)
        {
            if (texture != null)
            {
                if (!_visibleTextures.ContainsKey(texture))
                {
                    _visibleTextures.Add(texture, new HashSet <Material>());
                }
                _visibleTextures[texture].Add(ownerMat);

                // refresh the size
                if (!_textureSizeLut.ContainsKey(texture))
                {
                    _textureSizeLut[texture] = UsTextureUtil.CalculateTextureSizeBytes(texture);
                }
            }
        }
Exemplo n.º 4
0
 private void AddVisibleTexture(Texture texture, Material ownerMat)
 {
     if (!Object.op_Inequality((Object)texture, (Object)null))
     {
         return;
     }
     if (!this._visibleTextures.ContainsKey(texture))
     {
         this._visibleTextures.Add(texture, new HashSet <Material>());
     }
     this._visibleTextures[texture].Add(ownerMat);
     if (this._textureSizeLut.ContainsKey(texture))
     {
         return;
     }
     this._textureSizeLut[texture] = UsTextureUtil.CalculateTextureSizeBytes(texture);
 }
Exemplo n.º 5
0
        public UsCmd CreateTextureCmd()
        {
            UsCmd cmd = new UsCmd();

            cmd.WriteNetCmd(eNetCmd.SV_FrameData_Texture);
            cmd.WriteInt32(VisibleTextures.Count);

            foreach (KeyValuePair <Texture, HashSet <Material> > kv in VisibleTextures)
            {
                cmd.WriteInt32(kv.Key.GetInstanceID());
                cmd.WriteStringStripped(kv.Key.name);
                cmd.WriteString(string.Format("{0}x{1}", kv.Key.width, kv.Key.height));
                cmd.WriteString(UsTextureUtil.FormatSizeString(_textureSizeLut[kv.Key] / 1024));

                cmd.WriteInt32(kv.Value.Count);
                foreach (var item in kv.Value)
                {
                    cmd.WriteInt32(item.GetInstanceID());
                }
            }

            return(cmd);
        }
Exemplo n.º 6
0
        public void DumpAllInfo()
        {
            Debug.Log(string.Format("{0} visible materials ({2}), visible textures ({3})",
                                    DateTime.Now.ToLongTimeString(),
                                    VisibleMaterials.Count,
                                    VisibleTextures.Count));

            string matInfo = "";

            foreach (KeyValuePair <Material, HashSet <GameObject> > kv in VisibleMaterials)
            {
                matInfo += string.Format("{0} {1} {2}\n", kv.Key.name, kv.Key.shader.name, kv.Value.Count);
            }
            Debug.Log(matInfo);

            string texInfo = "";

            foreach (KeyValuePair <Texture, HashSet <Material> > kv in VisibleTextures)
            {
                Texture tex = kv.Key;
                texInfo += string.Format("{0} {1} {2} {3} {4}\n", tex.name, tex.width, tex.height, kv.Value.Count, UsTextureUtil.FormatSizeString(_textureSizeLut[tex] / 1024));
            }
            Debug.Log(texInfo);
        }
Exemplo n.º 7
0
        public void DumpAllInfo()
        {
            Debug.Log((object)string.Format("{0} visible materials ({2}), visible textures ({3})", (object)DateTime.Now.ToLongTimeString(), (object)this.VisibleMaterials.Count, (object)this.VisibleTextures.Count));
            string empty1 = string.Empty;

            using (Dictionary <Material, HashSet <GameObject> > .Enumerator enumerator = this.VisibleMaterials.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <Material, HashSet <GameObject> > current = enumerator.Current;
                    empty1 += string.Format("{0} {1} {2}\n", (object)((Object)current.Key).get_name(), (object)((Object)current.Key.get_shader()).get_name(), (object)current.Value.Count);
                }
            }
            Debug.Log((object)empty1);
            string empty2 = string.Empty;

            using (Dictionary <Texture, HashSet <Material> > .Enumerator enumerator = this.VisibleTextures.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <Texture, HashSet <Material> > current = enumerator.Current;
                    Texture key = current.Key;
                    empty2 += string.Format("{0} {1} {2} {3} {4}\n", (object)((Object)key).get_name(), (object)key.get_width(), (object)key.get_height(), (object)current.Value.Count, (object)UsTextureUtil.FormatSizeString(this._textureSizeLut[key] / 1024));
                }
            }
            Debug.Log((object)empty2);
        }