예제 #1
0
        private void DebugInfoSection(LightmapData[] lightmaps)
        {
            if (!showDebugInfo)
            {
                return;
            }

            Lightmapping.ResetExplicitlyShownMemLabels();
            float oldWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 400.0f;

            {
                float gpuMemory = Lightmapping.ComputeTotalGPUMemoryUsageInBytes();
                if (gpuMemory > 0.0f)
                {
                    string foldoutNameGPU = String.Format("Total GPU memory ({0})", SizeString(gpuMemory));
                    EditorGUILayout.FoldoutTitlebar(false, new GUIContent(foldoutNameGPU), true);
                }
            }

            {
                Dictionary <Hash128, SortedList <int, int> > gbufferHashToLightmapIndices = new Dictionary <Hash128, SortedList <int, int> >();
                for (int i = 0; i < lightmaps.Length; i++)
                {
                    Hash128 gbufferHash;
                    if (Lightmapping.GetGBufferHash(i, out gbufferHash))
                    {
                        if (!gbufferHashToLightmapIndices.ContainsKey(gbufferHash))
                        {
                            gbufferHashToLightmapIndices.Add(gbufferHash, new SortedList <int, int>());
                        }

                        gbufferHashToLightmapIndices[gbufferHash].Add(i, i);
                    }
                }

                float totalGBuffersSize  = 0.0f;
                float totalLightmapsSize = 0.0f;

                foreach (var entry in gbufferHashToLightmapIndices)
                {
                    Hash128 gbufferHash     = entry.Key;
                    float   gbufferDataSize = Lightmapping.GetGBufferMemory(ref gbufferHash);
                    totalGBuffersSize += gbufferDataSize;

                    SortedList <int, int> lightmapIndices = entry.Value;
                    foreach (var i in lightmapIndices)
                    {
                        LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(i.Value);
                        totalLightmapsSize += lightmapMemory.lightmapDataSizeCPU;
                        totalLightmapsSize += lightmapMemory.lightmapTexturesSize;
                    }
                }

                string foldoutNameFull = String.Format(
                    "G-buffers ({0}) | Lightmaps ({1})",
                    SizeString(totalGBuffersSize),
                    SizeString(totalLightmapsSize));

                if (lightmaps.Length > 0)
                {
                    EditorGUILayout.FoldoutTitlebar(false, new GUIContent(foldoutNameFull), true);
                }
            }

            System.UInt64[] dummyCounts = new System.UInt64[0];
            {
                MemLabels labels = Lightmapping.GetTransmissionTexturesMemLabels();
                ShowObjectNamesSizesAndCounts("Transmission textures", kEditorPrefsTransmissionTextures, labels.labels, labels.sizes, dummyCounts);
            }

            {
                MemLabels labels = Lightmapping.GetMaterialTexturesMemLabels();
                ShowObjectNamesSizesAndCounts("Albedo/emissive textures", kEditorPrefsMaterialTextures, labels.labels, labels.sizes, dummyCounts);
            }

            {
                GeoMemLabels labels = Lightmapping.GetGeometryMemory();
                ShowObjectNamesSizesAndCounts("Geometry data", kEditorPrefsGeometryData, labels.labels, labels.sizes, labels.triCounts);
            }

            {
                // Note: this needs to go last.
                // It simply shows all the memory labels that were not explicitly queried after the Lightmapping.ResetExplicitlyShownMemLabels() call.
                MemLabels labels = Lightmapping.GetNotShownMemLabels();
                string    remainingEntriesFoldoutName = Lightmapping.isProgressiveLightmapperDone ? "Leaks" : "In-flight";
                ShowObjectNamesSizesAndCounts(remainingEntriesFoldoutName, kEditorPrefsInFlight, labels.labels, labels.sizes, dummyCounts);
            }

            EditorGUILayout.Space();
            EditorGUIUtility.labelWidth = oldWidth;
        }
예제 #2
0
        void MemoryCentricView(LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, GlobalMapsViewType viewType)
        {
            Lightmapping.ResetExplicitlyShownMemLabels();

            Dictionary <Hash128, SortedList <int, int> > gbufferHashToLightmapIndices = new Dictionary <Hash128, SortedList <int, int> >();

            for (int i = 0; i < lightmaps.Length; i++)
            {
                Hash128 gbufferHash;
                if (Lightmapping.GetGBufferHash(i, out gbufferHash))
                {
                    if (!gbufferHashToLightmapIndices.ContainsKey(gbufferHash))
                    {
                        gbufferHashToLightmapIndices.Add(gbufferHash, new SortedList <int, int>());
                    }

                    gbufferHashToLightmapIndices[gbufferHash].Add(i, i);
                }
            }

            float totalGBuffersSize  = 0.0f;
            float totalLightmapsSize = 0.0f;

            foreach (var entry in gbufferHashToLightmapIndices)
            {
                Hash128 gbufferHash     = entry.Key;
                float   gbufferDataSize = Lightmapping.GetGBufferMemory(ref gbufferHash);
                totalGBuffersSize += gbufferDataSize;

                SortedList <int, int> lightmapIndices = entry.Value;
                foreach (var i in lightmapIndices)
                {
                    LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(i.Value);
                    totalLightmapsSize += lightmapMemory.lightmapDataSize;
                    totalLightmapsSize += lightmapMemory.lightmapTexturesSize;
                }
            }

            if (gbufferHashToLightmapIndices.Count > 0)
            {
                const bool toggleOnLabelClick = true;
                string     foldoutNameFull    = String.Format(
                    "G-buffers ({0}) | Lightmaps ({1})",
                    SizeString(totalGBuffersSize),
                    SizeString(totalLightmapsSize));
                bool showDetailsOld = EditorPrefs.GetBool(kEditorPrefsGBuffersLightmapsAlbedoEmissive, true);

                bool showDetails = EditorGUILayout.Foldout(showDetailsOld, foldoutNameFull, toggleOnLabelClick, s_Styles.boldFoldout);

                if (showDetails != showDetailsOld)
                {
                    EditorPrefs.SetBool(kEditorPrefsGBuffersLightmapsAlbedoEmissive, showDetails);
                }

                if (showDetails)
                {
                    foreach (var entry in gbufferHashToLightmapIndices)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(15);
                            GUILayout.BeginVertical();
                            {
                                Hash128 gbufferHash     = entry.Key;
                                float   gbufferDataSize = Lightmapping.GetGBufferMemory(ref gbufferHash);
                                GUILayout.Label(EditorGUIUtility.TrTextContent("G-buffer: " + gbufferDataSize.ToString("0.0") + " MB", gbufferHash.ToString()), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));

                                SortedList <int, int> lightmapIndices = entry.Value;
                                foreach (var i in lightmapIndices)
                                {
                                    LightmapRow(i.Value, lightmaps, showDirLightmap, showShadowMask, viewType);
                                }
                            }
                            GUILayout.EndVertical();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.Space(10);
                    }
                }
            }

            System.UInt64[] dummyCounts = new System.UInt64[0];
            {
                MemLabels labels = Lightmapping.GetTransmissionTexturesMemLabels();
                ShowObjectNamesSizesAndCounts("Transmission textures", kEditorPrefsTransmissionTextures, labels.labels, labels.sizes, dummyCounts, Precision.Tenths);
            }

            {
                MemLabels labels = Lightmapping.GetMaterialTexturesMemLabels();
                ShowObjectNamesSizesAndCounts("Albedo/emissive textures", kEditorPrefsMaterialTextures, labels.labels, labels.sizes, dummyCounts, Precision.Hundredths);
            }

            {
                string[]        objectNames;
                float[]         sizes;
                System.UInt64[] triCounts;
                Lightmapping.GetGeometryMemory(out objectNames, out sizes, out triCounts);
                ShowObjectNamesSizesAndCounts("Geometry data", kEditorPrefsGeometryData, objectNames, sizes, triCounts, Precision.Hundredths);
            }

            {
                MemLabels labels = Lightmapping.GetNotShownMemLabels();
                string    remainingEntriesFoldoutName = Lightmapping.isProgressiveLightmapperDone ? "Leaks" : "In-flight";
                ShowObjectNamesSizesAndCounts(remainingEntriesFoldoutName, kEditorPrefsInFlight, labels.labels, labels.sizes, dummyCounts, Precision.Tenths);
            }
        }
        private void MemoryCentricView(LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, LightingWindowLightmapPreviewTab.GlobalMapsViewType viewType)
        {
            Lightmapping.ResetExplicitlyShownMemLabels();
            Dictionary <Hash128, SortedList <int, int> > dictionary = new Dictionary <Hash128, SortedList <int, int> >();

            for (int i = 0; i < lightmaps.Length; i++)
            {
                Hash128 key;
                if (Lightmapping.GetGBufferHash(i, out key))
                {
                    if (!dictionary.ContainsKey(key))
                    {
                        dictionary.Add(key, new SortedList <int, int>());
                    }
                    dictionary[key].Add(i, i);
                }
            }
            float num  = 0f;
            float num2 = 0f;
            float num3 = 0f;

            foreach (KeyValuePair <Hash128, SortedList <int, int> > current in dictionary)
            {
                Hash128 key2          = current.Key;
                float   gBufferMemory = Lightmapping.GetGBufferMemory(ref key2);
                num += gBufferMemory;
                SortedList <int, int> value = current.Value;
                foreach (KeyValuePair <int, int> current2 in value)
                {
                    LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(current2.Value);
                    num2 += lightmapMemory.lightmapDataSize;
                    num2 += lightmapMemory.lightmapTexturesSize;
                    num3 += lightmapMemory.albedoDataSize;
                    num3 += lightmapMemory.albedoTextureSize;
                    num3 += lightmapMemory.emissiveDataSize;
                    num3 += lightmapMemory.emissiveTextureSize;
                }
            }
            if (dictionary.Count > 0)
            {
                string content = string.Format("G-buffers ({0}) | Lightmaps ({1}) | Albedo/Emissive ({2})", this.SizeString(num), this.SizeString(num2), this.SizeString(num3));
                bool   @bool   = EditorPrefs.GetBool("LightingWindowGlobalMapsGLAE", true);
                bool   flag    = EditorGUILayout.Foldout(@bool, content, true, LightingWindowLightmapPreviewTab.s_Styles.boldFoldout);
                if (flag != @bool)
                {
                    EditorPrefs.SetBool("LightingWindowGlobalMapsGLAE", flag);
                }
                if (flag)
                {
                    foreach (KeyValuePair <Hash128, SortedList <int, int> > current3 in dictionary)
                    {
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUILayout.Space(15f);
                        GUILayout.BeginVertical(new GUILayoutOption[0]);
                        Hash128 key3 = current3.Key;
                        GUILayout.Label(EditorGUIUtility.TrTextContent("G-buffer: " + Lightmapping.GetGBufferMemory(ref key3).ToString("0.0") + " MB", key3.ToString(), null), EditorStyles.miniLabel, new GUILayoutOption[]
                        {
                            GUILayout.ExpandWidth(false)
                        });
                        SortedList <int, int> value2 = current3.Value;
                        foreach (KeyValuePair <int, int> current4 in value2)
                        {
                            this.LightmapRow(current4.Value, lightmaps, showDirLightmap, showShadowMask, viewType);
                        }
                        GUILayout.EndVertical();
                        GUILayout.EndHorizontal();
                        GUILayout.Space(10f);
                    }
                }
            }
            ulong[]  counts = new ulong[0];
            string[] objectNames;
            float[]  sizes;
            Lightmapping.GetTransmissionTexturesMemLabels(out objectNames, out sizes);
            this.ShowObjectNamesSizesAndCounts("Transmission textures", "LightingWindowGlobalMapsTT", objectNames, sizes, counts, LightingWindowLightmapPreviewTab.Precision.Tenths);
            string[] objectNames2;
            float[]  sizes2;
            ulong[]  counts2;
            Lightmapping.GetGeometryMemory(out objectNames2, out sizes2, out counts2);
            this.ShowObjectNamesSizesAndCounts("Geometry data", "LightingWindowGlobalMapsGD", objectNames2, sizes2, counts2, LightingWindowLightmapPreviewTab.Precision.Hundredths);
            string[] objectNames3;
            float[]  sizes3;
            Lightmapping.GetNotShownMemLabels(out objectNames3, out sizes3);
            string foldoutName = (!Lightmapping.isProgressiveLightmapperDone) ? "In-flight" : "Leaks";

            this.ShowObjectNamesSizesAndCounts(foldoutName, "LightingWindowGlobalMapsIF", objectNames3, sizes3, counts, LightingWindowLightmapPreviewTab.Precision.Tenths);
        }