Skip to content

Commit cf3b4ae

Browse files
PaulDemeulenaereGitHub Enterprise
authored andcommitted
[Test] Add test to cover "Thread Group Size" error (#104)
* Add test * Add test to cover behavior from case 1271839
1 parent 1eecca7 commit cf3b4ae

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/VFXComponentTest.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,39 @@ void fnSet_UsingSerializedProperty(VFXValueType type, VisualEffect vfx, string n
11671167
VFXValueType.Matrix4x4
11681168
};
11691169

1170+
public struct VFXNullableTest
1171+
{
1172+
internal VFXValueType type;
1173+
public override string ToString()
1174+
{
1175+
return type.ToString();
1176+
}
1177+
}
1178+
1179+
private static bool IsTypeNullable(Type type)
1180+
{
1181+
if (!type.IsValueType)
1182+
return true;
1183+
if (Nullable.GetUnderlyingType(type) != null)
1184+
return true;
1185+
return false;
1186+
}
1187+
1188+
#pragma warning disable 0414
1189+
private static VFXNullableTest[] nullableTestCase = s_supportedValueType.Where(o => IsTypeNullable(VFXValue.TypeToType(o))).Select(o => new VFXNullableTest() { type = o }).ToArray();
1190+
#pragma warning restore 0414
1191+
1192+
[UnityTest]
1193+
public IEnumerator Check_SetNullable_Throw_An_Exception_While_Using_Null([ValueSource("nullableTestCase")] VFXNullableTest valueType)
1194+
{
1195+
1196+
while (m_mainObject.GetComponent<VisualEffect>() != null)
1197+
UnityEngine.Object.DestroyImmediate(m_mainObject.GetComponent<VisualEffect>());
1198+
var vfx = m_mainObject.AddComponent<VisualEffect>();
1199+
yield return null;
1200+
Assert.Throws<System.ArgumentNullException>(() => fnSet_UsingBindings(valueType.type, vfx, "null", null));
1201+
}
1202+
11701203
[UnityTest]
11711204
public IEnumerator CreateComponentWithAllBasicTypeExposed([ValueSource("trueOrFalse")] bool linkMode, [ValueSource("trueOrFalse")] bool bindingModes)
11721205
{

TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/VFXSpawnerTest.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ private void CreateAssetAndComponent(float spawnCountValue, string playEventName
4949
var spawnerInit = ScriptableObject.CreateInstance<VFXBasicInitialize>();
5050
var spawnerOutput = ScriptableObject.CreateInstance<VFXPlanarPrimitiveOutput>();
5151

52+
var blockAttributeDesc = VFXLibrary.GetBlocks().FirstOrDefault(o => o.modelType == typeof(Block.SetAttribute));
53+
var blockAttribute = blockAttributeDesc.CreateInstance();
54+
blockAttribute.SetSettingValue("attribute", "position");
55+
spawnerInit.AddChild(blockAttribute);
56+
5257
slotCount.value = spawnCountValue;
5358

5459
spawnerContext.AddChild(blockConstantRate);
@@ -406,6 +411,47 @@ public IEnumerator Create_Spawner_Check_Time_Mode_Update_Count([ValueSource("s_C
406411
yield return new ExitPlayMode();
407412
}
408413

414+
//Cover fix from 1268360 : Simple usage of exact fixed time step, it should not throw any error from the renderer
415+
[UnityTest]
416+
public IEnumerator Create_Spawner_Check_No_Incorrect_Thread_Count([ValueSource("s_CheckTimeMode")] VFXTimeModeTest timeMode)
417+
{
418+
yield return new EnterPlayMode();
419+
420+
var spawnCountValue = 651.0f;
421+
VisualEffect vfxComponent;
422+
GameObject cameraObj, gameObj;
423+
VFXGraph graph;
424+
CreateAssetAndComponent(spawnCountValue, "OnPlay", out graph, out vfxComponent, out gameObj, out cameraObj);
425+
graph.GetResource().updateMode = (VFXUpdateMode)timeMode.vfxUpdateMode;
426+
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(graph));
427+
428+
var previousCaptureFrameRate = Time.captureFramerate;
429+
var previousFixedTimeStep = UnityEngine.VFX.VFXManager.fixedTimeStep;
430+
var previousMaxDeltaTime = UnityEngine.VFX.VFXManager.maxDeltaTime;
431+
432+
UnityEngine.VFX.VFXManager.fixedTimeStep = 0.1f;
433+
UnityEngine.VFX.VFXManager.maxDeltaTime = 0.5f;
434+
Time.captureDeltaTime = 1.0f;
435+
436+
int maxFrame = 128;
437+
while (vfxComponent.culled && --maxFrame > 0)
438+
yield return null;
439+
440+
//Wait a few frame to verify if we are getting any warning from the rendering
441+
for (int i = 0; i < 5; ++i)
442+
yield return null;
443+
444+
UnityEngine.Object.DestroyImmediate(gameObj);
445+
UnityEngine.Object.DestroyImmediate(cameraObj);
446+
447+
Time.captureFramerate = previousCaptureFrameRate;
448+
UnityEngine.VFX.VFXManager.fixedTimeStep = previousFixedTimeStep;
449+
UnityEngine.VFX.VFXManager.maxDeltaTime = previousMaxDeltaTime;
450+
451+
yield return new ExitPlayMode();
452+
}
453+
454+
409455
//Fix case 1217876
410456
static VFXTimeModeTest[] s_Change_Fixed_Time_Step_To_A_Large_Value_Then_Back_To_Default = new[]
411457
{

0 commit comments

Comments
 (0)