浏览代码

Reuse internal FrameSettings to avoid GC stress

/main
Thomas 7 年前
当前提交
c2f60a14
共有 2 个文件被更改,包括 37 次插入34 次删除
  1. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  2. 65
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/FrameSettings.cs

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


// First, get aggregate of frame settings base on global settings, camera frame settings and debug settings
var additionalCameraData = camera.GetComponent<HDAdditionalCameraData>();
// Note: the scene view camera will never have additionalCameraData
m_FrameSettings = FrameSettings.InitializeFrameSettings( camera, m_Asset.GetRenderPipelineSettings(),
(additionalCameraData && additionalCameraData.renderingPath != HDAdditionalCameraData.RenderingPath.Default) ? additionalCameraData.GetFrameSettings() : m_Asset.GetFrameSettings());
var srcFrameSettings = (additionalCameraData && additionalCameraData.renderingPath != HDAdditionalCameraData.RenderingPath.Default)
? additionalCameraData.GetFrameSettings()
: m_Asset.GetFrameSettings();
FrameSettings.InitializeFrameSettings(camera, m_Asset.GetRenderPipelineSettings(), srcFrameSettings, ref m_FrameSettings);
// This is the main command buffer used for the frame.
var cmd = CommandBufferPool.Get("");

65
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/FrameSettings.cs


// Init a FrameSettings from renderpipeline settings, frame settings and debug settings (if any)
// This will aggregate the various option
static public FrameSettings InitializeFrameSettings(Camera camera, RenderPipelineSettings renderPipelineSettings, FrameSettings frameSettings)
static public FrameSettings InitializeFrameSettings(Camera camera, RenderPipelineSettings renderPipelineSettings, FrameSettings srcFrameSettings, ref FrameSettings dstFrameSettings)
FrameSettings aggregate = new FrameSettings();
if (dstFrameSettings == null)
dstFrameSettings = new FrameSettings();
aggregate.diffuseGlobalDimmer = 1.0f;
aggregate.specularGlobalDimmer = 0.0f;
dstFrameSettings.diffuseGlobalDimmer = 1.0f;
dstFrameSettings.specularGlobalDimmer = 0.0f;
aggregate.diffuseGlobalDimmer = 1.0f;
aggregate.specularGlobalDimmer = 1.0f;
dstFrameSettings.diffuseGlobalDimmer = 1.0f;
dstFrameSettings.specularGlobalDimmer = 1.0f;
aggregate.enableShadow = frameSettings.enableShadow;
aggregate.enableSSR = camera.cameraType == CameraType.Reflection ? false : frameSettings.enableSSR && renderPipelineSettings.supportSSR;
aggregate.enableSSAO = frameSettings.enableSSAO && renderPipelineSettings.supportSSAO;
aggregate.enableSubsurfaceScattering = camera.cameraType == CameraType.Reflection ? false : frameSettings.enableSubsurfaceScattering && renderPipelineSettings.supportSubsurfaceScattering;
aggregate.enableTransmission = frameSettings.enableTransmission;
dstFrameSettings.enableShadow = srcFrameSettings.enableShadow;
dstFrameSettings.enableSSR = camera.cameraType == CameraType.Reflection ? false : srcFrameSettings.enableSSR && renderPipelineSettings.supportSSR;
dstFrameSettings.enableSSAO = srcFrameSettings.enableSSAO && renderPipelineSettings.supportSSAO;
dstFrameSettings.enableSubsurfaceScattering = camera.cameraType == CameraType.Reflection ? false : srcFrameSettings.enableSubsurfaceScattering && renderPipelineSettings.supportSubsurfaceScattering;
dstFrameSettings.enableTransmission = srcFrameSettings.enableTransmission;
aggregate.enableForwardRenderingOnly = frameSettings.enableForwardRenderingOnly || GL.wireframe;
aggregate.enableDepthPrepassWithDeferredRendering = frameSettings.enableDepthPrepassWithDeferredRendering;
aggregate.enableAlphaTestOnlyInDeferredPrepass = frameSettings.enableAlphaTestOnlyInDeferredPrepass;
dstFrameSettings.enableForwardRenderingOnly = srcFrameSettings.enableForwardRenderingOnly || GL.wireframe;
dstFrameSettings.enableDepthPrepassWithDeferredRendering = srcFrameSettings.enableDepthPrepassWithDeferredRendering;
dstFrameSettings.enableAlphaTestOnlyInDeferredPrepass = srcFrameSettings.enableAlphaTestOnlyInDeferredPrepass;
aggregate.enableTransparentPrepass = frameSettings.enableTransparentPrepass;
aggregate.enableMotionVectors = camera.cameraType == CameraType.Reflection ? false : frameSettings.enableMotionVectors;
aggregate.enableObjectMotionVectors = camera.cameraType == CameraType.Reflection ? false : frameSettings.enableObjectMotionVectors;
aggregate.enableDBuffer = frameSettings.enableDBuffer && renderPipelineSettings.supportDBuffer;
aggregate.enableAtmosphericScattering = frameSettings.enableAtmosphericScattering;
aggregate.enableRoughRefraction = frameSettings.enableRoughRefraction;
aggregate.enableTransparentPostpass = frameSettings.enableTransparentPostpass;
aggregate.enableDistortion = camera.cameraType == CameraType.Reflection ? false : frameSettings.enableDistortion;
dstFrameSettings.enableTransparentPrepass = srcFrameSettings.enableTransparentPrepass;
dstFrameSettings.enableMotionVectors = camera.cameraType == CameraType.Reflection ? false : srcFrameSettings.enableMotionVectors;
dstFrameSettings.enableObjectMotionVectors = camera.cameraType == CameraType.Reflection ? false : srcFrameSettings.enableObjectMotionVectors;
dstFrameSettings.enableDBuffer = srcFrameSettings.enableDBuffer && renderPipelineSettings.supportDBuffer;
dstFrameSettings.enableAtmosphericScattering = srcFrameSettings.enableAtmosphericScattering;
dstFrameSettings.enableRoughRefraction = srcFrameSettings.enableRoughRefraction;
dstFrameSettings.enableTransparentPostpass = srcFrameSettings.enableTransparentPostpass;
dstFrameSettings.enableDistortion = camera.cameraType == CameraType.Reflection ? false : srcFrameSettings.enableDistortion;
aggregate.enablePostprocess = camera.cameraType == CameraType.Reflection ? false : frameSettings.enablePostprocess;
dstFrameSettings.enablePostprocess = camera.cameraType == CameraType.Reflection ? false : srcFrameSettings.enablePostprocess;
aggregate.enableStereo = camera.cameraType == CameraType.Reflection ? false : frameSettings.enableStereo && UnityEngine.XR.XRSettings.isDeviceActive && (camera.stereoTargetEye == StereoTargetEyeMask.Both);
dstFrameSettings.enableStereo = camera.cameraType == CameraType.Reflection ? false : srcFrameSettings.enableStereo && UnityEngine.XR.XRSettings.isDeviceActive && (camera.stereoTargetEye == StereoTargetEyeMask.Both);
aggregate.enableForwardRenderingOnly = aggregate.enableForwardRenderingOnly || aggregate.enableStereo;
dstFrameSettings.enableForwardRenderingOnly = dstFrameSettings.enableForwardRenderingOnly || dstFrameSettings.enableStereo;
aggregate.enableAsyncCompute = frameSettings.enableAsyncCompute && renderPipelineSettings.supportAsyncCompute;
dstFrameSettings.enableAsyncCompute = srcFrameSettings.enableAsyncCompute && renderPipelineSettings.supportAsyncCompute;
aggregate.enableOpaqueObjects = frameSettings.enableOpaqueObjects;
aggregate.enableTransparentObjects = frameSettings.enableTransparentObjects;
dstFrameSettings.enableOpaqueObjects = srcFrameSettings.enableOpaqueObjects;
dstFrameSettings.enableTransparentObjects = srcFrameSettings.enableTransparentObjects;
aggregate.enableMSAA = frameSettings.enableMSAA && renderPipelineSettings.supportMSAA;
dstFrameSettings.enableMSAA = srcFrameSettings.enableMSAA && renderPipelineSettings.supportMSAA;
aggregate.enableShadowMask = frameSettings.enableShadowMask && renderPipelineSettings.supportShadowMask;
dstFrameSettings.enableShadowMask = srcFrameSettings.enableShadowMask && renderPipelineSettings.supportShadowMask;
aggregate.lightLoopSettings = LightLoopSettings.InitializeLightLoopSettings(camera, aggregate, renderPipelineSettings, frameSettings);
dstFrameSettings.lightLoopSettings = LightLoopSettings.InitializeLightLoopSettings(camera, dstFrameSettings, renderPipelineSettings, srcFrameSettings);
return aggregate;
return dstFrameSettings;
}
static public void RegisterDebug(String menuName, FrameSettings frameSettings)

正在加载...
取消
保存