public void IncludeRenderPlatform(RenderPlatform plat) { if (includeRenderers.Contains(plat) == false) { includeRenderers.Add(plat); } }
//private enum LookingFor{ }; public void UpdateInstructionCount(Shader sh) { // Compiled shader string: string[] css = (new SerializedObject(sh)).FindProperty("m_Script").stringValue.Split('\n'); Debug.Log((new SerializedObject(sh)).FindProperty("m_Script").stringValue); Debug.Log(css.Length); if (css.Length < 2) { return; } ShaderProgram prog = ShaderProgram.Vert; List <SFIns_Pass> passes = new List <SFIns_Pass>(); SFIns_Pass cPass; // current pass for (int i = 0; i < css.Length; i++) { if (css[i].Contains("Pass {")) // Found a pass! { bool ignoreMin = false; i++; // Shadow passes if (css[i].Contains("Name \"ShadowCaster\"") || css[i].Contains("Name \"ShadowCollector\"") || css[i].Contains("Name \"ForwardAdd\"")) { continue; } if ((css[i].Contains("Name \"PrePassBase\"") || css[i].Contains("Name \"PrePassFinal\"")) && editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Forward) { continue; } if ((css[i].Contains("Name \"ForwardBase\"") || css[i].Contains("Name \"ForwardAdd\"")) && editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred) { continue; } //ignoreMin = true; cPass = new SFIns_Pass(); for ( ; i < css.Length; i++) { if (css[i].StartsWith("// Vertex combos")) { prog = ShaderProgram.Vert; } else if (css[i].StartsWith("// Fragment combos")) { prog = ShaderProgram.Frag; } else { continue; } // Program found! i++; // Next line... // Scan following lines for shader platform data for ( ; i < css.Length; i++) { if (css[i].StartsWith("//")) { cPass.Parse(prog, css[i], ignoreMin); } else { // No more platform data break; } } // Leave this loop and start searching for the next pass if we just found the frag data if (prog == ShaderProgram.Frag) { break; } } // Add the current pass to the list passes.Add(cPass); } } // All passes scanned! // Show, some sort of instruction count // Show sum of all passes min for now vCount.Reset(); fCount.Reset(); vtCount.Reset(); ftCount.Reset(); // Find which program to display instruction count for! // if(mac) opengl // if(win) d3d9 // else gles // else *any enabled* platform = GetPrimaryPlatform(); int primPlat = (int)platform; // Debug.Log("Primary platform: " + (RenderPlatform)primPlat); foreach (SFIns_Pass p in passes) { vCount += p.plats[primPlat].vert; // Only d3d9 for now // TODO fCount += p.plats[primPlat].frag; vtCount += p.plats[primPlat].vTex; ftCount += p.plats[primPlat].fTex; } //Debug.Log("vCount = " + vCount); /* * int programID = 0; // 0 = vert | 1 = frag * for( int i = 0; i < css.Length; i++ ) { * if( css[i].Contains( "instructions" ) ) * continue; * if( css[i].Contains( "# " ) ) { * if( programID == 0 ) { * string[] split = css[i].Trim().Split( ' ' ); * vCount = int.Parse( split[1] ); // Vertex instructions TODO: Textures in vertex program * programID++; // Search for fragment * } else if( programID == 1 ) { * string[] split = css[i].Trim().Split( ' ' ); * fCount = int.Parse( split[1] ); // Fragment instructions * try { * tCount = int.Parse( split[3] ); // Textures * } catch { * * } * * } * } * } */ }
public SFIns_PassPlat(RenderPlatform plat) { this.plat = plat; }