浏览代码

Modifi test framework to test template image against multiple render pipelines per scene (HDRP parity)

/main
Remy 6 年前
当前提交
65aa2c2b
共有 15 个文件被更改,包括 356 次插入54 次删除
  1. 6
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_Test_Camera.prefab
  2. 4
      Tests/Scripts/Editor/GraphicTests/Framework/SetupSceneForRenderPipelineTestEditor.cs
  3. 97
      Tests/Scripts/Editor/GraphicTests/Framework/TestFramework.cs
  4. 15
      Tests/Scripts/GraphicTests/Framework/SetupSceneForRenderPipelineTest.cs
  5. 7
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def.asset
  6. 8
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets.meta
  7. 81
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass.asset
  8. 10
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass.asset.meta
  9. 81
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass_AlphaOnly.asset
  10. 10
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass_AlphaOnly.asset.meta
  11. 81
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Fwd.asset
  12. 10
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Fwd.asset.meta
  13. 0
      /Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def.asset.meta
  14. 0
      /Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def.asset

6
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_Test_Camera.prefab


m_Script: {fileID: 11500000, guid: a05220af15327674cb776279e892d996, type: 3}
m_Name:
m_EditorClassIdentifier:
renderPipeline: {fileID: 11400000, guid: d7fe5f39d2c099a4ea1f1f610af309d7, type: 2}
renderPipelines:
- {fileID: 11400000, guid: d7fe5f39d2c099a4ea1f1f610af309d7, type: 2}
- {fileID: 11400000, guid: e0b837a0b8013cb4380a2f1286170857, type: 2}
- {fileID: 11400000, guid: ae88914339ad0504eaca3f858706b8ad, type: 2}
- {fileID: 11400000, guid: d206727e1fcd98842b54b98db4dfce28, type: 2}
cameraToUse: {fileID: 20109210616973140}
hdr: 1
msaaSamples: 1

4
Tests/Scripts/Editor/GraphicTests/Framework/SetupSceneForRenderPipelineTestEditor.cs


using UnityEditor;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;

if (GUILayout.Button("Set renderpipe"))
{
GraphicsSettings.renderPipelineAsset = sceneSetup.renderPipeline;
GraphicsSettings.renderPipelineAsset = sceneSetup.renderPipelines[0];
}
}
}

97
Tests/Scripts/Editor/GraphicTests/Framework/TestFramework.cs


Assert.IsNotNull(testSetup, "No SetupSceneForRenderPipelineTest in scene " + testInfo.name);
Assert.IsNotNull(testSetup.cameraToUse, "No configured camera in <SetupSceneForRenderPipelineTest>");
testSetup.Setup();
if (testSetup.renderPipelines == null || testSetup.renderPipelines.Length == 0)
yield break;
for (int i = 0; i < testInfo.frameWait; ++i)
for (int r = 0; r < testSetup.renderPipelines.Length; ++r)
yield return null;
}
if (r==0)
testSetup.Setup();
else
testSetup.Setup(r);
for (int i = 0; i < testInfo.frameWait; ++i)
{
yield return null;
}
while (UnityEditor.Lightmapping.isRunning)
{
yield return null;
}
while (UnityEditor.Lightmapping.isRunning)
{
yield return null;
}
// Force rendering of all realtime reflection probes
ReflectionProbe[] probes = GameObject.FindObjectsOfType<ReflectionProbe>();
int[] renderIDs = new int[probes.Length];
for (int i=0; i<probes.Length; ++i)
{
if (probes[i].mode == UnityEngine.Rendering.ReflectionProbeMode.Realtime)
renderIDs[i] = probes[i].RenderProbe();
else
renderIDs[i] = -1;
}
for (int i=0; i<probes.Length; ++i)
{
if (renderIDs[i] != -1)
// Force rendering of all realtime reflection probes
ReflectionProbe[] probes = GameObject.FindObjectsOfType<ReflectionProbe>();
int[] renderIDs = new int[probes.Length];
for (int i = 0; i < probes.Length; ++i)
while (!probes[i].IsFinishedRendering(renderIDs[i])) yield return null;
if (probes[i].mode == UnityEngine.Rendering.ReflectionProbeMode.Realtime)
renderIDs[i] = probes[i].RenderProbe();
else
renderIDs[i] = -1;
}
for (int i = 0; i < probes.Length; ++i)
{
if (renderIDs[i] != -1)
{
while (!probes[i].IsFinishedRendering(renderIDs[i])) yield return null;
}
}
testSetup.thingToDoBeforeTest.Invoke();
testSetup.thingToDoBeforeTest.Invoke();
// Render the camera
Texture2D captured = TestFrameworkTools.RenderSetupToTexture(testSetup);
// Render the camera
Texture2D captured = TestFrameworkTools.RenderSetupToTexture(testSetup);
// Load the template
Texture2D fromDisk = new Texture2D(2, 2);
string dumpFileLocation = "";
if ( !TestFrameworkTools.FindReferenceImage( testInfo, ref fromDisk, captured, ref dumpFileLocation) )
Assert.Fail("Template file not found for {0}, creating it at {1}.", testInfo.name, dumpFileLocation);
// Load the template
Texture2D fromDisk = new Texture2D(2, 2);
string dumpFileLocation = "";
if (!TestFrameworkTools.FindReferenceImage(testInfo, ref fromDisk, captured, ref dumpFileLocation))
Assert.Fail("Template file not found for {0}, creating it at {1}.", testInfo.name, dumpFileLocation);
// Compare
var areEqual = TestFrameworkTools.CompareTextures(fromDisk, captured, testInfo.threshold);
// Compare
var areEqual = TestFrameworkTools.CompareTextures(fromDisk, captured, testInfo.threshold);
if (!areEqual)
{
var failedPath = Path.Combine(Directory.GetParent(Application.dataPath).ToString(), "SRP_Failed");
Directory.CreateDirectory(failedPath);
var misMatchLocationResult = Path.Combine(failedPath, string.Format("{0}.{1}", testInfo.name, "png"));
var misMatchLocationTemplate = Path.Combine(failedPath, string.Format("{0}.template.{1}", testInfo.name, "png"));
var generated = captured.EncodeToPNG();
File.WriteAllBytes(misMatchLocationResult, generated);
File.Copy(dumpFileLocation, misMatchLocationTemplate, true);
}
if (!areEqual)
{
var failedPath = Path.Combine(Directory.GetParent(Application.dataPath).ToString(), "SRP_Failed");
Directory.CreateDirectory(failedPath);
var misMatchLocationResult = Path.Combine(failedPath, string.Format("{0}.{1}", testInfo.name, "png"));
var misMatchLocationTemplate = Path.Combine(failedPath, string.Format("{0}.template.{1}", testInfo.name, "png"));
var generated = captured.EncodeToPNG();
File.WriteAllBytes(misMatchLocationResult, generated);
File.Copy(dumpFileLocation, misMatchLocationTemplate, true);
}
Assert.IsTrue(areEqual, "Scene from {0}, did not match .template file.", testInfo.relativePath);
Assert.IsTrue(areEqual, "Scene from {0}, did not match .template file.", testInfo.relativePath);
}
testSetup.TearDown();
}

15
Tests/Scripts/GraphicTests/Framework/SetupSceneForRenderPipelineTest.cs


public class SetupSceneForRenderPipelineTest : MonoBehaviour, IMonoBehaviourTest
{
private RenderPipelineAsset m_OriginalAsset;
public RenderPipelineAsset renderPipeline;
public Camera cameraToUse;
public RenderPipelineAsset[] renderPipelines;
public Camera cameraToUse;
public bool hdr = false;
public int msaaSamples = 1;

}
}
public void Setup()
public void Setup()
{
m_OriginalAsset = GraphicsSettings.renderPipelineAsset;
Setup(0);
}
public void Setup(int index)
m_OriginalAsset = GraphicsSettings.renderPipelineAsset;
if (m_OriginalAsset != renderPipeline) GraphicsSettings.renderPipelineAsset = renderPipeline;
if (m_OriginalAsset != renderPipelines[index]) GraphicsSettings.renderPipelineAsset = renderPipelines[index];
}
public void TearDown()

7
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def.asset


m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRP_GraphicTests_Asset
m_Name: HDRP_Test_Def
m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}

supportSSAO: 1
supportSubsurfaceScattering: 1
supportDBuffer: 1
supportMSAA: 0
msaaSampleCount: 1
lightLoopSettings:
spotCookieSize: 128
cookieTexArraySize: 16

shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
decalSettings:
drawDistance: 1000
atlasSize: 8192
diffusionProfileSettings: {fileID: 11400000, guid: 802c802428a2d9640a87e821dfcdd9e8,
type: 2}

8
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets.meta


fileFormatVersion: 2
guid: dee1533093552b845a042607c13594f2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

81
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRP_Test_Def_DepthPrepass
m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
m_FrameSettings:
enableShadow: 1
enableContactShadows: 1
enableSSR: 1
enableSSAO: 1
enableSubsurfaceScattering: 1
enableTransmission: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 0
enableDepthPrepassWithDeferredRendering: 1
enableAlphaTestOnlyInDeferredPrepass: 0
enableTransparentPrepass: 1
enableMotionVectors: 1
enableObjectMotionVectors: 1
enableDBuffer: 1
enableAtmosphericScattering: 1
enableRoughRefraction: 1
enableTransparentPostpass: 1
enableDistortion: 1
enablePostprocess: 1
enableStereo: 0
enableAsyncCompute: 0
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableShadowMask: 1
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
renderPipelineSettings:
supportShadowMask: 1
supportSSR: 1
supportSSAO: 1
supportSubsurfaceScattering: 1
supportDBuffer: 1
msaaSampleCount: 1
lightLoopSettings:
spotCookieSize: 128
cookieTexArraySize: 16
pointCookieSize: 512
cubeCookieTexArraySize: 16
reflectionProbeCacheSize: 128
planarReflectionProbeCacheSize: 128
reflectionCubemapSize: 128
planarReflectionTextureSize: 512
reflectionCacheCompressed: 0
planarReflectionCacheCompressed: 0
maxPlanarReflectionProbes: 128
skyReflectionSize: 256
skyLightingOverrideLayerMask:
serializedVersion: 2
m_Bits: 0
shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
decalSettings:
drawDistance: 1000
atlasSize: 8192
diffusionProfileSettings: {fileID: 11400000, guid: 802c802428a2d9640a87e821dfcdd9e8,
type: 2}

10
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass.asset.meta


fileFormatVersion: 2
guid: e0b837a0b8013cb4380a2f1286170857
timeCreated: 1509445177
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

81
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass_AlphaOnly.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRP_Test_Def_DepthPrepass_AlphaOnly
m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
m_FrameSettings:
enableShadow: 1
enableContactShadows: 1
enableSSR: 1
enableSSAO: 1
enableSubsurfaceScattering: 1
enableTransmission: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 0
enableDepthPrepassWithDeferredRendering: 1
enableAlphaTestOnlyInDeferredPrepass: 1
enableTransparentPrepass: 1
enableMotionVectors: 1
enableObjectMotionVectors: 1
enableDBuffer: 1
enableAtmosphericScattering: 1
enableRoughRefraction: 1
enableTransparentPostpass: 1
enableDistortion: 1
enablePostprocess: 1
enableStereo: 0
enableAsyncCompute: 0
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableShadowMask: 1
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
renderPipelineSettings:
supportShadowMask: 1
supportSSR: 1
supportSSAO: 1
supportSubsurfaceScattering: 1
supportDBuffer: 1
msaaSampleCount: 1
lightLoopSettings:
spotCookieSize: 128
cookieTexArraySize: 16
pointCookieSize: 512
cubeCookieTexArraySize: 16
reflectionProbeCacheSize: 128
planarReflectionProbeCacheSize: 128
reflectionCubemapSize: 128
planarReflectionTextureSize: 512
reflectionCacheCompressed: 0
planarReflectionCacheCompressed: 0
maxPlanarReflectionProbes: 128
skyReflectionSize: 256
skyLightingOverrideLayerMask:
serializedVersion: 2
m_Bits: 0
shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
decalSettings:
drawDistance: 1000
atlasSize: 8192
diffusionProfileSettings: {fileID: 11400000, guid: 802c802428a2d9640a87e821dfcdd9e8,
type: 2}

10
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def_DepthPrepass_AlphaOnly.asset.meta


fileFormatVersion: 2
guid: ae88914339ad0504eaca3f858706b8ad
timeCreated: 1509445177
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

81
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Fwd.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3}
m_Name: HDRP_Test_Fwd
m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
m_FrameSettings:
enableShadow: 1
enableContactShadows: 1
enableSSR: 1
enableSSAO: 1
enableSubsurfaceScattering: 1
enableTransmission: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 1
enableDepthPrepassWithDeferredRendering: 0
enableAlphaTestOnlyInDeferredPrepass: 0
enableTransparentPrepass: 1
enableMotionVectors: 1
enableObjectMotionVectors: 1
enableDBuffer: 1
enableAtmosphericScattering: 1
enableRoughRefraction: 1
enableTransparentPostpass: 1
enableDistortion: 1
enablePostprocess: 1
enableStereo: 0
enableAsyncCompute: 0
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableShadowMask: 1
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
renderPipelineSettings:
supportShadowMask: 1
supportSSR: 1
supportSSAO: 1
supportSubsurfaceScattering: 1
supportDBuffer: 1
msaaSampleCount: 1
lightLoopSettings:
spotCookieSize: 128
cookieTexArraySize: 16
pointCookieSize: 512
cubeCookieTexArraySize: 16
reflectionProbeCacheSize: 128
planarReflectionProbeCacheSize: 128
reflectionCubemapSize: 128
planarReflectionTextureSize: 512
reflectionCacheCompressed: 0
planarReflectionCacheCompressed: 0
maxPlanarReflectionProbes: 128
skyReflectionSize: 256
skyLightingOverrideLayerMask:
serializedVersion: 2
m_Bits: 0
shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
decalSettings:
drawDistance: 1000
atlasSize: 8192
diffusionProfileSettings: {fileID: 11400000, guid: 802c802428a2d9640a87e821dfcdd9e8,
type: 2}

10
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Fwd.asset.meta


fileFormatVersion: 2
guid: d206727e1fcd98842b54b98db4dfce28
timeCreated: 1509445177
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

/Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_GraphicTests_Asset.asset.meta → /Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def.asset.meta

/Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_GraphicTests_Asset.asset → /Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/RP_Assets/HDRP_Test_Def.asset

正在加载...
取消
保存