From e261761d5ae23ee99158eebcd7dcb54f9669f850 Mon Sep 17 00:00:00 2001 From: Scorr Date: Wed, 13 Feb 2019 03:52:25 +0100 Subject: [PATCH 1/3] limit update to rom framerate --- .../RetroUnity/Examples/Scenes/Main.unity | 250 ++++++++++-------- .../Plugins/RetroUnity/Scripts/GameManager.cs | 27 +- ProjectSettings/ProjectSettings.asset | 247 +++++++++-------- ProjectSettings/QualitySettings.asset | 11 +- ProjectSettings/TimeManager.asset | 1 + 5 files changed, 282 insertions(+), 254 deletions(-) diff --git a/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity b/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity index 5731ea4..4cd0c83 100644 --- a/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity +++ b/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 8 + serializedVersion: 9 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -39,6 +39,7 @@ RenderSettings: m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -49,16 +50,14 @@ LightmapSettings: m_BounceScale: 1 m_IndirectOutputScale: 1 m_AlbedoBoost: 1 - m_TemporalCoherenceThreshold: 1 m_EnvironmentLightingMode: 0 m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 9 + serializedVersion: 10 m_Resolution: 2 m_BakeResolution: 40 - m_TextureWidth: 1024 - m_TextureHeight: 1024 + m_AtlasSize: 1024 m_AO: 0 m_AOMaxDistance: 1 m_CompAOExponent: 0 @@ -77,15 +76,18 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 - m_PVRFiltering: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 m_PVRFilteringMode: 1 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousColorSigma: 1 - m_PVRFilteringAtrousNormalSigma: 1 - m_PVRFilteringAtrousPositionSigma: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 0 --- !u!196 &4 @@ -107,13 +109,16 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + debug: + m_Flags: 0 m_NavMeshData: {fileID: 0} --- !u!1 &536390079 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 536390081} - component: {fileID: 536390080} @@ -127,8 +132,9 @@ GameObject: --- !u!108 &536390080 Light: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 536390079} m_Enabled: 1 serializedVersion: 8 @@ -154,22 +160,9 @@ Light: serializedVersion: 2 m_Bits: 4294967295 m_Lightmapping: 4 + m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 - m_FalloffTable: - m_Table[0]: 0 - m_Table[1]: 0 - m_Table[2]: 0 - m_Table[3]: 0 - m_Table[4]: 0 - m_Table[5]: 0 - m_Table[6]: 0 - m_Table[7]: 0 - m_Table[8]: 0 - m_Table[9]: 0 - m_Table[10]: 0 - m_Table[11]: 0 - m_Table[12]: 0 m_ColorTemperature: 6570 m_UseColorTemperature: 0 m_ShadowRadius: 0 @@ -177,8 +170,9 @@ Light: --- !u!4 &536390081 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 536390079} m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.109381676, w: 0.87542605} m_LocalPosition: {x: 0, y: 3, z: 0} @@ -189,14 +183,17 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &589599783 stripped Transform: - m_PrefabParentObject: {fileID: 400000, guid: ad6611d95a9ac7d45bc4da137220780c, type: 3} - m_PrefabInternal: {fileID: 793110061} + m_CorrespondingSourceObject: {fileID: 400000, guid: ad6611d95a9ac7d45bc4da137220780c, + type: 3} + m_PrefabInstance: {fileID: 793110061} + m_PrefabAsset: {fileID: 0} --- !u!1 &635089073 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 635089077} - component: {fileID: 635089076} @@ -212,15 +209,19 @@ GameObject: --- !u!23 &635089074 MeshRenderer: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 + m_DynamicOccludee: 1 m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 m_Materials: - {fileID: 2100000, guid: ea16435dffa3e34408933b59f313504c, type: 2} m_StaticBatchInfo: @@ -233,6 +234,7 @@ MeshRenderer: m_PreserveUVs: 1 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 + m_StitchLightmapSeams: 0 m_SelectedEditorRenderState: 3 m_MinimumChartSize: 4 m_AutoUVMaxDistance: 0.5 @@ -244,29 +246,31 @@ MeshRenderer: --- !u!64 &635089075 MeshCollider: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 2 + serializedVersion: 3 m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 + m_CookingOptions: 14 m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &635089076 MeshFilter: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &635089077 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_LocalRotation: {x: 0, y: 0, z: 1, w: -0.00000016292068} m_LocalPosition: {x: 0, y: 6.2, z: -0.16} @@ -276,7 +280,7 @@ Transform: m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &793110061 -Prefab: +PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: @@ -315,14 +319,14 @@ Prefab: value: 4 objectReference: {fileID: 0} m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: ad6611d95a9ac7d45bc4da137220780c, type: 3} - m_IsPrefabParent: 0 + m_SourcePrefab: {fileID: 100100000, guid: ad6611d95a9ac7d45bc4da137220780c, type: 3} --- !u!1 &794582236 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 794582239} - component: {fileID: 794582237} @@ -337,8 +341,9 @@ GameObject: --- !u!114 &794582237 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 794582236} m_Enabled: 1 m_EditorHideFlags: 0 @@ -348,8 +353,9 @@ MonoBehaviour: --- !u!82 &794582238 AudioSource: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 794582236} m_Enabled: 1 serializedVersion: 4 @@ -375,62 +381,78 @@ AudioSource: rolloffCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 1 inSlope: 0 outSlope: 0 tangentMode: 0 - - serializedVersion: 2 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 time: 1 value: 0 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 panLevelCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 0 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 0 spreadCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 0 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 0 reverbZoneMixCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 1 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 0 --- !u!4 &794582239 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 794582236} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -442,9 +464,10 @@ Transform: --- !u!1 &1042651432 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 1042651434} - component: {fileID: 1042651433} @@ -459,8 +482,9 @@ GameObject: --- !u!114 &1042651433 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1042651432} m_Enabled: 1 m_EditorHideFlags: 0 @@ -470,8 +494,9 @@ MonoBehaviour: --- !u!4 &1042651434 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1042651432} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -483,81 +508,81 @@ Transform: --- !u!114 &1042651435 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1042651432} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 52ea678dff3796c4c92ab162cb5764bd, type: 3} m_Name: m_EditorClassIdentifier: - CoreName: vbam_libretro.dll - RomName: 1695 - Pokemon Fire Red (U)(Independent).gba + CoreName: snes9x_libretro.dll + RomName: Chrono Trigger (USA).sfc Display: {fileID: 635089074} --- !u!1001 &1178825821 -Prefab: +PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalPosition.y value: -12.5 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalPosition.z value: 4 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.x value: 0.000000115202326 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.y value: 0.7071068 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.z value: 0.7071067 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.w value: -0.00000011520231 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalScale.x value: 10 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalScale.y value: 10 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalScale.z value: 10 objectReference: {fileID: 0} m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} - m_IsPrefabParent: 0 + m_SourcePrefab: {fileID: 100100000, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} --- !u!1 &1702816979 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 1702816984} - component: {fileID: 1702816983} - - component: {fileID: 1702816982} - component: {fileID: 1702816981} - component: {fileID: 1702816980} - component: {fileID: 1702816985} @@ -571,34 +596,35 @@ GameObject: --- !u!81 &1702816980 AudioListener: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_Enabled: 1 --- !u!124 &1702816981 Behaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1702816979} - m_Enabled: 1 ---- !u!92 &1702816982 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_Enabled: 1 --- !u!20 &1702816983 Camera: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 2 m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 + m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -620,16 +646,17 @@ Camera: m_TargetEye: 3 m_HDR: 0 m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 - m_StereoMirrorMode: 0 --- !u!4 &1702816984 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: -10} @@ -641,10 +668,11 @@ Transform: --- !u!114 &1702816985 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: aaf7309e7e423004696df04cdf3b7a8b, type: 3} m_Name: diff --git a/Assets/Plugins/RetroUnity/Scripts/GameManager.cs b/Assets/Plugins/RetroUnity/Scripts/GameManager.cs index c77058a..0b9b810 100644 --- a/Assets/Plugins/RetroUnity/Scripts/GameManager.cs +++ b/Assets/Plugins/RetroUnity/Scripts/GameManager.cs @@ -9,35 +9,28 @@ public class GameManager : MonoBehaviour { [SerializeField] private string RomName = "Chrono Trigger (USA).sfc"; private LibretroWrapper.Wrapper wrapper; + private float _frameTimer; + public Renderer Display; private void Awake() { - Application.targetFrameRate = 60; LoadRom(Application.streamingAssetsPath + "/" + RomName); } private void Update() { if (wrapper != null) { - wrapper.Update(); + _frameTimer += Time.deltaTime; + float timePerFrame = 1f / (float)wrapper.GetAVInfo().timing.fps; + + while (_frameTimer >= timePerFrame) + { + wrapper.Update(); + _frameTimer -= timePerFrame; + } } if (LibretroWrapper.tex != null) { Display.material.mainTexture = LibretroWrapper.tex; } - - // debug input - //if (Input.GetButton("B")) Debug.Log("B"); - //if (Input.GetButton("Y")) Debug.Log("Y"); - //if (Input.GetButton("SELECT")) Debug.Log("SELECT"); - //if (Input.GetButton("START")) Debug.Log("START"); - //if (Input.GetAxisRaw("DpadX") >= 1.0f) Debug.Log("UP"); - //if (Input.GetAxisRaw("DpadX") <= -1.0f) Debug.Log("DOWN"); - //if (Input.GetAxisRaw("DpadY") >= 1.0f) Debug.Log("RIGHT"); - //if (Input.GetAxisRaw("DpadY") <= -1.0f) Debug.Log("LEFT"); - //if (Input.GetButton("A")) Debug.Log("A"); - //if (Input.GetButton("X")) Debug.Log("X"); - //if (Input.GetButton("L")) Debug.Log("L"); - //if (Input.GetButton("R")) Debug.Log("R"); - } public void LoadRom(string path) { diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index d2af132..615c103 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,9 +3,11 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 12 + serializedVersion: 15 productGUID: 0600f466d2bb79d45aa373ee29d3a2aa AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 @@ -38,8 +40,6 @@ PlayerSettings: width: 1 height: 1 m_SplashScreenLogos: [] - m_SplashScreenBackgroundLandscape: {fileID: 0} - m_SplashScreenBackgroundPortrait: {fileID: 0} m_VirtualRealitySplashScreen: {fileID: 0} m_HolographicTrackingLossScreen: {fileID: 0} defaultScreenWidth: 1024 @@ -49,11 +49,9 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 - m_MobileMTRendering: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - tizenShowActivityIndicatorOnLoading: -1 iosAppInBackgroundBehavior: 0 displayResolutionDialog: 0 iosAllowHTTPDownload: 1 @@ -63,14 +61,20 @@ PlayerSettings: allowedAutorotateToLandscapeLeft: 1 useOSAutorotation: 1 use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 disableDepthAndStencilBuffers: 0 - defaultIsFullScreen: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 0 + androidBlitType: 0 defaultIsNativeResolution: 1 + macRetinaSupport: 1 runInBackground: 1 captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 bakeCollisionMeshes: 0 @@ -88,33 +92,21 @@ PlayerSettings: visibleInBackground: 0 allowFullscreenSwitch: 1 graphicsJobMode: 0 - macFullscreenMode: 2 - d3d9FullscreenMode: 1 - d3d11FullscreenMode: 1 + fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 - n3dsDisableStereoscopicView: 0 - n3dsEnableSharedListOpt: 1 - n3dsEnableVSync: 0 - ignoreAlphaClear: 0 + metalFramebufferOnly: 0 xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 xboxOneDisableEsram: 0 - videoMemoryForVertexBuffers: 0 - psp2PowerMode: 0 - psp2AcquireBGM: 1 - wiiUTVResolution: 0 - wiiUGamePadMSAA: 1 - wiiUSupportsNunchuk: 0 - wiiUSupportsClassicController: 0 - wiiUSupportsBalanceBoard: 0 - wiiUSupportsMotionPlus: 0 - wiiUSupportsProController: 0 - wiiUAllowScreenCapture: 1 - wiiUControllerCount: 0 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 0 + vulkanEnableSetSRGBWrite: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -124,9 +116,11 @@ PlayerSettings: bundleVersion: 1.0 preloadedAssets: [] metroInputSource: 0 + wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 0 xboxOneEnable7thCore: 0 + isWsaHolographicRemotingEnabled: 0 vrSettings: cardboard: depthFormat: 0 @@ -134,12 +128,25 @@ PlayerSettings: daydream: depthFormat: 0 useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 hololens: depthFormat: 1 + depthBufferSharingEnabled: 0 + oculus: + sharedDepthBuffer: 1 + dashSupport: 1 + enable360StereoCapture: 0 protectGraphicsMemory: 0 + enableFrameTimingStats: 0 useHDRDisplay: 0 - targetPixelDensity: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 applicationIdentifier: Android: com.scorr.retrounity Standalone: unity.DefaultCompany.RetroUnity @@ -162,11 +169,9 @@ PlayerSettings: APKExpansionFiles: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 - VertexChannelCompressionMask: - serializedVersion: 2 - m_Bits: 238 + VertexChannelCompressionMask: 214 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 6.0 + iOSTargetOSVersionString: 9.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 tvOSTargetOSVersionString: 9.0 @@ -182,15 +187,22 @@ PlayerSettings: iPhone47inSplashScreen: {fileID: 0} iPhone55inPortraitSplashScreen: {fileID: 0} iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} iPadPortraitSplashScreen: {fileID: 0} iPadHighResPortraitSplashScreen: {fileID: 0} iPadLandscapeSplashScreen: {fileID: 0} iPadHighResLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] iOSLaunchScreenType: 0 iOSLaunchScreenPortrait: {fileID: 0} iOSLaunchScreenLandscape: {fileID: 0} @@ -208,6 +220,8 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -218,15 +232,25 @@ PlayerSettings: appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 - AndroidTargetDevice: 0 + iOSRequireARKit: 0 + appleEnableProMotion: 0 + clonedFromGUID: 00000000000000000000000000000000 + templatePackageId: + templateDefaultScene: + AndroidTargetArchitectures: 5 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 1 AndroidIsGame: 1 + AndroidEnableTango: 0 androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 m_AndroidBanners: - width: 320 height: 180 @@ -240,6 +264,8 @@ PlayerSettings: m_Icon: {fileID: 0} m_Width: 128 m_Height: 128 + m_Kind: 0 + m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: [] m_BuildTargetVRSettings: @@ -297,29 +323,23 @@ PlayerSettings: - m_BuildTarget: tvOS m_Enabled: 0 m_Devices: [] + m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 - webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} - wiiUTitleID: 0005000011000000 - wiiUGroupID: 00010000 - wiiUCommonSaveSize: 4096 - wiiUAccountSaveSize: 2048 - wiiUOlvAccessKey: 0 - wiiUTinCode: 0 - wiiUJoinGameId: 0 - wiiUJoinGameModeMask: 0000000000000000 - wiiUCommonBossSize: 0 - wiiUAccountBossSize: 0 - wiiUAddOnUniqueIDs: [] - wiiUMainThreadStackSize: 3072 - wiiULoaderThreadStackSize: 1024 - wiiUSystemHeapSize: 128 - wiiUTVStartupScreen: {fileID: 0} - wiiUGamePadStartupScreen: {fileID: 0} - wiiUDrcBufferDisabled: 0 - wiiUProfilerLibPath: + mobileMTRendering: + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: + - m_BuildTarget: Standalone + m_EncodingQuality: 1 + - m_BuildTarget: XboxOne + m_EncodingQuality: 1 + - m_BuildTarget: PS4 + m_EncodingQuality: 1 + m_BuildTargetGroupLightmapSettings: [] playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -347,6 +367,9 @@ PlayerSettings: switchTitleNames_9: switchTitleNames_10: switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -359,6 +382,9 @@ PlayerSettings: switchPublisherNames_9: switchPublisherNames_10: switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -371,6 +397,9 @@ PlayerSettings: switchIcons_9: {fileID: 0} switchIcons_10: {fileID: 0} switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -383,6 +412,9 @@ PlayerSettings: switchSmallIcons_9: {fileID: 0} switchSmallIcons_10: {fileID: 0} switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -424,8 +456,14 @@ PlayerSettings: switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -455,6 +493,8 @@ PlayerSettings: ps4PronunciationSIGPath: ps4BackgroundImagePath: ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: ps4SaveDataImagePath: ps4SdkOverride: ps4BGMPath: @@ -479,6 +519,8 @@ PlayerSettings: ps4pnFriends: 1 ps4pnGameCustomData: 1 playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 restrictedAudioUsageRights: 0 ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 @@ -502,54 +544,6 @@ PlayerSettings: ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] monoEnv: - psp2Splashimage: {fileID: 0} - psp2NPTrophyPackPath: - psp2NPSupportGBMorGJP: 0 - psp2NPAgeRating: 12 - psp2NPTitleDatPath: - psp2NPCommsID: - psp2NPCommunicationsID: - psp2NPCommsPassphrase: - psp2NPCommsSig: - psp2ParamSfxPath: - psp2ManualPath: - psp2LiveAreaGatePath: - psp2LiveAreaBackroundPath: - psp2LiveAreaPath: - psp2LiveAreaTrialPath: - psp2PatchChangeInfoPath: - psp2PatchOriginalPackage: - psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui - psp2KeystoneFile: - psp2MemoryExpansionMode: 0 - psp2DRMType: 0 - psp2StorageType: 0 - psp2MediaCapacity: 0 - psp2DLCConfigPath: - psp2ThumbnailPath: - psp2BackgroundPath: - psp2SoundPath: - psp2TrophyCommId: - psp2TrophyPackagePath: - psp2PackagedResourcesPath: - psp2SaveDataQuota: 10240 - psp2ParentalLevel: 1 - psp2ShortTitle: Not Set - psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF - psp2Category: 0 - psp2MasterVersion: 01.00 - psp2AppVersion: 01.00 - psp2TVBootMode: 0 - psp2EnterButtonAssignment: 2 - psp2TVDisableEmu: 0 - psp2AllowTwitterDialog: 1 - psp2Upgradable: 0 - psp2HealthWarning: 0 - psp2UseLibLocation: 0 - psp2InfoBarOnStartup: 0 - psp2InfoBarColor: 0 - psp2ScriptOptimizationLevel: 0 - psmSplashimage: {fileID: 0} splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} spritePackerPolicy: @@ -563,8 +557,9 @@ PlayerSettings: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 - webGLUseWasm: 0 webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 scriptingDefineSymbols: 1: 2: @@ -581,7 +576,10 @@ PlayerSettings: Standalone: 0 WebGL: 1 WebPlayer: 0 + il2cppCompilerConfiguration: {} + managedStrippingLevel: {} incrementalIl2cppBuild: {} + allowUnsafeCode: 0 additionalIl2CppArgs: scriptingRuntimeVersion: 0 apiCompatibilityLevelPerPlatform: {} @@ -597,11 +595,12 @@ PlayerSettings: metroApplicationDescription: RetroUnity wsaImages: {} metroTileShortName: - metroCommandLineArgsFile: metroTileShowName: 0 metroMediumTileShowName: 0 metroLargeTileShowName: 0 metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 metroDefaultTileSize: 1 metroTileForegroundText: 1 metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} @@ -609,35 +608,11 @@ PlayerSettings: a: 1} metroSplashScreenUseBackgroundColor: 1 platformCapabilities: {} + metroTargetDeviceFamilies: {} metroFTAName: metroFTAFileTypes: [] metroProtocolName: metroCompilationOverrides: 1 - tizenProductDescription: - tizenProductURL: - tizenSigningProfileName: - tizenGPSPermissions: 0 - tizenMicrophonePermissions: 0 - tizenDeploymentTarget: - tizenDeploymentTargetType: 0 - tizenMinOSVersion: 1 - n3dsUseExtSaveData: 0 - n3dsCompressStaticMem: 1 - n3dsExtSaveDataNumber: 0x12345 - n3dsStackSize: 131072 - n3dsTargetPlatform: 2 - n3dsRegion: 7 - n3dsMediaSize: 0 - n3dsLogoStyle: 3 - n3dsTitle: GameName - n3dsProductCode: - n3dsApplicationId: 0xFF3FF - stvDeviceAddress: - stvProductDescription: - stvProductAuthor: - stvProductAuthorEmail: - stvProductLink: - stvProductCategory: 0 XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -647,6 +622,7 @@ PlayerSettings: XboxOneGameOsOverridePath: XboxOnePackagingOverridePath: XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 XboxOneDescription: @@ -660,7 +636,9 @@ PlayerSettings: XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 xboxOneScriptCompiler: 0 + XboxOneOverrideIdentityName: vrEditorSettings: daydream: daydreamIconForeground: {fileID: 0} @@ -675,11 +653,30 @@ PlayerSettings: Purchasing: 0 UNet: 0 Unity_Ads: 0 + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_PrivateKeyPath: + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: facebookSdkVersion: 7.9.4 + facebookAppId: + facebookCookies: 1 + facebookLogging: 1 + facebookStatus: 1 + facebookXfbml: 0 + facebookFrictionlessRequests: 1 apiCompatibilityLevel: 2 cloudProjectId: + framebufferDepthMemorylessMode: 0 projectName: organizationId: cloudEnabled: 0 enableNativePlatformBackendsForNewInputSystem: 0 disableOldInputManagerSupport: 0 + legacyClampBlendShapeWeights: 1 diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 48a883e..5a48d90 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -17,6 +17,7 @@ QualitySettings: shadowNearPlaneOffset: 2 shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.19999999, z: 0.46666664} + shadowmaskMode: 0 blendWeights: 4 textureQuality: 0 anisotropicTextures: 2 @@ -25,12 +26,20 @@ QualitySettings: softVegetation: 1 realtimeReflectionProbes: 1 billboardsFaceCameraPosition: 1 - vSyncCount: 1 + vSyncCount: 0 lodBias: 2 maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 4096 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 4 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 excludedTargetPlatforms: [] m_PerPlatformDefaultQuality: Android: 0 diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset index a2dc235..558a017 100644 --- a/ProjectSettings/TimeManager.asset +++ b/ProjectSettings/TimeManager.asset @@ -6,3 +6,4 @@ TimeManager: Fixed Timestep: 0.02 Maximum Allowed Timestep: 0.33333334 m_TimeScale: 1 + Maximum Particle Timestep: 0.03 From 861725c19afceccac85591a24ee04cd71e87bd74 Mon Sep 17 00:00:00 2001 From: Humberto Dias Date: Fri, 11 Sep 2020 19:51:18 +0200 Subject: [PATCH 2/3] Decoupling Video processor + burst compiler --- .../RetroUnity/Scripts/GraphicsProcessor.cs | 177 ++++++++++++++++++ .../RetroUnity/Scripts/LibretroWrapper.cs | 157 +++------------- Packages/manifest.json | 1 + 3 files changed, 201 insertions(+), 134 deletions(-) create mode 100644 Assets/Plugins/RetroUnity/Scripts/GraphicsProcessor.cs diff --git a/Assets/Plugins/RetroUnity/Scripts/GraphicsProcessor.cs b/Assets/Plugins/RetroUnity/Scripts/GraphicsProcessor.cs new file mode 100644 index 0000000..e887560 --- /dev/null +++ b/Assets/Plugins/RetroUnity/Scripts/GraphicsProcessor.cs @@ -0,0 +1,177 @@ +using System; +using Unity.Burst; +using Unity.Collections; +using Unity.Collections.LowLevel.Unsafe; +using Unity.Jobs; +using UnityEngine; + +namespace RetroUnity +{ + public class GraphicsProcessor + { + public Action OnTextureRecreated; + + public Texture2D Texture { get; private set; } = new Texture2D(8, 8, TextureFormat.BGRA32, false) { filterMode = FilterMode.Point }; + public FilterMode VideoFilterMode + { + get => _filterMode; + set + { + _filterMode = value; + CreateTexture(Texture.width, Texture.height); + } + } + + private FilterMode _filterMode = FilterMode.Point; + + public unsafe void ProcessFrame0RGB1555(ushort* data, int width, int height, int pitch) + { + CreateTexture(width, height); + + new ProcessFrame0RGB1555Job + { + SourceData = data, + Width = width, + Height = height, + PitchPixels = pitch / sizeof(ushort), + TextureData = Texture.GetRawTextureData() + }.Schedule().Complete(); + + Texture.Apply(); + } + + public unsafe void ProcessFrameXRGB8888(uint* data, int width, int height, int pitch) + { + CreateTexture(width, height); + + new ProcessFrameXRGB8888Job + { + SourceData = data, + Width = width, + Height = height, + PitchPixels = pitch / sizeof(uint), + TextureData = Texture.GetRawTextureData() + }.Schedule().Complete(); + + Texture.Apply(); + } + + public unsafe void ProcessFrameRGB565(ushort* data, int width, int height, int pitch) + { + CreateTexture(width, height); + + new ProcessFrameRGB565Job + { + SourceData = data, + Width = width, + Height = height, + PitchPixels = pitch / sizeof(ushort), + TextureData = Texture.GetRawTextureData() + }.Schedule().Complete(); + + Texture.Apply(); + } + + private void CreateTexture(int width, int height) + { + if (Texture.width != width || Texture.height != height || Texture.filterMode != VideoFilterMode) + { + Texture = new Texture2D(width, height, TextureFormat.BGRA32, false) + { + filterMode = VideoFilterMode + }; + OnTextureRecreated?.Invoke(Texture); + } + } + + [BurstCompile] + private unsafe struct ProcessFrame0RGB1555Job : IJob + { + [ReadOnly] [NativeDisableUnsafePtrRestriction] public ushort* SourceData; + public int Width; + public int Height; + public int PitchPixels; + [WriteOnly] public NativeArray TextureData; + + public void Execute() + { + ushort* line = SourceData; + for (int y = 0; y < Height; ++y) + { + for (int x = 0; x < Width; ++x) + { + TextureData[y * Width + x] = ARGB1555toBGRA32(line[x]); + } + line += PitchPixels; + } + } + } + + [BurstCompile] + private unsafe struct ProcessFrameXRGB8888Job : IJob + { + [ReadOnly] [NativeDisableUnsafePtrRestriction] public uint* SourceData; + public int Width; + public int Height; + public int PitchPixels; + [WriteOnly] public NativeArray TextureData; + + public void Execute() + { + uint* line = SourceData; + for (int y = 0; y < Height; ++y) + { + for (int x = 0; x < Width; ++x) + { + TextureData[y * Width + x] = line[x]; + } + line += PitchPixels; + } + } + } + + [BurstCompile] + private unsafe struct ProcessFrameRGB565Job : IJob + { + [ReadOnly] [NativeDisableUnsafePtrRestriction] public ushort* SourceData; + public int Width; + public int Height; + public int PitchPixels; + [WriteOnly] public NativeArray TextureData; + + public void Execute() + { + ushort* line = SourceData; + for (int y = 0; y < Height; ++y) + { + for (int x = 0; x < Width; ++x) + { + TextureData[y * Width + x] = RGB565toBGRA32(line[x]); + } + line += PitchPixels; + } + } + } + + private static uint ARGB1555toBGRA32(ushort packed) + { + uint a = (uint)packed & 0x8000; + uint r = (uint)packed & 0x7C00; + uint g = (uint)packed & 0x03E0; + uint b = (uint)packed & 0x1F; + uint rgb = (r << 9) | (g << 6) | (b << 3); + return (a * 0x1FE00) | rgb | ((rgb >> 5) & 0x070707); + } + + private static uint RGB565toBGRA32(ushort packed) + { + uint r = ((uint)packed >> 11) & 0x1f; + uint g = ((uint)packed >> 5) & 0x3f; + uint b = ((uint)packed >> 0) & 0x1f; + r = (r << 3) | (r >> 2); + g = (g << 2) | (g >> 4); + b = (b << 3) | (b >> 2); + return (0xffu << 24) | (r << 16) | (g << 8) | (b << 0); + } + } +} \ No newline at end of file diff --git a/Assets/Plugins/RetroUnity/Scripts/LibretroWrapper.cs b/Assets/Plugins/RetroUnity/Scripts/LibretroWrapper.cs index 45d75bb..18dafde 100644 --- a/Assets/Plugins/RetroUnity/Scripts/LibretroWrapper.cs +++ b/Assets/Plugins/RetroUnity/Scripts/LibretroWrapper.cs @@ -30,13 +30,6 @@ public class LibretroWrapper : MonoBehaviour { private static Speaker _speaker; public static Texture2D tex; - public static int pix; - public static int w; - public static int h; - public static int p; - - public static byte[] Src; - public static byte[] Dst; public enum PixelFormat { // 0RGB1555, native endian. 0 bit must be set to 0. @@ -134,13 +127,6 @@ public class Wrapper { private PixelFormat _pixelFormat; private bool _requiresFullPath; private SystemAVInfo _av; - private Pixel[] _frameBuffer; - public static int Pix = 0; - public static int w = 0; - public static int h = 0; - public static int p = 0; - public static uint Button; - public static uint Keep; public IDLLHandler DLLHandler; @@ -202,130 +188,33 @@ public SystemAVInfo GetAVInfo() { return _av; } - public Pixel[] GetFramebuffer() { - return _frameBuffer; - } + private GraphicsProcessor graphicsProcessor = new GraphicsProcessor(); private unsafe void RetroVideoRefresh(void* data, uint width, uint height, uint pitch) { - - // Process Pixels one by one for now...this is not the best way to do it - // should be using memory streams or something - - //Declare the pixel buffer to pass on to the renderer - if(_frameBuffer == null || _frameBuffer.Length != width * height) - _frameBuffer = new Pixel[width * height]; - - //Get the array from unmanaged memory as a pointer - var pixels = (IntPtr)data; - //Gets The pointer to the row start to use with the pitch - //IntPtr rowStart = pixels; - - //Get the size to move the pointer - //int size = 0; - - uint i; - uint j; - - switch (_pixelFormat) { - case PixelFormat.RetroPixelFormat_0RGB1555: - - LibretroWrapper.w = Convert.ToInt32(width); - LibretroWrapper.h = Convert.ToInt32(height); - if (tex == null) { - tex = new Texture2D(LibretroWrapper.w, LibretroWrapper.h, TextureFormat.RGB565, false); - } - LibretroWrapper.p = Convert.ToInt32(pitch); - - //size = Marshal.SizeOf(typeof(short)); - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - short packed = Marshal.ReadInt16(pixels); - _frameBuffer[i * width + j] = new Pixel { - Alpha = 1 - , - Red = ((packed >> 10) & 0x001F) / 31.0f - , - Green = ((packed >> 5) & 0x001F) / 31.0f - , - Blue = (packed & 0x001F) / 31.0f - }; - var color = new Color(((packed >> 10) & 0x001F) / 31.0f, ((packed >> 5) & 0x001F) / 31.0f, (packed & 0x001F) / 31.0f, 1.0f); - tex.SetPixel((int)i, (int)j, color); - //pixels = (IntPtr)((int)pixels + size); - } - tex.filterMode = FilterMode.Trilinear; - tex.Apply(); - //pixels = (IntPtr)((int)rowStart + pitch); - //rowStart = pixels; - } - break; - case PixelFormat.RetroPixelFormatXRGB8888: - - LibretroWrapper.w = Convert.ToInt32(width); - LibretroWrapper.h = Convert.ToInt32(height); - if (tex == null) { - tex = new Texture2D(LibretroWrapper.w, LibretroWrapper.h, TextureFormat.RGB565, false); - } - LibretroWrapper.p = Convert.ToInt32(pitch); - - //size = Marshal.SizeOf(typeof(int)); - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - int packed = Marshal.ReadInt32(pixels); - _frameBuffer[i * width + j] = new Pixel { - Alpha = 1, - Red = ((packed >> 16) & 0x00FF) / 255.0f, - Green = ((packed >> 8) & 0x00FF) / 255.0f, - Blue = (packed & 0x00FF) / 255.0f - }; - var color = new Color(((packed >> 16) & 0x00FF) / 255.0f, ((packed >> 8) & 0x00FF) / 255.0f, (packed & 0x00FF) / 255.0f, 1.0f); - tex.SetPixel((int)i, (int)j, color); - //pixels = (IntPtr)((int)pixels + size); - } - //pixels = (IntPtr)((int)rowStart + pitch); - //rowStart = pixels; - - } - - tex.filterMode = FilterMode.Trilinear; - tex.Apply(); - break; - - case PixelFormat.RetroPixelFormatRGB565: - - var imagedata565 = new IntPtr(data); - LibretroWrapper.w = Convert.ToInt32(width); - LibretroWrapper.h = Convert.ToInt32(height); - if (tex == null) { - tex = new Texture2D(LibretroWrapper.w, LibretroWrapper.h, TextureFormat.RGB565, false); - } - LibretroWrapper.p = Convert.ToInt32(pitch); - int srcsize565 = 2 * (LibretroWrapper.p * LibretroWrapper.h); - int dstsize565 = 2 * (LibretroWrapper.w * LibretroWrapper.h); - if (Src == null || Src.Length != srcsize565) - Src = new byte[srcsize565]; - if (Dst == null || Dst.Length != dstsize565) - Dst = new byte[dstsize565]; - Marshal.Copy(imagedata565, Src, 0, srcsize565); - int m565 = 0; - for (int y = 0; y < LibretroWrapper.h; y++) { - for (int k = 0 * 2 + y * LibretroWrapper.p; k < LibretroWrapper.w * 2 + y * LibretroWrapper.p; k++) { - Dst[m565] = Src[k]; - m565++; - } - } - tex.LoadRawTextureData(Dst); - tex.filterMode = FilterMode.Trilinear; - tex.Apply(); - break; - case PixelFormat.RetroPixelFormatUnknown: - _frameBuffer = null; - break; - default: - throw new ArgumentOutOfRangeException(); + if (graphicsProcessor != null) + { + int intWidth = (int) width; + int intHeight = (int) height; + int intPitch = (int) pitch; + + tex = graphicsProcessor.Texture; + switch (_pixelFormat) + { + case PixelFormat.RetroPixelFormat_0RGB1555: + graphicsProcessor.ProcessFrame0RGB1555((ushort*) data, intWidth, intHeight, intPitch); + break; + case PixelFormat.RetroPixelFormatXRGB8888: + graphicsProcessor.ProcessFrameXRGB8888((uint*) data, intWidth, intHeight, intPitch); + break; + case PixelFormat.RetroPixelFormatRGB565: + graphicsProcessor.ProcessFrameRGB565((ushort*) data, intWidth, intHeight, intPitch); + break; + default: + throw new ArgumentOutOfRangeException(); + } } } - + private void RetroAudioSample(short left, short right) { // Unused. } diff --git a/Packages/manifest.json b/Packages/manifest.json index bf56235..d195c14 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,5 +1,6 @@ { "dependencies": { + "com.unity.burst": "1.3.6", "com.unity.collab-proxy": "1.2.16", "com.unity.ide.rider": "1.1.4", "com.unity.ide.vscode": "1.2.1", From 92f4665917b3acb276018639f829fc15aaa8cc3e Mon Sep 17 00:00:00 2001 From: Humberto Dias Date: Fri, 11 Sep 2020 20:20:49 +0200 Subject: [PATCH 3/3] mgba core --- Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs b/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs index b3a4fdf..8fa79db 100644 --- a/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs +++ b/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs @@ -31,7 +31,7 @@ static void DownloadCores() { var coreNames = new List() { - "snes9x","blastem", "nestopia" + "snes9x","blastem", "nestopia", "mgba" }; foreach (var coreName in coreNames) {