Example #1
0
        void LightmapMemoryStats(int index)
        {
            GUILayout.BeginVertical();

            GUILayout.Label("Index: " + index, EditorStyles.miniLabel);

            LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(index);

            GUILayout.Label("Lightmap data: " + lightmapMemory.lightmapDataSize.ToString("0.0") + " MB", EditorStyles.miniLabel);
            GUIContent lightmapTexturesSizeContent = null;

            if (lightmapMemory.lightmapTexturesSize > 0.0f)
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: " + SizeString(lightmapMemory.lightmapTexturesSize));
            }
            else
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: N/A", "This lightmap has converged and is not owned by the Progressive Lightmapper anymore.");
            }
            GUILayout.Label(lightmapTexturesSizeContent, EditorStyles.miniLabel);
            GUILayout.Label("Albedo data: " + lightmapMemory.albedoDataSize.ToString("0.0") + " MB", EditorStyles.miniLabel);
            GUILayout.Label("Albedo texture: " + lightmapMemory.albedoTextureSize.ToString("0.0") + " MB", EditorStyles.miniLabel);
            GUILayout.Label("Emissive data: " + lightmapMemory.emissiveDataSize.ToString("0.0") + " MB", EditorStyles.miniLabel);
            GUILayout.Label("Emissive texture: " + lightmapMemory.emissiveTextureSize.ToString("0.0") + " MB", EditorStyles.miniLabel);

            GUILayout.EndVertical();
        }
Example #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);
            }
        }
Example #3
0
        private void LightmapDebugInfo(int index)
        {
            if (!showDebugInfo)
            {
                return;
            }

            GUILayout.Space(5);
            GUILayout.BeginVertical();

            LightmapConvergence lc = Lightmapping.GetLightmapConvergence(index);

            if (lc.IsValid())
            {
                GUILayout.Label("Occupied: " + InternalEditorUtility.CountToString((ulong)lc.occupiedTexelCount), EditorStyles.miniLabel);

                GUIContent direct = EditorGUIUtility.TrTextContent("Direct: " + lc.minDirectSamples + " / " + lc.maxDirectSamples + " / " + lc.avgDirectSamples + "", "min / max / avg samples per texel");
                GUILayout.Label(direct, EditorStyles.miniLabel);

                GUIContent gi = EditorGUIUtility.TrTextContent("GI: " + lc.minGISamples + " / " + lc.maxGISamples + " / " + lc.avgGISamples + "", "min / max / avg samples per texel");
                GUILayout.Label(gi, EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("Occupied: N/A", EditorStyles.miniLabel);
                GUILayout.Label("Direct: N/A", EditorStyles.miniLabel);
                GUILayout.Label("GI: N/A", EditorStyles.miniLabel);
            }
            float mraysPerSec = Lightmapping.GetLightmapBakePerformance(index);

            if (mraysPerSec >= 0.0)
            {
                GUILayout.Label(mraysPerSec.ToString("0.00") + " mrays/sec", EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("N/A mrays/sec", EditorStyles.miniLabel);
            }

            LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(index);

            GUILayout.Label("Lightmap data: " + SizeString(lightmapMemory.lightmapDataSizeCPU), EditorStyles.miniLabel);

            GUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.BeginVertical();

            GUIContent lightmapTexturesSizeContent = null;

            if (lightmapMemory.lightmapTexturesSize > 0.0f)
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: " + SizeString(lightmapMemory.lightmapTexturesSize));
            }
            else
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: N/A", "This lightmap has converged and is not owned by the Progressive Lightmapper anymore.");
            }
            GUILayout.Label(lightmapTexturesSizeContent, EditorStyles.miniLabel);

            GUIContent GPUSizeContent = null;

            if (lightmapMemory.lightmapDataSizeGPU > 0.0f)
            {
                GPUSizeContent = EditorGUIUtility.TrTextContent("GPU memory: " + SizeString(lightmapMemory.lightmapDataSizeGPU));
            }
            else
            {
                GPUSizeContent = EditorGUIUtility.TrTextContent("GPU memory: N/A");
            }
            GUILayout.Label(GPUSizeContent, EditorStyles.miniLabel);

            GUILayout.EndVertical();
        }
Example #4
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;
        }
Example #5
0
        private void LightmapDebugInfo(int index)
        {
            if (!showDebugInfo)
            {
                return;
            }

            GUILayout.Space(5);
            GUILayout.BeginVertical();

            LightmapConvergence lc = Lightmapping.GetLightmapConvergence(index);

            if (lc.IsValid())
            {
                ulong occupiedTexels = (ulong)lc.occupiedTexelCount;
                if (lc.tilingMode > 0)
                {
                    // Make sure we display the total amount of occupied texels once lightmap is converged
                    // If tiling is on, and lightmap is not converged, display the occupied texel count in current tile
                    if (lc.IsConverged())
                    {
                        GUILayout.Label("Occupied: " + InternalEditorUtility.CountToString(occupiedTexels), EditorStyles.miniLabel);
                        GUILayout.Label("Baked using " + lc.GetTileCount() + " tiles", EditorStyles.miniLabel);
                    }
                    else
                    {
                        occupiedTexels = (ulong)lc.occupiedTexelCountInCurrentTile;
                        GUILayout.Label("Occupied (in tile): " + InternalEditorUtility.CountToString(occupiedTexels), EditorStyles.miniLabel);
                        GUILayout.Label("Baking pass (#tile): " + (lc.tilingPassNum + 1) + "/" + lc.GetTileCount(), EditorStyles.miniLabel);
                    }
                }
                else
                {
                    GUILayout.Label("Occupied: " + InternalEditorUtility.CountToString(occupiedTexels), EditorStyles.miniLabel);
                }
                GUIContent direct = EditorGUIUtility.TrTextContent("Direct: " + lc.minDirectSamples + " / " + lc.maxDirectSamples + " / " + lc.avgDirectSamples + "", "min / max / avg samples per texel");
                GUILayout.Label(direct, EditorStyles.miniLabel);

                GUIContent gi = EditorGUIUtility.TrTextContent("GI: " + lc.minGISamples + " / " + lc.maxGISamples + " / " + lc.avgGISamples + "", "min / max / avg samples per texel");
                GUILayout.Label(gi, EditorStyles.miniLabel);

                GUIContent env = EditorGUIUtility.TrTextContent("Environment: " + lc.minEnvSamples + " / " + lc.maxEnvSamples + " / " + lc.avgEnvSamples + "", "min / max / avg samples per texel");
                GUILayout.Label(env, EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("Occupied: N/A", EditorStyles.miniLabel);
                GUILayout.Label("Direct: N/A", EditorStyles.miniLabel);
                GUILayout.Label("GI: N/A", EditorStyles.miniLabel);
                GUILayout.Label("Environment: N/A", EditorStyles.miniLabel);
            }
            float mraysPerSec = Lightmapping.GetLightmapBakePerformance(index);

            if (mraysPerSec >= 0.0)
            {
                GUILayout.Label(mraysPerSec.ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + " mrays/sec", EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("N/A mrays/sec", EditorStyles.miniLabel);
            }

            GUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.BeginVertical();

            LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(index);

            GUILayout.Label("Lightmap data: " + SizeString(lightmapMemory.lightmapDataSizeCPU), EditorStyles.miniLabel);

            GUIContent lightmapTexturesSizeContent = null;

            if (lightmapMemory.lightmapTexturesSize > 0.0f)
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: " + SizeString(lightmapMemory.lightmapTexturesSize));
            }
            else
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: N/A", "This lightmap has converged and is not owned by the Progressive Lightmapper anymore.");
            }
            GUILayout.Label(lightmapTexturesSizeContent, EditorStyles.miniLabel);

            GUIContent GPUSizeContent = null;

            if (lightmapMemory.lightmapDataSizeGPU > 0.0f)
            {
                GPUSizeContent = EditorGUIUtility.TrTextContent("GPU memory: " + SizeString(lightmapMemory.lightmapDataSizeGPU));
            }
            else
            {
                GPUSizeContent = EditorGUIUtility.TrTextContent("GPU memory: N/A");
            }
            GUILayout.Label(GPUSizeContent, EditorStyles.miniLabel);

            GUILayout.EndVertical();
        }
        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);
        }