Skip to content

Commit 3001584

Browse files
committed
FrameGui outside boundary fix. unsorted frame fix
1 parent 9bda703 commit 3001584

File tree

8 files changed

+90
-34
lines changed

8 files changed

+90
-34
lines changed

Assets/Scenes/FIFO.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ MonoBehaviour:
10541054
m_EditorClassIdentifier:
10551055
currentRefLength: 3
10561056
maxRefStrLength: 9
1057-
minRefStrLength: 3
1057+
minRefStrLength: 9
10581058
refStrCountText: {fileID: 1350027221}
10591059
warning: {fileID: 299530289}
10601060
applyButton: {fileID: 2029409281}
@@ -1763,7 +1763,7 @@ GameObject:
17631763
m_Icon: {fileID: 0}
17641764
m_NavMeshLayer: 0
17651765
m_StaticEditorFlags: 0
1766-
m_IsActive: 0
1766+
m_IsActive: 1
17671767
--- !u!224 &883078025
17681768
RectTransform:
17691769
m_ObjectHideFlags: 0

Assets/Scripts/Algorithms/FifoAlgorithm.cs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using TMPro;
55
using UnityEngine;
66
using UnityEngine.UI;
7-
using UnityEngine.UIElements;
87

98
public class FifoAlgorithm : MonoBehaviour
109
{
@@ -38,8 +37,10 @@ public void SimulateFIFO()
3837
int[] refString = DataManager.instance.GetRefStringArray();
3938
int frameCount = DataManager.instance.GetFrameCount();
4039

41-
Queue<int> fifoQueue = new Queue<int>();
42-
HashSet<int> frameSet = new HashSet<int>(); // for fast lookup
40+
List<int> frameList = new List<int>(frameCount);
41+
HashSet<int> frameSet = new HashSet<int>();
42+
int pointer = 0;
43+
4344

4445
// Get the frameGui in sorted way by hierachy(Use this code if frames got inverted)
4546
frameGui = FindObjectsOfType<FrameGui>()
@@ -64,58 +65,64 @@ public void SimulateFIFO()
6465
{
6566
int currentPage = refString[i];
6667

67-
// Create a column (a container for this step's frame state)
68+
// Create column UI
6869
GameObject column = new GameObject("Step " + i);
6970
column.transform.SetParent(frameGui[i].frameSlotParent.transform);
70-
7171
GuiSettings(column);
7272

73-
74-
75-
// Check if currentPage is in memory
7673
bool isPageFault = !frameSet.Contains(currentPage);
7774

7875
if (isPageFault)
7976
{
8077
pageFaults++;
8178

82-
// If full, remove the oldest page
83-
if (fifoQueue.Count >= frameCount)
79+
if (frameList.Count < frameCount)
8480
{
85-
int removed = fifoQueue.Dequeue();
86-
frameSet.Remove(removed);
81+
// Just add new
82+
frameList.Add(currentPage);
83+
frameSet.Add(currentPage);
8784
}
85+
else
86+
{
87+
// Replace oldest using pointer logic
88+
int removedPage = frameList[pointer];
89+
frameSet.Remove(removedPage);
8890

89-
// Add the current page
90-
fifoQueue.Enqueue(currentPage);
91-
frameSet.Add(currentPage);
92-
}
91+
frameList[pointer] = currentPage;
92+
frameSet.Add(currentPage);
9393

94-
// Convert queue to list so we can index it
95-
List<int> currentFrameList = new List<int>(fifoQueue);
94+
pointer = (pointer + 1) % frameCount; // move circularly
95+
}
96+
}
9697

97-
// Fill frame slots
98+
// Render current frame state from top (oldest) to bottom (newest)
9899
for (int j = 0; j < frameCount; j++)
99100
{
100101
GameObject slot = Instantiate(frameSlot, column.transform);
101102
TMP_Text txt = slot.GetComponentInChildren<TMP_Text>();
102103

103-
if (j < currentFrameList.Count)
104+
if (j < frameList.Count)
104105
{
105-
txt.text = currentFrameList[j].ToString();
106+
txt.text = frameList[j].ToString();
107+
108+
// Highlight if newly replaced
109+
if (isPageFault && frameList[j] == currentPage)
110+
{
111+
slot.GetComponent<Image>().color = Color.red;
112+
}
106113
}
107114
else
108115
{
109116
txt.text = "";
110117
}
111118
}
112119

113-
// Add page fault text after adding the frame GUI
114120
if (isPageFault)
115121
{
116122
Instantiate(faultTextPrefab, column.transform);
117123
}
118124
}
125+
119126
totalFaultText.text = "Total Page Faults: " + pageFaults;
120127
DataManager.instance.SetPageFault(pageFaults);
121128
}

Assets/Scripts/Controller/FifoFrameGuiController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class FifoFrameGuiController : MonoBehaviour
1313
// Start is called before the first frame update
1414
void Start()
1515
{
16-
GenerateFrameContainers();
16+
/* GenerateFrameContainers();*/
1717
// frameContainerArray = new GameObject[DataManager.instance.GetRefStringLength()];
1818

1919
}

Assets/Scripts/GUI/FrameGui.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ private void Awake()
2727
// Start is called before the first frame update
2828
void Start()
2929
{
30-
// Set the Frame Slots when they got instantiated
31-
GenerateFrameSlots();
30+
// Set the Frame Slots when they got instantiated
31+
/* GenerateFrameSlots();*/
3232

33+
RenameFrameNumber();
3334

3435
}
3536

@@ -39,15 +40,11 @@ void Update()
3940

4041
}
4142

42-
public void GenerateFrameSlots()
43+
44+
public void RenameFrameNumber()
4345
{
4446
int[] refString = DataManager.instance.GetRefStringArray();
4547

46-
for (int i = 0; i < DataManager.instance.GetFrameCount(); i++)
47-
{
48-
Instantiate(frameSlot, frameSlotParent.gameObject.transform);
49-
}
50-
5148
for (int i = 0; i < refString.Length; i++)
5249
{
5350
GameObject frameObj = fifoFrameGuiController.frameContainerArray[i];

Assets/Settings/Renderer2D.asset

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ MonoBehaviour:
1414
m_EditorClassIdentifier:
1515
debugShaders:
1616
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, type: 3}
17+
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
1718
m_RendererFeatures: []
1819
m_RendererFeatureMap:
1920
m_UseNativeRenderPass: 0
@@ -45,6 +46,8 @@ MonoBehaviour:
4546
m_PointLightShader: {fileID: 4800000, guid: e35a31e1679aeff489e202f5cc4853d5, type: 3}
4647
m_PointLightVolumeShader: {fileID: 4800000, guid: c7d04ca57e5449d49ad9cee1c604bc26, type: 3}
4748
m_CoreBlitShader: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
49+
m_BlitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
50+
m_CoreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, type: 3}
4851
m_SamplingShader: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
4952
m_ProjectedShadowShader: {fileID: 4800000, guid: ce09d4a80b88c5a4eb9768fab4f1ee00, type: 3}
5053
m_SpriteShadowShader: {fileID: 4800000, guid: 44fc62292b65ab04eabcf310e799ccf6, type: 3}

Assets/Settings/UniversalRP.asset

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ MonoBehaviour:
3232
m_FsrSharpness: 0.92
3333
m_EnableLODCrossFade: 1
3434
m_LODCrossFadeDitheringType: 1
35+
m_ShEvalMode: 0
3536
m_MainLightRenderingMode: 1
3637
m_MainLightShadowsSupported: 1
3738
m_MainLightShadowmapResolution: 2048
@@ -52,9 +53,11 @@ MonoBehaviour:
5253
m_CascadeBorder: 0.1
5354
m_ShadowDepthBias: 1
5455
m_ShadowNormalBias: 1
56+
m_AnyShadowsSupported: 1
5557
m_SoftShadowsSupported: 0
5658
m_ConservativeEnclosingSphere: 0
5759
m_NumIterationsEnclosingSphere: 64
60+
m_SoftShadowQuality: 2
5861
m_AdditionalLightsCookieResolution: 2048
5962
m_AdditionalLightsCookieFormat: 3
6063
m_UseSRPBatcher: 1
@@ -69,6 +72,7 @@ MonoBehaviour:
6972
m_ColorGradingMode: 0
7073
m_ColorGradingLutSize: 32
7174
m_UseFastSRGBLinearConversion: 0
75+
m_SupportDataDrivenLensFlare: 1
7276
m_ShadowType: 1
7377
m_LocalShadowsSupported: 0
7478
m_LocalShadowsAtlasResolution: 256
@@ -78,5 +82,33 @@ MonoBehaviour:
7882
m_Textures:
7983
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
8084
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
85+
m_PrefilteringModeMainLightShadows: 4
86+
m_PrefilteringModeAdditionalLight: 4
87+
m_PrefilteringModeAdditionalLightShadows: 0
88+
m_PrefilterXRKeywords: 1
89+
m_PrefilteringModeForwardPlus: 0
90+
m_PrefilteringModeDeferredRendering: 0
91+
m_PrefilteringModeScreenSpaceOcclusion: 0
92+
m_PrefilterDebugKeywords: 1
93+
m_PrefilterWriteRenderingLayers: 1
94+
m_PrefilterHDROutput: 1
95+
m_PrefilterSSAODepthNormals: 1
96+
m_PrefilterSSAOSourceDepthLow: 1
97+
m_PrefilterSSAOSourceDepthMedium: 1
98+
m_PrefilterSSAOSourceDepthHigh: 1
99+
m_PrefilterSSAOInterleaved: 1
100+
m_PrefilterSSAOBlueNoise: 1
101+
m_PrefilterSSAOSampleCountLow: 1
102+
m_PrefilterSSAOSampleCountMedium: 1
103+
m_PrefilterSSAOSampleCountHigh: 1
104+
m_PrefilterDBufferMRT1: 1
105+
m_PrefilterDBufferMRT2: 1
106+
m_PrefilterDBufferMRT3: 1
107+
m_PrefilterSoftShadowsQualityLow: 1
108+
m_PrefilterSoftShadowsQualityMedium: 1
109+
m_PrefilterSoftShadowsQualityHigh: 1
110+
m_PrefilterSoftShadows: 0
111+
m_PrefilterScreenCoord: 1
112+
m_PrefilterNativeRenderPass: 1
81113
m_ShaderVariantLogLevel: 0
82114
m_ShadowCascades: 0

ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ PlayerSettings:
553553
webGLTemplate: APPLICATION:Default
554554
webGLAnalyzeBuildSize: 0
555555
webGLUseEmbeddedResources: 0
556-
webGLCompressionFormat: 0
556+
webGLCompressionFormat: 2
557557
webGLWasmArithmeticExceptions: 0
558558
webGLLinkerTarget: 1
559559
webGLThreadsSupport: 0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &1
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 53
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3}
13+
m_Name:
14+
m_EditorClassIdentifier:
15+
shaderVariantLimit: 2048
16+
customInterpolatorErrorThreshold: 32
17+
customInterpolatorWarningThreshold: 16

0 commit comments

Comments
 (0)