浏览代码

Some fixes of RTHandleSystem

/main
Frédéric Vauchelles 7 年前
当前提交
3eb55fa2
共有 3 个文件被更改,包括 26 次插入17 次删除
  1. 7
      ScriptableRenderPipeline/Core/CoreRP/Textures/RTHandleSystem.cs
  2. 22
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
  3. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BufferPyramid.cs

7
ScriptableRenderPipeline/Core/CoreRP/Textures/RTHandleSystem.cs


newRT.m_EnableRandomWrite = enableRandomWrite;
newRT.m_EnableMSAA = enableMSAA;
newRT.m_Name = name;
newRT.referenceSize = new Vector2Int(width, height);
return newRT;
}

memoryless,
name
);
rth.referenceSize = new Vector2Int(width, height);
rth.scaleFactor = scaleFactor;
return rth;

memoryless,
name
);
rth.referenceSize = new Vector2Int(width, height);
rth.scaleFunc = scaleFunc;
return rth;

22
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs


HDAdditionalCameraData m_AdditionalCameraData;
BufferedRTHandleSystem m_HistoryRTSystem = null;
BufferedRTHandleSystem m_HistoryRTSystem = new BufferedRTHandleSystem();
public HDCamera(Camera cam)
{

// Unfortunately sometime (like in the HDCameraEditor) HDUtils.hdrpSettings can be null because of scripts that change the current pipeline...
m_msaaSamples = HDUtils.hdrpSettings != null ? HDUtils.hdrpSettings.msaaSampleCount : MSAASamples.None;
RTHandles.SetReferenceSize(m_ActualWidth, m_ActualHeight, frameSettings.enableMSAA, m_msaaSamples);
if (m_HistoryRTSystem != null)
{
m_HistoryRTSystem.SetReferenceSize(m_ActualWidth, m_ActualHeight, frameSettings.enableMSAA, m_msaaSamples);
m_HistoryRTSystem.Swap();
}
m_HistoryRTSystem.SetReferenceSize(m_ActualWidth, m_ActualHeight, frameSettings.enableMSAA, m_msaaSamples);
m_HistoryRTSystem.Swap();
int maxWidth = RTHandles.maxWidth;
int maxHeight = RTHandles.maxHeight;

public RTHandleSystem.RTHandle GetPreviousFrameRT(int id)
{
return m_HistoryRTSystem != null
? m_HistoryRTSystem.GetFrameRT(id, 1)
: null;
return m_HistoryRTSystem.GetFrameRT(id, 1);
return m_HistoryRTSystem != null
? m_HistoryRTSystem.GetFrameRT(id, 0)
: null;
return m_HistoryRTSystem.GetFrameRT(id, 0);
if (m_HistoryRTSystem == null)
m_HistoryRTSystem = new BufferedRTHandleSystem();
m_HistoryRTSystem.AllocBuffer(id, (rts, i) => allocator(camera.name, i, rts), 2);
return m_HistoryRTSystem.GetFrameRT(id, 0);
}

if (m_HistoryRTSystem != null)
m_HistoryRTSystem.ReleaseAll();
m_HistoryRTSystem.ReleaseAll();
}
}
}

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


public int GetPyramidLodCount(Vector2Int size)
{
var minSize = Mathf.Min(size.x, size.y);
return Mathf.FloorToInt(Mathf.Log(minSize, 2f));
return Mathf.Max(0, Mathf.FloorToInt(Mathf.Log(minSize, 2f)));
}
Vector2Int CalculatePyramidMipSize(Vector2Int baseMipSize, int mipIndex)

GetPyramidLodCount(targetDepthTexture.referenceSize),
GetPyramidLodCount(new Vector2Int(hdCamera.actualWidth, hdCamera.actualHeight))
);
if (lodCount == 0)
{
Debug.LogWarning("The target for the pyramid buffer has an invalid size. Skipping DepthPyramid calculation.");
return;
}
UpdatePyramidMips(hdCamera, targetDepthTexture.rt.format, m_DepthPyramidMips, lodCount);
Vector2 scale = GetPyramidToScreenScale(hdCamera, targetDepthTexture);

GetPyramidLodCount(targetColorTexture.referenceSize),
GetPyramidLodCount(new Vector2Int(hdCamera.actualWidth, hdCamera.actualHeight))
);
if (lodCount == 0)
{
Debug.LogWarning("The target for the pyramid buffer has an invalid size. Skipping ColorPyramid calculation.");
return;
}
UpdatePyramidMips(hdCamera, targetColorTexture.rt.format, m_ColorPyramidMips, lodCount);
Vector2 scale = GetPyramidToScreenScale(hdCamera, targetColorTexture);

正在加载...
取消
保存