private GameObject GetPrefBy(EPlatformType type) { var path = ""; switch (type) { case EPlatformType.Platform: { path = ConfigurationData.PLATFORM_PATH; break; } case EPlatformType.Space: { path = ConfigurationData.SPACE_PATH; break; } case EPlatformType.Obstacle: { path = ConfigurationData.OBSTACLE_PATH; break; } } return(Resources.Load <GameObject>(path)); }
private ISDKTool GetSdkTool(EPlatformType type) { ISDKTool sdkTool = null; switch (Application.platform) { case RuntimePlatform.WindowsEditor: case RuntimePlatform.Android: Type sdkType = Type.GetType("AndroidSDKToolImpl"); sdkTool = (ISDKTool)Activator.CreateInstance(sdkType); break; case RuntimePlatform.WindowsPlayer: Type toolType = typeof(WindowsSDKToolImpl); if (type == EPlatformType.Platform_Tencent) { toolType = Type.GetType("WindowsTencensSDKToolImpl"); } else if (type == EPlatformType.Platform_Baidu) { toolType = Type.GetType("WindowsBaiduSDKToolImpl"); } sdkTool = (ISDKTool)Activator.CreateInstance(toolType); break; } return(sdkTool); }
static async System.Threading.Tasks.Task CookPlatformShader(string[] args, string platform, string[] sm, HashSet <RName> MaterialAssets) { //把准备打包的数据做一次优化,初步想法是利用杨智做的Package流程,重新走一次资源存盘,然后用参数控制特殊Save流程 var cookShader = FindArgument(args, "cookshader"); if (cookShader != null) { CEngine.Instance.FileManager.CookingPlatform = platform; EPlatformType platformFlags = EPlatformType.PLATFORM_WIN; platformFlags = 0; if (platform == "windows") { platformFlags = EPlatformType.PLATFORM_WIN; } else if (platform == "android") { platformFlags = EPlatformType.PLATFORM_DROID; } else if (platform == "ios") { platformFlags = EPlatformType.PLATFORM_IOS; } foreach (var i in sm)//每个平台的多个shadermodel { await CookShadersWithFilter(args, i, platformFlags, MaterialAssets); } } }
public bool Init(bool noPixelShader, bool noPixelWrite, EPlatformType platforms) { RName noPsShader = RName.GetRName("Shaders/ShadingEnv/Sys/NoPixelShader.shadingenv"); var rc = CEngine.Instance.RenderContext; var shaderDesc = rc.CreateShaderDesc(noPsShader, "PS_Main", EShaderType.EST_PixelShader, new CShaderDefinitions(), platforms); if (shaderDesc == null) { return(false); } var ps = rc.CreatePixelShader(shaderDesc); SDK_GraphicsProfiler_SetEmptyPixelShader(CoreObject, ps.CoreObject); if (noPixelWrite) { CFrameBuffersDesc FBDesc = new CFrameBuffersDesc(); FBDesc.IsSwapChainBuffer = vBOOL.FromBoolean(false); FBDesc.UseDSV = vBOOL.FromBoolean(false); var mFrameBuffer = rc.CreateFrameBuffers(FBDesc); if (mFrameBuffer == null) { return(false); } CTexture2DDesc TexDesc = new CTexture2DDesc(); TexDesc.Init(); TexDesc.Width = 1; TexDesc.Height = 1; TexDesc.Format = EPixelFormat.PXF_R8G8B8A8_UNORM; TexDesc.BindFlags = (UInt32)(EBindFlags.BF_SHADER_RES | EBindFlags.BF_RENDER_TARGET); var Tex2D = rc.CreateTexture2D(TexDesc); CShaderResourceViewDesc SRVDesc = new CShaderResourceViewDesc(); SRVDesc.mTexture2D = Tex2D.CoreObject; var SRV = rc.CreateShaderResourceView(SRVDesc); mFrameBuffer.BindSRV_RT((UInt32)0, SRV); CRenderTargetViewDesc RTVDesc = new CRenderTargetViewDesc(); RTVDesc.mTexture2D = Tex2D.CoreObject; var RTV = rc.CreateRenderTargetView(RTVDesc); mFrameBuffer.BindRenderTargetView((UInt32)0, RTV); //depth stencil view; CDepthStencilViewDesc mDSVDesc = new CDepthStencilViewDesc(); mDSVDesc.Width = 1; mDSVDesc.Height = 1; var mDepthStencilView = rc.CreateDepthStencilView(mDSVDesc); mFrameBuffer.BindDepthStencilView(mDepthStencilView); SDK_GraphicsProfiler_SetOnePixelFrameBuffers(CoreObject, mFrameBuffer.CoreObject); } NoPixelShader = noPixelShader; NoPixelWrite = noPixelWrite; return(true); }
public static async System.Threading.Tasks.Task <bool> RunCook(RName entry, EPlatformType platform, int shaderModel, bool bCookShader, bool bRecompileShader, bool bGenVSProj, bool bCopyInfo, List <string> outInfos) { List <string> args = new List <string>(); args.Add("cook"); args.Add($"entry={entry.Name}"); args.Add($"platform={PlatformType2Name(platform)}"); args.Add($"shadermodel={shaderModel.ToString()}"); if (bCookShader) { args.Add("cookshader"); } if (bRecompileShader) { args.Add("recompile"); } if (bGenVSProj) { args.Add("genvsproj"); } if (bCopyInfo) { args.Add("copyrinfo"); } return(await RunEditorCMD(args, outInfos)); }
/// <summary> Initializes and sizes the arrays. Size is known as soon as header is serialized. </summary> public void Initialize(FProfileDataHeader Header) { Platform = Header.Platform; PlatformName = Header.PlatformName; NameArray = new List <string>((int)Header.NameTableEntries); CallStackArray = new List <FCallStack>((int)Header.CallStackTableEntries); CallStackAddressArray = new List <FCallStackAddress>((int)Header.CallStackAddressTableEntries); }
public static int get_screen_tiles_height_by_platform_type_uni(EPlatformType _platform_type, data_sets_manager.EScreenDataType _type, bool _native = false) { if (_type == data_sets_manager.EScreenDataType.sdt_Tiles4x4) { return(get_screen_tiles_height(_platform_type, _native)); } else { return(get_screen_blocks_height(_platform_type, _native)); } }
void OnGUI() { GUILayout.Space(20); //写下版本号 GUILayout.BeginHorizontal(); GUILayout.Label("主版本号:", GUILayout.Width(60)); mMajor = (byte)EditorGUILayout.IntField("", mMajor, GUILayout.Width(50)); GUILayout.Space(20); GUILayout.Label("子版本号:", GUILayout.Width(60)); mMinor = (byte)EditorGUILayout.IntField("", mMinor, GUILayout.Width(50)); GUILayout.Space(20); GUILayout.Label("svn版本号:", GUILayout.Width(60)); mSvn = EditorGUILayout.IntField("", mSvn, GUILayout.Width(80)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("打包平台:", GUILayout.Width(60)); mPlatform = (EPlatformType)EditorGUILayout.EnumPopup("", mPlatform, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("最后一次补丁路径:", GUILayout.Width(60)); mLastPatchPath = EditorGUILayout.TextField("", mLastPatchPath); if (GUILayout.Button("...", GUILayout.Width(40))) { mLastPatchPath = SelectPatchPath(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("补丁路径:", GUILayout.Width(60)); mCurrPatchPath = EditorGUILayout.TextField("", mCurrPatchPath); if (GUILayout.Button("...", GUILayout.Width(40))) { mCurrPatchPath = SelectPatchPath(); } GUILayout.EndHorizontal(); GUILayout.Space(25); if (GUILayout.Button("开始打资源补丁")) { DoPublish(); } }
public static string PlatformType2Name(EPlatformType platform) { switch (platform) { case EPlatformType.PLATFORM_DROID: return("android"); case EPlatformType.PLATFORM_IOS: return("ios"); case EPlatformType.PLATFORM_WIN: return("windows"); default: return("unknown"); } }
public static int[] get_palette_by_platform_type(EPlatformType _type) { switch (_type) { case EPlatformType.pt_NES: { return(NES_palette); } case EPlatformType.pt_SMS: { return(SMS_palette); } case EPlatformType.pt_SMD: case EPlatformType.pt_PCE: { if (PCE_SMD_palette == null) { PCE_SMD_palette = new int[CONST_PCE_SMD_PALETTE_NUM_COLORS]; int r, g, b; for (int i = 0; i < CONST_PCE_SMD_PALETTE_NUM_COLORS; i++) { b = 36 * (i & 0x007); r = 36 * ((i & 0x038) >> 3); g = 36 * ((i & 0x1c0) >> 6); PCE_SMD_palette[i] = (r << 16) | (g << 8) | b; } } return(PCE_SMD_palette); } case EPlatformType.pt_ZX: { return(ZX_palette); } } throw new Exception("platform_data.get_palette_by_platform_type(...) : invalid parameter!"); }
public void Login() { if (!Social.localUser.authenticated) // 로그인 되어 있지 않다면 { Social.localUser.Authenticate((bool success, string error) => // 로그인 시도 { UI_Start.Get().btn_GuestAccount.gameObject.SetActive(false); UI_Start.Get().btn_GooglePlay.gameObject.SetActive(false); UI_Start.Get().btn_GameCenter.gameObject.SetActive(false); if (success) // 성공하면 { #if UNITY_EDITOR type = EPlatformType.Guest; #elif UNITY_ANDROID type = EPlatformType.Android; #elif UNITY_IOS type = EPlatformType.IOS; #endif StartCoroutine(LoginCoroutine(true)); } else // 실패하면 { Debug.Log("Login Error : " + error); UI_Start.Get().btn_GuestAccount.gameObject.SetActive(true); #if UNITY_ANDROID UI_Start.Get().btn_GooglePlay.gameObject.SetActive(true); #elif UNITY_IOS UI_Start.Get().btn_GameCenter.gameObject.SetActive(true); #endif } }); } else { UI_Start.Get().btn_GuestAccount.gameObject.SetActive(false); UI_Start.Get().btn_GooglePlay.gameObject.SetActive(false); UI_Start.Get().btn_GameCenter.gameObject.SetActive(false); StartCoroutine(LoginCoroutine(true)); } }
static platform_data() { int i; for (i = 0; i < m_platform_names_arr.Length; i++) { m_platform_name_platform_type_dict[m_platform_names_arr[i]] = ( EPlatformType )i; } m_platform = m_platform_name_platform_type_dict[CONST_PLATFORM]; for (i = 0; i < m_platform_file_ext_arr.Length; i++) { m_file_ext_platform_type_dict[m_platform_file_ext_arr[i]] = ( EPlatformType )i; } m_scr_tiles_width = m_platform_screen_tiles_width_cnt[( int )m_platform]; m_scr_tiles_height = m_platform_screen_tiles_height_cnt[( int )m_platform]; m_scr_blocks_width = m_platform_screen_blocks_width_cnt[( int )m_platform]; m_scr_blocks_height = m_platform_screen_blocks_height_cnt[( int )m_platform]; }
public void LinkPlatform(bool isConfirm, GameBaseAccountProtocol.ReceiveAccountPlatformLinkAckDelegate callback) { this.isConfirm = isConfirm; platformLinkCallback = callback; if (!Social.localUser.authenticated) // 로그인 되어 있지 않다면 { Social.localUser.Authenticate((bool success, string error) => // 로그인 시도 { if (success) // 성공하면 { #if UNITY_EDITOR type = EPlatformType.Guest; #elif UNITY_ANDROID type = EPlatformType.Android; #elif UNITY_IOS type = EPlatformType.IOS; #endif StartCoroutine(LoginCoroutine(false)); } else // 실패하면 { Debug.Log("Login Error : " + error); } }); } else { #if UNITY_EDITOR type = EPlatformType.Guest; #elif UNITY_ANDROID type = EPlatformType.Android; #elif UNITY_IOS type = EPlatformType.IOS; #endif StartCoroutine(LoginCoroutine(false)); } }
public void Save2Xnd(IO.XndNode node, EPlatformType platforms) { SDK_IShaderDesc_Save2Xnd(CoreObject, node.CoreObject, (UInt32)platforms); }
/// <summary> Initializes and sizes the arrays. Size is known as soon as header is serialized. </summary> public void Initialize( FProfileDataHeader Header ) { Platform = Header.Platform; PlatformName = Header.PlatformName; NameArray = new List<string>( (int)Header.NameTableEntries ); CallStackArray = new List<FCallStack>( (int)Header.CallStackTableEntries ); CallStackAddressArray = new List<FCallStackAddress>( (int)Header.CallStackAddressTableEntries ); }
//工程整理 static IEnumerator _OnBuildAllAssetBundles(EPlatformType pfType, string projectPath, string channelid) { AndroidProjectArrangement(projectPath); yield return(null);// if (pfType == EPlatformType.SDK_Test || pfType == EPlatformType.VersionPackage) { //如果是测试版本,修改广告文件 #region 修改发布渠道 //修改AndroidManifest string MainfestPath = projectPath + "AndroidManifest.xml"; if (File.Exists(MainfestPath)) { try { string AndroidManifest = File.ReadAllText(MainfestPath); AndroidManifest = AndroidManifest.Replace("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", channelid); File.WriteAllText(MainfestPath, AndroidManifest); } catch (Exception e) { Debug.LogError(e); } } else { Debug.LogError($"未找到AndroidManifest.xml文件+{MainfestPath}"); } #endregion //修改AdsConstant string AdsConstantPath = projectPath + "src/com/pdragon/ad/AdsConstant.java"; if (File.Exists(AdsConstantPath)) { string str1 = "ShowSplashAd"; string str2 = "SplashAdCallback"; string str3 = "ShowBannerAd"; string str4 = "ShowInterstitialAd"; string str5 = "ShowVideoAd"; try { string[] lines = File.ReadAllLines(AdsConstantPath); for (int i = 0; i < lines.Length; i++) { if (lines[i].Contains(str1) || lines[i].Contains(str2) || lines[i].Contains(str3) || lines[i].Contains(str4) || lines[i].Contains(str5)) { lines[i] = lines[i].Replace("false", "true"); } } File.WriteAllLines(AdsConstantPath, lines); } catch (Exception e) { Debug.LogError(e); } } //删除生成的UnityPlayerActivity.java文件 string UnityPlayerActivityPath = projectPath + "src/com/wedobest/u3d/demo/UnityPlayerActivity.java"; if (File.Exists(UnityPlayerActivityPath)) { File.Delete(UnityPlayerActivityPath); } //去掉VersionPackage宏定义 if (pfType == EPlatformType.VersionPackage) { //CopyVerPackgetFile(projectPath);//自动引用 不用复制文件操作 //版本包添加预定义宏 string ScriptingDefine = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android); ScriptingDefine = ScriptingDefine.Replace(",VersionPackage", ""); ScriptingDefine = ScriptingDefine.Replace("VersionPackage", ""); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, ScriptingDefine); } } ToolsHelper.Log("发布版本操作"); yield return(new WaitForSeconds(0.1f));//DessterministicAssetBundle //正式版修改包名 if (pfType == EPlatformType.SDK_Release) { ReleaseSDKFileModify(projectPath); } yield return(null); //由于加入了版本包文件,所以得删除版本包资源 if (pfType != EPlatformType.VersionPackage) { DeleteVersionPackageFile(projectPath); } yield return(null); //替换APPName //找到所有的strings.xml ModifyStringsXmlFile(projectPath, pfType == EPlatformType.SDK_Test?PlayerSettings.productName:GetAppSettingInfo(3)); ToolsHelper.Log("发包完成."); yield return(null); ToolsHelper.ShowExplorer(projectPath); }
public static int get_screen_blocks_height(EPlatformType _platform_type, bool _native = false) { return(_native ? m_platform_screen_blocks_height_cnt[( int )_platform_type]:m_scr_blocks_height); }
public void CookShaderDesc(RName shader, string entry, EShaderType type, CShaderDefinitions defines, int ShaderModel, EPlatformType platforms) { string cachedName = ""; string sm = "vs_5_0"; var shaderHash = UniHash.APHash(shader.Name + entry + defines.ToString()); var macro = defines.GetHash64().ToString(); switch (type) { case EShaderType.EST_ComputeShader: cachedName = $"cs/{shaderHash}_{macro}.cshader"; sm = "cs_5_0"; if (ShaderModel == 3) { return; } break; case EShaderType.EST_VertexShader: cachedName = $"vs/{shaderHash}_{macro}.vshader"; sm = "vs_5_0"; break; case EShaderType.EST_PixelShader: cachedName = $"ps/{shaderHash}_{macro}.pshader"; sm = "ps_5_0"; break; } var shaderFile = ""; switch (CIPlatform.Instance.PlayMode) { case CIPlatform.enPlayMode.Cook: shaderFile = CEngine.Instance.FileManager.CookingRoot + "deriveddatacache/" + $"sm{ShaderModel}/" + cachedName; break; case CIPlatform.enPlayMode.Game: case CIPlatform.enPlayMode.Editor: case CIPlatform.enPlayMode.PlayerInEditor: shaderFile = CEngine.Instance.FileManager.DDCDirectory + $"sm{ShaderModel}/" + cachedName; break; } using (var xnd = IO.XndHolder.SyncLoadXND(shaderFile)) { if (xnd != null) { bool needCompile = false; var fileDesc = CEngine.Instance.FileManager.HLSLFileDescManager.FindFileDesc(shader.Address); if (fileDesc != null) { var hashAttr = xnd.Node.FindAttrib("HashCode"); if (hashAttr != null) { hashAttr.BeginRead(); string savedHash; hashAttr.Read(out savedHash); hashAttr.EndRead(); if (savedHash != fileDesc.HashCode.ToString()) { needCompile = true; } } } if (needCompile == false) { CShaderDesc desc = new CShaderDesc(type); desc.LoadXnd(xnd.Node); return; } } { var desc = CompileHLSLFromFile(shader.Address, entry, sm, defines, platforms); var saved = IO.XndHolder.NewXNDHolder(); var fileDesc = CEngine.Instance.FileManager.HLSLFileDescManager.FindFileDesc(shader.Address); if (fileDesc != null) { var hashAttr = saved.Node.AddAttrib("HashCode"); hashAttr.BeginWrite(); hashAttr.Write(fileDesc.HashCode.ToString()); hashAttr.EndWrite(); desc.Save2Xnd(saved.Node, platforms); } IO.XndHolder.SaveXND(shaderFile, saved); } } }
public static int get_screen_tiles_width(EPlatformType _platform_type, bool _native = false) { return(_native ? m_platform_screen_tiles_width_cnt[( int )_platform_type]:m_scr_tiles_width); }
public static int get_CHR_bank_pages_cnt(EPlatformType _type) { return(m_CHR_bank_pages_cnt[( int )_type]); }
public static void BulidTarget(EPlatformType pfType, string channelid = "") { appSetting = ReadAppSettingTxt(); string pfName = pfType.ToString(); string app_name = $"{ Application.productName }.{pfName}_{ DateTime.Now.ToString("yyyyMMdd_HHmm")}"; string target_dir = ""; string target_name = ""; BuildTarget buildTarget = BuildTarget.Android; string applicationPath = Application.dataPath.Replace("/Assets", ""); switch (pfType) { case EPlatformType.SDK_ReleaseIOS: case EPlatformType.SDK_TestIOS: target_dir = applicationPath + "/Builds/BuildIOS"; target_name = app_name; buildTarget = BuildTarget.iOS; break; default: target_dir = applicationPath + "/Builds/BuildAndroid"; target_name = app_name; buildTarget = BuildTarget.Android; PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel19; EditorUserBuildSettings.exportAsGoogleAndroidProject = true; //SetKey(); break; } if (string.IsNullOrEmpty(channelid)) { //Test_IOS_Proj_xfkp channelid = "Test_" + buildTarget.ToString() + "_" + AppSetting.MineGameName; } Directory.CreateDirectory(target_dir); //PlayerSettings.bundleVersion = "9.9.9"; //PlayerSettings.ve = "9999"; if (pfType == EPlatformType.SDK_Test || pfType == EPlatformType.VersionPackage) { //安卓测试版设置包名 PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.wedobest.u3d.demo"); if (pfType == EPlatformType.VersionPackage) { //版本包添加预定义宏 string ScriptingDefine = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android); if (!ScriptingDefine.Contains("VersionPackage")) { if (string.IsNullOrEmpty(ScriptingDefine)) { ScriptingDefine = "VersionPackage"; } else { ScriptingDefine += ";VersionPackage"; } PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, ScriptingDefine); } } } else if (pfType == EPlatformType.SDK_Release) { //安卓发布版设置包名 PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, GetAppSettingInfo(2)); } BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, target_dir + "/" + target_name, buildTarget, BuildOptions.None); if (pfType == EPlatformType.SDK_ReleaseIOS || pfType == EPlatformType.SDK_TestIOS) { return; } ToolsHelper.Log("生成Android工程完成,开始替换SDK文件"); //整理安卓工程 string projectPath = target_dir + "/" + target_name + $"/{Application.productName}/"; //string projectPath = target_dir + "/" + "GameFrameworkTest.SDK_Test_20191210_1012" + $"/{Application.productName}/"; EditorCoroutineRunner.StartEditorCoroutine(_OnBuildAllAssetBundles(pfType, projectPath, channelid)); }
/** * Constructor, serializing header from passed in stream. * * @param BinaryStream Stream to serialize header from. */ public FProfileDataHeader(BinaryReader BinaryStream) { // Serialize the file format magic first. Magic = BinaryStream.ReadUInt32(); // Stop serializing data if magic number doesn't match. Most likely endian issue. if (Magic == ExpectedMagic) { // Version info for backward compatible serialization. Version = BinaryStream.ReadUInt32(); if (Version >= 4) { // Read platform name. PlatformName = FStreamParser.ReadString(BinaryStream); PlatformName = FixFixedSizeString(PlatformName); } else { // Read platform type. Platform = (EPlatformType)BinaryStream.ReadUInt32(); } // Whether symbol information was serialized. bShouldSerializeSymbolInfo = BinaryStream.ReadUInt32() == 0 ? false : true; if (Version >= 5) { // Name table offset in file and number of entries. NameTableOffset = BinaryStream.ReadUInt64(); NameTableEntries = BinaryStream.ReadUInt64(); // CallStack address table offset and number of entries. CallStackAddressTableOffset = BinaryStream.ReadUInt64(); CallStackAddressTableEntries = BinaryStream.ReadUInt64(); // CallStack table offset and number of entries. CallStackTableOffset = BinaryStream.ReadUInt64(); CallStackTableEntries = BinaryStream.ReadUInt64(); ModulesOffset = BinaryStream.ReadUInt64(); ModuleEntries = BinaryStream.ReadUInt64(); NumDataFiles = 1; } else { // Name table offset in file and number of entries. NameTableOffset = BinaryStream.ReadUInt32(); NameTableEntries = BinaryStream.ReadUInt32(); // CallStack address table offset and number of entries. CallStackAddressTableOffset = BinaryStream.ReadUInt32(); CallStackAddressTableEntries = BinaryStream.ReadUInt32(); // CallStack table offset and number of entries. CallStackTableOffset = BinaryStream.ReadUInt32(); CallStackTableEntries = BinaryStream.ReadUInt32(); ModulesOffset = BinaryStream.ReadUInt32(); ModuleEntries = BinaryStream.ReadUInt32(); // Number of data files the stream spans. NumDataFiles = BinaryStream.ReadUInt32(); } FStreamToken.Version = Version; if (Version >= 4) { // Just ignore } else if (Version > 2) { ScriptCallstackTableOffset = BinaryStream.ReadUInt32(); ScriptNameTableOffset = BinaryStream.ReadUInt32(); bDecodeScriptCallstacks = ScriptCallstackTableOffset != UInt32.MaxValue; } // Name of executable. ExecutableName = FStreamParser.ReadString(BinaryStream); ExecutableName = FixFixedSizeString(ExecutableName); } }
/** * Constructor, serializing header from passed in stream. * * @param BinaryStream Stream to serialize header from. */ public FProfileDataHeader(BinaryReader BinaryStream) { // Serialize the file format magic first. Magic = BinaryStream.ReadUInt32(); // Stop serializing data if magic number doesn't match. Most likely endian issue. if( Magic == ExpectedMagic ) { // Version info for backward compatible serialization. Version = BinaryStream.ReadUInt32(); // Platform and max backtrace depth. Platform = (EPlatformType)BinaryStream.ReadUInt32(); // Whether symbol information was serialized. bShouldSerializeSymbolInfo = BinaryStream.ReadUInt32() == 0 ? false : true; // Name table offset in file and number of entries. NameTableOffset = BinaryStream.ReadUInt32(); NameTableEntries = BinaryStream.ReadUInt32(); // CallStack address table offset and number of entries. CallStackAddressTableOffset = BinaryStream.ReadUInt32(); CallStackAddressTableEntries = BinaryStream.ReadUInt32(); // CallStack table offset and number of entries. CallStackTableOffset = BinaryStream.ReadUInt32(); CallStackTableEntries = BinaryStream.ReadUInt32(); ModulesOffset = BinaryStream.ReadUInt32(); ModuleEntries = BinaryStream.ReadUInt32(); // Number of data files the stream spans. NumDataFiles = BinaryStream.ReadUInt32(); FStreamToken.Version = Version; if (Version > 2) { ScriptCallstackTableOffset = BinaryStream.ReadUInt32(); ScriptNameTableOffset = BinaryStream.ReadUInt32(); bDecodeScriptCallstacks = ScriptCallstackTableOffset != UInt32.MaxValue; } // Name of executable. UInt32 ExecutableNameLength = BinaryStream.ReadUInt32(); ExecutableName = new string(BinaryStream.ReadChars((int)ExecutableNameLength)); // We serialize a fixed size string. Trim the null characters that make it in by converting char[] to string. int RealLength = 0; while( ExecutableName[RealLength++] != '\0' ) { } ExecutableName = ExecutableName.Remove(RealLength-1); } }
/// <summary> Initializes and sizes the arrays. Size is known as soon as header is serialized. </summary> public void Initialize( EPlatformType InPlatform, uint InNameArrayEntries, uint InCallStackArrayEntries, uint InCallStackAddressArrayEntries ) { Platform = InPlatform; NameArray = new List<string>( ( int )InNameArrayEntries ); CallStackArray = new List<FCallStack>( ( int )InCallStackArrayEntries ); CallStackAddressArray = new List<FCallStackAddress>( ( int )InCallStackAddressArrayEntries ); }
public CShaderDesc CreateShaderDesc(RName shader, string entry, EShaderType type, CShaderDefinitions defines, EPlatformType platforms) { string cachedName = ""; string sm = "vs_5_0"; var shaderHash = UniHash.APHash(shader.Name + entry + defines.ToString()); var macro = defines.GetHash64().ToString(); switch (type) { case EShaderType.EST_ComputeShader: cachedName = $"cs/{shaderHash}_{macro}.cshader"; sm = "cs_5_0"; if (ShaderModel == 3) { return(null); } break; case EShaderType.EST_VertexShader: cachedName = $"vs/{shaderHash}_{macro}.vshader"; sm = "vs_5_0"; break; case EShaderType.EST_PixelShader: cachedName = $"ps/{shaderHash}_{macro}.pshader"; sm = "ps_5_0"; break; } var smStr = CRenderContext.ShaderModelString; var shaderFile = CEngine.Instance.FileManager.DDCDirectory + smStr + "/" + cachedName; using (var xnd = IO.XndHolder.SyncLoadXND(shaderFile)) { if (xnd != null) { bool needCompile = false; var fileDesc = CEngine.Instance.FileManager.HLSLFileDescManager.FindFileDesc(shader.Address); if (fileDesc != null) { var hashAttr = xnd.Node.FindAttrib("HashCode"); if (hashAttr != null) { hashAttr.BeginRead(); string savedHash; hashAttr.Read(out savedHash); hashAttr.EndRead(); if (savedHash != fileDesc.HashCode.ToString()) { needCompile = true; } } } if (needCompile == false) { CShaderDesc desc = new CShaderDesc(type); desc.LoadXnd(xnd.Node); return(desc); } } { var xml = IO.XmlHolder.NewXMLHolder($"{type.ToString()}", ""); xml.RootNode.AddAttrib("Shader", shader.ToString()); xml.RootNode.AddAttrib("Entry", entry); var node = xml.RootNode.AddNode("Macro", "", xml); foreach (var i in defines.mShaderMacroArray) { node.AddAttrib(i.Name, i.Definition); } var fileDesc = CEngine.Instance.FileManager.HLSLFileDescManager.FindFileDesc(shader.Address); if (fileDesc != null) { xml.RootNode.AddAttrib("HashCode", fileDesc.HashCode.ToString()); } var shaderDescFile = CEngine.Instance.FileManager.DDCDirectory + "shaderinfo/" + cachedName + ".shaderxml"; IO.XmlHolder.SaveXML(shaderDescFile, xml); var desc = CompileHLSLFromFile(shader.Address, entry, sm, defines, platforms); var saved = IO.XndHolder.NewXNDHolder(); if (fileDesc != null) { var hashAttr = saved.Node.AddAttrib("HashCode"); hashAttr.BeginWrite(); hashAttr.Write(fileDesc.HashCode.ToString()); hashAttr.EndWrite(); } desc.Save2Xnd(saved.Node, platforms); IO.XndHolder.SaveXND(shaderFile, saved); return(desc); } } }
void Init() { titleContent = new GUIContent("补丁打包"); position = new Rect(30, 30, 500, 220); mPlatform = EPlatformType.Android; }
public CShaderDesc CompileHLSLFromFile(string file, string entry, string sm, CShaderDefinitions defines, EPlatformType platforms) { //defines.SetDefine("ShaderModel", CEngine.Instance.RenderContext.ShaderModel.ToString()); defines.SetDefine("ShaderModel", CRenderContext.ShaderModel.ToString()); unsafe { int TempIsCrossPlatform = CEngine.mGenerateShaderForMobilePlatform == true ? 1 : 0; CShaderDesc.NativePointer obj; if (defines == null) { obj = SDK_IRenderContext_CompileHLSLFromFile(CoreObject, file, entry, sm, CShaderDefinitions.GetEmptyNativePointer(), (UInt32)platforms, vBOOL.FromBoolean(IsDebugHLSL)); } else { obj = SDK_IRenderContext_CompileHLSLFromFile(CoreObject, file, entry, sm, defines.CoreObject, (UInt32)platforms, vBOOL.FromBoolean(IsDebugHLSL)); } defines.RemoveDefine("ShaderModel"); if (obj.Pointer == IntPtr.Zero) { return(null); } return(new CShaderDesc(obj)); } }
public static string get_platform_name(EPlatformType _type) { return(m_platform_names_arr[( int )_type]); }
public static int get_screen_tiles_cnt(EPlatformType _type, bool _native = false) { return(get_screen_tiles_width(_type, _native) * get_screen_tiles_height(_type, _native)); }
/** * Constructor, serializing header from passed in stream. * * @param BinaryStream Stream to serialize header from. */ public FProfileDataHeader(BinaryReader BinaryStream) { // Serialize the file format magic first. Magic = BinaryStream.ReadUInt32(); // Stop serializing data if magic number doesn't match. Most likely endian issue. if( Magic == ExpectedMagic ) { // Version info for backward compatible serialization. Version = BinaryStream.ReadUInt32(); if( Version >= 4 ) { // Read platform name. PlatformName = FStreamParser.ReadString( BinaryStream ); PlatformName = FixFixedSizeString( PlatformName ); } else { // Read platform type. Platform = (EPlatformType)BinaryStream.ReadUInt32(); } // Whether symbol information was serialized. bShouldSerializeSymbolInfo = BinaryStream.ReadUInt32() == 0 ? false : true; if( Version >= 5 ) { // Name table offset in file and number of entries. NameTableOffset = BinaryStream.ReadUInt64(); NameTableEntries = BinaryStream.ReadUInt64(); // CallStack address table offset and number of entries. CallStackAddressTableOffset = BinaryStream.ReadUInt64(); CallStackAddressTableEntries = BinaryStream.ReadUInt64(); // CallStack table offset and number of entries. CallStackTableOffset = BinaryStream.ReadUInt64(); CallStackTableEntries = BinaryStream.ReadUInt64(); ModulesOffset = BinaryStream.ReadUInt64(); ModuleEntries = BinaryStream.ReadUInt64(); NumDataFiles = 1; } else { // Name table offset in file and number of entries. NameTableOffset = BinaryStream.ReadUInt32(); NameTableEntries = BinaryStream.ReadUInt32(); // CallStack address table offset and number of entries. CallStackAddressTableOffset = BinaryStream.ReadUInt32(); CallStackAddressTableEntries = BinaryStream.ReadUInt32(); // CallStack table offset and number of entries. CallStackTableOffset = BinaryStream.ReadUInt32(); CallStackTableEntries = BinaryStream.ReadUInt32(); ModulesOffset = BinaryStream.ReadUInt32(); ModuleEntries = BinaryStream.ReadUInt32(); // Number of data files the stream spans. NumDataFiles = BinaryStream.ReadUInt32(); } FStreamToken.Version = Version; if( Version >= 4 ) { // Just ignore } else if (Version > 2) { ScriptCallstackTableOffset = BinaryStream.ReadUInt32(); ScriptNameTableOffset = BinaryStream.ReadUInt32(); bDecodeScriptCallstacks = ScriptCallstackTableOffset != UInt32.MaxValue; } // Name of executable. ExecutableName = FStreamParser.ReadString( BinaryStream ); ExecutableName = FixFixedSizeString( ExecutableName ); } }
private static int get_screen_blocks_cnt(EPlatformType _type) { return(get_screen_blocks_width(_type) * get_screen_blocks_height(_type)); }
public static string get_platform_file_ext(EPlatformType _type) { return(m_platform_file_ext_arr[( int )_type]); }
static async System.Threading.Tasks.Task CookShadersWithFilter(string[] args, string smStr, EPlatformType platforms, HashSet <RName> MaterialAssets) { var rc = CEngine.Instance.RenderContext; int ShaderModel = System.Convert.ToInt32(smStr); string targetDir = CEngine.Instance.FileManager.CookingRoot + "deriveddatacache/" + "/sm" + smStr + "/"; if (FindArgument(args, "recompile") != null) { if (CEngine.Instance.FileManager.DirectoryExists(targetDir)) { CEngine.Instance.FileManager.DeleteDirectory(targetDir, true); } } CEngine.Instance.FileManager.CreateDirectory(targetDir); CEngine.Instance.FileManager.CreateDirectory(targetDir + "cs/"); CEngine.Instance.FileManager.CreateDirectory(targetDir + "vs/"); CEngine.Instance.FileManager.CreateDirectory(targetDir + "ps/"); EngineNS.CRenderContext.ShaderModel = ShaderModel; var shaderPath = CEngine.Instance.FileManager.DDCDirectory + "shaderinfo/"; var shaders = CEngine.Instance.FileManager.GetFiles(shaderPath, "*.xml"); int NumOfFailed = 0; int NumOfNotUsed = 0; foreach (var i in shaders) { using (var xml = EngineNS.IO.XmlHolder.LoadXML(i)) { EngineNS.Graphics.CGfxEffectDesc desc = await EngineNS.Graphics.CGfxEffectDesc.LoadEffectDescFromXml(rc, xml.RootNode, false); if (desc == null) { EngineNS.Profiler.Log.WriteLine(EngineNS.Profiler.ELogTag.Warning, "CookShader", $"CookShader Failed: {xml.GetTextString()}"); NumOfFailed++; continue; } if (MaterialAssets.Contains(desc.MtlShaderPatch.Name) == false) { NumOfNotUsed++; continue; } var effect = new EngineNS.Graphics.CGfxEffect(desc); await effect.CookEffect(rc, desc, ShaderModel, platforms); } } shaders = CEngine.Instance.FileManager.GetFiles(shaderPath, "*.shaderxml"); foreach (var i in shaders) { using (var xml = EngineNS.IO.XmlHolder.LoadXML(i)) { RName shaderName = RName.GetRName(xml.RootNode.FindAttrib("Shader").Value, RName.enRNameType.Engine); EShaderType type = EShaderType.EST_UnknownShader; switch (xml.RootNode.Name) { case "EST_ComputeShader": type = EShaderType.EST_ComputeShader; break; case "EST_VertexShader": type = EShaderType.EST_VertexShader; break; case "EST_PixelShader": type = EShaderType.EST_PixelShader; break; } string entry = xml.RootNode.FindAttrib("Entry").Value; var node = xml.RootNode.FindNode("Macro"); var attrs = node.GetAttribs(); CShaderDefinitions defines = new CShaderDefinitions(); foreach (var j in attrs) { defines.SetDefine(j.Name, j.Value); } CEngine.Instance.RenderContext.CookShaderDesc(shaderName, entry, type, defines, ShaderModel, platforms); } } }