Beispiel #1
0
        private void AppendShaderParamTextures(JsonStringGenerator jsonStringGenerator, FrameInfoCrawler.ShaderProperties shaderParams)
        {
            if (shaderParams.convertedTextures == null)
            {
                return;
            }

            using (new JsonStringGenerator.ObjectArrayValueScope(jsonStringGenerator, "textures"))
            {
                foreach (var textureParam in shaderParams.convertedTextures)
                {
                    using (new JsonStringGenerator.ObjectScope(jsonStringGenerator))
                    {
                        var val = textureParam.value as Texture;
                        jsonStringGenerator.AddObjectValue("name", textureParam.name);
                        jsonStringGenerator.AddObjectValue("textureName", textureParam.textureName);
                        if (val != null)
                        {
#if UNITY_2019_1_OR_NEWER || UNITY_2019_OR_NEWER
                            jsonStringGenerator.AddObjectValue("originFormat", val.graphicsFormat.ToString());
#endif
                            jsonStringGenerator.AddObjectValue("originWidth", val.width);
                            jsonStringGenerator.AddObjectValue("originHeight", val.height);
                            jsonStringGenerator.AddObjectValue("originMipCount", TextureUtility.GetMipMapCount(val));
                        }
                        var saveInfo = textureParam.saveTextureInfo;
                        AppendSavedTextureInfo(jsonStringGenerator, "saved", saveInfo);
                    }
                }
            }
        }
Beispiel #2
0
        private void SaveDetailJsonData(string dirPath)
        {
            JsonStringGenerator jsonStringGenerator = new JsonStringGenerator();

            try
            {
                using (new JsonStringGenerator.ObjectScope(jsonStringGenerator))
                {
                    jsonStringGenerator.AddObjectValue("captureFlag", (int)captureFlag);
                    using (new JsonStringGenerator.ObjectArrayValueScope(jsonStringGenerator, "events"))
                    {
                        for (int i = 0; i < crawler.frameDebuggerEventDataList.Count; ++i)
                        {
                            var evt     = crawler.frameDebuggerEventList[i];
                            var evtData = crawler.frameDebuggerEventDataList[i];
                            AppendFrameEvent(jsonStringGenerator, evt, evtData);
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
            }
            File.WriteAllText(Path.Combine(dirPath, "detail.json"), jsonStringGenerator.ToString());
        }
Beispiel #3
0
 private void AppendShaderParam(JsonStringGenerator jsonStringGenerator, FrameInfoCrawler.ShaderProperties shaderParams)
 {
     using (new JsonStringGenerator.ObjectScopeWithName(jsonStringGenerator, "shaderParams"))
     {
         AppendShaderParamTextures(jsonStringGenerator, shaderParams);
         AppendShaderParamFloats(jsonStringGenerator, shaderParams);
         AppendShaderParamVectors(jsonStringGenerator, shaderParams);
         AppendShaderParamMatricies(jsonStringGenerator, shaderParams);
     }
 }
Beispiel #4
0
 private void AppendRenderTargetInfo(JsonStringGenerator jsonStringGenerator,
                                     FrameInfoCrawler.FrameDebuggerEventData evtData)
 {
     using (new JsonStringGenerator.ObjectScopeWithName(jsonStringGenerator, "renderTarget"))
     {
         jsonStringGenerator.AddObjectValue("rtName", evtData.rtName).
         AddObjectValue("rtWidth", evtData.rtWidth).AddObjectValue("rtHeight", evtData.rtHeight).
         AddObjectValue("rtCount", evtData.rtCount).AddObjectValue("rtHasDepthTexture", evtData.rtHasDepthTexture);
     }
 }
Beispiel #5
0
 private void AppendShaderParamBuffers(JsonStringGenerator jsonStringGenerator, FrameInfoCrawler.ShaderProperties shaderParams)
 {
     if (shaderParams.convertedBuffers == null)
     {
         return;
     }
     using (new JsonStringGenerator.ObjectArrayValueScope(jsonStringGenerator, "buffers"))
     {
         foreach (var bufferParam in shaderParams.convertedBuffers)
         {
             jsonStringGenerator.AddObjectValue(bufferParam.name, "No Implements");
         }
     }
 }
Beispiel #6
0
 private void AppendFrameEvent(JsonStringGenerator jsonStringGenerator,
                               FrameInfoCrawler.FrameDebuggerEvent evt,
                               FrameInfoCrawler.FrameDebuggerEventData evtData)
 {
     using (new JsonStringGenerator.ObjectScope(jsonStringGenerator))
     {
         jsonStringGenerator.AddObjectValue("frameEventIndex", evtData.frameEventIndex);
         jsonStringGenerator.AddObjectValue("type", evt.type.ToString());
         AppendSavedTextureInfo(jsonStringGenerator, "screenshot", evtData.savedScreenShotInfo);
         AppendRenderingInfo(jsonStringGenerator, evt, evtData);
         AppendRenderTargetInfo(jsonStringGenerator, evtData);
         AppendShaderInfo(jsonStringGenerator, evtData);
     }
 }
Beispiel #7
0
        private void AppendShaderInfo(JsonStringGenerator jsonStringGenerator,
                                      FrameInfoCrawler.FrameDebuggerEventData evtData)
        {
            using (new JsonStringGenerator.ObjectScopeWithName(jsonStringGenerator, "shaderInfo"))
            {
                jsonStringGenerator.AddObjectValue("shaderName", evtData.shaderName);
                jsonStringGenerator.AddObjectValue("subShaderIndex", evtData.subShaderIndex);
                jsonStringGenerator.AddObjectValue("shaderPassIndex", evtData.shaderPassIndex);
                jsonStringGenerator.AddObjectValue("passName", evtData.passName);
                jsonStringGenerator.AddObjectValue("passLightMode", evtData.passLightMode);
                jsonStringGenerator.AddObjectValue("shaderKeywords", evtData.shaderKeywords);

                AppendShaderParam(jsonStringGenerator, evtData.convertedProperties);
            }
        }
Beispiel #8
0
 private void AppendSavedTextureInfo(JsonStringGenerator jsonStringGenerator, string objName, TextureUtility.SaveTextureInfo saveInfo)
 {
     if (saveInfo == null)
     {
         return;
     }
     using (new JsonStringGenerator.ObjectScopeWithName(jsonStringGenerator, objName))
     {
         jsonStringGenerator.AddObjectValue("path", saveInfo.path);
         jsonStringGenerator.AddObjectValue("type", saveInfo.type);
         jsonStringGenerator.AddObjectValue("width", saveInfo.width);
         jsonStringGenerator.AddObjectValue("height", saveInfo.height);
         jsonStringGenerator.AddObjectValue("mipCount", saveInfo.mipCount);
         jsonStringGenerator.AddObjectValue("rawFormat", saveInfo.rawFormat.ToString());
     }
 }
Beispiel #9
0
 private void AppendShaderParamMatricies(JsonStringGenerator jsonStringGenerator, FrameInfoCrawler.ShaderProperties shaderParams)
 {
     if (shaderParams.convertedMatricies == null)
     {
         return;
     }
     using (new JsonStringGenerator.ObjectArrayValueScope(jsonStringGenerator, "matricies"))
     {
         foreach (var matrixParam in shaderParams.convertedMatricies)
         {
             using (new JsonStringGenerator.ObjectScope(jsonStringGenerator))
             {
                 var val = (Matrix4x4)matrixParam.value;
                 jsonStringGenerator.AddObjectValue("name", matrixParam.name);
                 jsonStringGenerator.AddObjectMatrix("val", ref val);
             }
         }
     }
 }
Beispiel #10
0
        private void AppendShaderParamFloats(JsonStringGenerator jsonStringGenerator, FrameInfoCrawler.ShaderProperties shaderParams)
        {
            if (shaderParams.convertedFloats == null)
            {
                return;
            }

            using (new JsonStringGenerator.ObjectArrayValueScope(jsonStringGenerator, "floats"))
            {
                foreach (var floatParam in shaderParams.convertedFloats)
                {
                    using (new JsonStringGenerator.ObjectScope(jsonStringGenerator))
                    {
                        jsonStringGenerator.AddObjectValue("name", floatParam.name);
                        jsonStringGenerator.AddObjectValue("val", (float)floatParam.value);
                    }
                }
            }
        }
Beispiel #11
0
        private void AppendShaderParamVectors(JsonStringGenerator jsonStringGenerator, FrameInfoCrawler.ShaderProperties shaderParams)
        {
            if (shaderParams.convertedVectors == null)
            {
                return;
            }

            using (new JsonStringGenerator.ObjectArrayValueScope(jsonStringGenerator, "vectors"))
            {
                foreach (var vectorParam in shaderParams.convertedVectors)
                {
                    using (new JsonStringGenerator.ObjectScope(jsonStringGenerator))
                    {
                        var val = (Vector4)vectorParam.value;
                        jsonStringGenerator.AddObjectValue("name", vectorParam.name);
                        jsonStringGenerator.AddObjectVector("val", ref val);
                    }
                }
            }
        }
Beispiel #12
0
 private void AppendRenderingInfo(JsonStringGenerator jsonStringGenerator,
                                  FrameInfoCrawler.FrameDebuggerEvent evt,
                                  FrameInfoCrawler.FrameDebuggerEventData evtData)
 {
     using (new JsonStringGenerator.ObjectScopeWithName(jsonStringGenerator, "rendering"))
     {
         jsonStringGenerator.AddObjectValue("vertexCount", evtData.vertexCount).
         AddObjectValue("indexCount", evtData.indexCount).
         AddObjectValue("instanceCount", evtData.instanceCount).
         AddObjectValue("drawCallCount", evtData.drawCallCount).
         AddObjectValue("componentInstanceID", evtData.componentInstanceID).
         AddObjectValue("meshInstanceID", evtData.meshInstanceID).
         AddObjectValue("meshSubset", evtData.meshSubset).
         AddObjectValue("batchBreakCauseStr", evtData.batchBreakCauseStr);
         if (evt.gameObject)
         {
             stringBuilder.Length = 0;
             GetGameObjectName(evt.gameObject, stringBuilder);
             jsonStringGenerator.AddObjectValue("gameobject", stringBuilder.ToString());
         }
     }
 }
Beispiel #13
0
 public ObjectArrayValueScope(JsonStringGenerator generator, string name)
 {
     this.jsonStringGenerator = generator;
     generator.StartObjectArray(name);
 }
Beispiel #14
0
 public ObjectScopeWithName(JsonStringGenerator generator, string name)
 {
     this.jsonStringGenerator = generator;
     generator.StartObjectWithName(name);
 }
Beispiel #15
0
 public ObjectScope(JsonStringGenerator generator)
 {
     this.jsonStringGenerator = generator;
     generator.StartObject();
 }