浏览代码

Removed useless kernels

/main
Frédéric Vauchelles 7 年前
当前提交
05aa3232
共有 2 个文件被更改,包括 6 次插入31 次删除
  1. 15
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BufferPyramid.cs
  2. 22
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DepthPyramid.compute

15
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BufferPyramid.cs


List<RTHandle> m_DepthPyramidMips = new List<RTHandle>();
int[] m_DepthKernels = null;
int depthKernel8 { get { return m_DepthKernels[0]; } }
int depthKernel1 { get { return m_DepthKernels[1]; } }
public RTHandle colorPyramid { get { return m_ColorPyramidBuffer; } }
public RTHandle depthPyramid { get { return m_DepthPyramidBuffer; } }

m_DepthKernels = new int[]
{
m_DepthPyramidCS.FindKernel("KDepthDownSample8"),
m_DepthPyramidCS.FindKernel("KDepthDownSample2_0"),
m_DepthPyramidCS.FindKernel("KDepthDownSample2_1"),
m_DepthPyramidCS.FindKernel("KDepthDownSample2_2"),
m_DepthPyramidCS.FindKernel("KDepthDownSample2_3"),
m_DepthPyramidCS.FindKernel("KDepthDownSample1")
int GetDepthKernel2(int pattern)
{
return m_DepthKernels[pattern + 1];
}
float GetXRscale()
{
// for stereo double-wide, each half of the texture will represent a single eye's pyramid

public void CreateBuffers()
{
m_ColorPyramidBuffer = RTHandle.Alloc(size => CalculatePyramidSize(size), filterMode: FilterMode.Trilinear, colorFormat: RenderTextureFormat.ARGBHalf, sRGB: false, useMipMap: true, autoGenerateMips: false, name: "ColorPymarid");
m_DepthPyramidBuffer = RTHandle.Alloc(size => CalculatePyramidSize(size), filterMode: FilterMode.Trilinear, colorFormat: RenderTextureFormat.RFloat, sRGB: false, useMipMap: true, autoGenerateMips: false, enableRandomWrite: true, name: "DepthPyramid"); // Need randomReadWrite because we downsample the first mip with a compute shader.
m_DepthPyramidBuffer = RTHandle.Alloc(size => CalculatePyramidSize(size), filterMode: FilterMode.Trilinear, colorFormat: RenderTextureFormat.RGFloat, sRGB: false, useMipMap: true, autoGenerateMips: false, enableRandomWrite: true, name: "DepthPyramid"); // Need randomReadWrite because we downsample the first mip with a compute shader.
}
public void DestroyBuffers()

var srcMip = new RectInt(0, 0, hdCamera.actualWidth >> i, hdCamera.actualHeight >> i);
var dstMip = new RectInt(0, 0, srcMip.width >> 1, srcMip.height >> 1);
var kernel = GetDepthKernel2(0);
var kernel = depthKernel1;
var kernelSize = 1;
var srcWorkMip = srcMip;
var dstWorkMip = dstMip;

22
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DepthPyramid.compute


// Algorithm
// ------------------------------------------------
// Downsample a depth texture by taking min value of sampled pixels
// It also handles computing in a viewport of a texture.
// When we use partial kernels there are only 4 patterns (first is full):
// 0. |x|x| 1. |x|o| 2. |o|o| 3. |o|o|
// |x|x| |x|o| |x|x| |x|o|
#pragma kernel KDepthDownSample8 KERNEL_SIZE=8 PATTERN=0 KERNEL_NAME=KDepthDownSample8
#pragma kernel KDepthDownSample2_0 KERNEL_SIZE=1 PATTERN=0 KERNEL_NAME=KDepthDownSample2_0
#pragma kernel KDepthDownSample2_1 KERNEL_SIZE=1 PATTERN=1 KERNEL_NAME=KDepthDownSample2_1
#pragma kernel KDepthDownSample2_2 KERNEL_SIZE=1 PATTERN=2 KERNEL_NAME=KDepthDownSample2_2
#pragma kernel KDepthDownSample2_3 KERNEL_SIZE=1 PATTERN=3 KERNEL_NAME=KDepthDownSample2_3
#pragma kernel KDepthDownSample8 KERNEL_SIZE=8 KERNEL_NAME=KDepthDownSample8
#pragma kernel KDepthDownSample1 KERNEL_SIZE=1 KERNEL_NAME=KDepthDownSample1
#pragma only_renderers d3d11 ps4 xboxone vulkan metal

#endif
// Select the nearest sample
#if PATTERN == 0
#elif PATTERN == 1
float minDepth = MIN_DEPTH(depths.x, depths.z);
float maxDepth = MAX_DEPTH(depths.x, depths.z);
#elif PATTERN == 2
float minDepth = MIN_DEPTH(depths.x, depths.y);
float maxDepth = MAX_DEPTH(depths.x, depths.y);
#elif PATTERN == 3
float minDepth = depths.x;
float maxDepth = depths.x;
#endif
// Write to the final target
uint2 dstPixel = (_RectOffset >> 1) + dispatchThreadId;

正在加载...
取消
保存