浏览代码

Merge remote-tracking branch 'origin/master' into HDRP-GraphicTests

/namespace
Remy 7 年前
当前提交
16235f08
共有 4 个文件被更改,包括 74 次插入62 次删除
  1. 2
      ScriptableRenderPipeline/Core/Volume/VolumeParameter.cs
  2. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  3. 55
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DepthDownsample.compute
  4. 74
      Tests/GraphicsTests/Framework/Editor/TestFramework.cs

2
ScriptableRenderPipeline/Core/Volume/VolumeParameter.cs


public static bool operator ==(VolumeParameter<T> lhs, T rhs)
{
return lhs.value.Equals(rhs);
return lhs.value != null && lhs.value.Equals(rhs);
}
public static bool operator !=(VolumeParameter<T> lhs, T rhs)

5
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine.Rendering;
using System;
using System.Diagnostics;

var mipSize = size;
for (int i = 0; i < lodCount; i++)
{
int srcMipSize = mipSize;
mipSize >>= 1;
cmd.ReleaseTemporaryRT(HDShaderIDs._DepthPyramidMips[i + 1]);

cmd.SetComputeVectorParam(m_DepthPyramidCS, "_Size", new Vector4(mipSize, mipSize, 1f / mipSize, 1f / mipSize));
cmd.SetComputeVectorParam(m_DepthPyramidCS, "_SrcSize", new Vector4(srcMipSize, srcMipSize, 1f / srcMipSize, 1f / srcMipSize));
cmd.DispatchCompute(m_DepthPyramidCS, m_DepthPyramidKernel, mipSize / 8, mipSize / 8, 1);
cmd.CopyTexture(HDShaderIDs._DepthPyramidMips[i + 1], 0, 0, m_DepthPyramidBufferRT, 0, i + 1);
}

55
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DepthDownsample.compute


#include "ShaderLibrary/Common.hlsl"
Texture2D<float> _Source;
RWTexture2D<float> _Result;
SamplerState sampler_LinearClamp;
CBUFFER_START(cb)
float4 _Size;
CBUFFER_END
#pragma kernel KMain
[numthreads(8, 8, 1)]
void KMain(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, uint2 dispatchThreadId : SV_DispatchThreadID)
{
// Upper-left pixel coordinate of quad that this thread will read
int2 threadUL = dispatchThreadId;
// Downsample the block
float2 offset = float2(threadUL);
float p00 = _Source.SampleLevel(sampler_LinearClamp, (offset ) * _Size.zw, 0.0).x;
float p10 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(1.0, 0.0)) * _Size.zw, 0.0).x;
float p01 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(0.0, 1.0)) * _Size.zw, 0.0).x;
float p11 = _Source.SampleLevel(sampler_LinearClamp, (offset + float2(1.0, 1.0)) * _Size.zw, 0.0).x;
float depth = min(min(min(p00, p01), p10), p11);
// Write to the final target
_Result[dispatchThreadId] = depth;
#include "ShaderLibrary/Common.hlsl"
Texture2D<float> _Source;
RWTexture2D<float> _Result;
SamplerState sampler_PointClamp; //TODO: could we use min-sampler instead of using ALU?
CBUFFER_START(cb)
float4 _SrcSize;
CBUFFER_END
#pragma kernel KMain
[numthreads(8, 8, 1)]
void KMain(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, uint2 dispatchThreadId : SV_DispatchThreadID)
{
// Upper-left pixel coordinate of quad that this thread will read
int2 threadUL = dispatchThreadId;
// Downsample the block
float2 offset = float2(threadUL) * 2.0f + 1.0f;
float4 depths = _Source.GatherRed(sampler_PointClamp, offset * _SrcSize.zw, 0.0);
float minDepth = min(min(depths.x, depths.y), min(depths.z, depths.w));
// Write to the final target
_Result[dispatchThreadId] = minDepth;
}

74
Tests/GraphicsTests/Framework/Editor/TestFramework.cs


"RenderPipeline"
};
private static readonly string[] s_PipelinePath =
{
"LightweightPipeline",
"HDRenderPipeline",
};
// info that gets generated for use
// in a dod way
public struct TestInfo

// collect the scenes that we can use
public static class CollectScenes
{
public static IEnumerable scenes
public static IEnumerable HDScenes
var absoluteScenesPath = s_Path.Aggregate(s_RootPath, Path.Combine);
return GetScenesForPipeline("HDRenderPipeline");
}
}
foreach (var pipelinePath in s_PipelinePath)
{
public static IEnumerable LWScenes
{
get
{
return GetScenesForPipeline("LightweightPipeline");
}
}
var filesPath = Path.Combine(absoluteScenesPath, pipelinePath);
public static IEnumerable GetScenesForPipeline(string _pipelinePath)
{
var absoluteScenesPath = s_Path.Aggregate(s_RootPath, Path.Combine);
// find all the scenes
var allPaths = System.IO.Directory.GetFiles(filesPath, "*.unity", System.IO.SearchOption.AllDirectories);
var filesPath = Path.Combine(absoluteScenesPath, _pipelinePath);
// construct all the needed test infos
foreach (var path in allPaths)
{
var p = new FileInfo(path);
var split = s_Path.Aggregate("", Path.Combine);
split = string.Format("{0}{1}", split, Path.DirectorySeparatorChar);
var splitPaths = p.FullName.Split(new[] { split }, StringSplitOptions.RemoveEmptyEntries);
// find all the scenes
var allPaths = System.IO.Directory.GetFiles(filesPath, "*.unity", System.IO.SearchOption.AllDirectories);
yield return new TestInfo
{
name = p.Name,
relativePath = splitPaths.Last(),
threshold = 0.02f,
frameWait = 100
};
}
}
// construct all the needed test infos
foreach (var path in allPaths)
{
var p = new FileInfo(path);
var split = s_Path.Aggregate("", Path.Combine);
split = string.Format("{0}{1}", split, Path.DirectorySeparatorChar);
var splitPaths = p.FullName.Split(new[] { split }, StringSplitOptions.RemoveEmptyEntries);
yield return new TestInfo
{
name = p.Name,
relativePath = splitPaths.Last(),
threshold = 0.02f,
frameWait = 100
};
}
}
}

}
[UnityTest]
public IEnumerator TestScene([ValueSource(typeof(CollectScenes), "scenes")]TestInfo testInfo)
public IEnumerator HDRP_TestScene([ValueSource(typeof(CollectScenes), "HDScenes")]TestInfo testInfo)
{
return TestScene(testInfo);
}
[UnityTest]
public IEnumerator LWRP_TestScene([ValueSource(typeof(CollectScenes), "LWScenes")]TestInfo testInfo)
{
return TestScene(testInfo);
}
public IEnumerator TestScene(TestInfo testInfo)
{
var prjRelativeGraphsPath = s_Path.Aggregate(s_RootPath, Path.Combine);
var filePath = Path.Combine(prjRelativeGraphsPath, testInfo.relativePath);

正在加载...
取消
保存