浏览代码

doing some lw-callback testing work

/lw-callbacktests
Tim Cooper 7 年前
当前提交
e2dc966c
共有 1 个文件被更改,包括 58 次插入5 次删除
  1. 63
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs

63
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


private CopyTextureSupport m_CopyTextureSupport;
public struct LightweightSettings
{
public FrameRenderingConfiguration configuration;
public RenderTargetIdentifier colorBuffer;
public RenderTargetIdentifier depthBuffer;
public int rtWidth;
public int rtHeight;
}
// Callbacks
public static event Action<CullResults, ScriptableRenderContext, LightweightSettings> afterOpaqueBeforeOpaquePost;
public static event Action<CullResults, ScriptableRenderContext, LightweightSettings> beforeTransparentAfterOpaquePost;
public static event Action<CullResults, ScriptableRenderContext, LightweightSettings> afterTransparentBeforeTransparentPost;
public static event Action<CullResults, ScriptableRenderContext, LightweightSettings> afterEverything;
public LightweightPipeline(LightweightPipelineAsset asset)
{
m_Asset = asset;

context.DrawRenderers(m_CullResults.visibleRenderers, ref opaqueDrawSettings, opaqueFilterSettings);
}
private void DoCallback(Action<CullResults, ScriptableRenderContext, LightweightSettings> callback, CullResults cullResults, ScriptableRenderContext context, LightweightSettings settings)
{
if (callback == null)
return;
callback(cullResults, context, settings);
CommandBuffer cmd = CommandBufferPool.Get("Restore State");
cmd.SetRenderTarget(settings.colorBuffer, settings.depthBuffer);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
private void ForwardPass(List<VisibleLight> visibleLights, FrameRenderingConfiguration frameRenderingConfiguration, ref ScriptableRenderContext context, ref LightData lightData, bool stereoEnabled)
{
SetupShaderConstants(visibleLights, ref context, ref lightData);

BeginForwardRendering(ref context, frameRenderingConfiguration);
var settings = BeginForwardRendering(ref context, frameRenderingConfiguration);
DoCallback(afterOpaqueBeforeOpaquePost, m_CullResults, context, settings);
DoCallback(beforeTransparentAfterOpaquePost, m_CullResults, context, settings);
DoCallback(afterTransparentBeforeTransparentPost, m_CullResults, context, settings);
DoCallback(afterEverything, m_CullResults, context, settings);
EndForwardRendering(ref context, frameRenderingConfiguration);
}

return resolution;
}
private void BeginForwardRendering(ref ScriptableRenderContext context, FrameRenderingConfiguration renderingConfig)
private LightweightSettings BeginForwardRendering(ref ScriptableRenderContext context, FrameRenderingConfiguration renderingConfig)
{
RenderTargetIdentifier colorRT = BuiltinRenderTextureType.CameraTarget;
RenderTargetIdentifier depthRT = BuiltinRenderTextureType.None;

CommandBuffer cmd = CommandBufferPool.Get("SetCameraRenderTarget");
bool intermeaditeTexture = LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.IntermediateTexture);
if (intermeaditeTexture)
bool intermediateTexture = LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.IntermediateTexture);
if (intermediateTexture)
{
if (!m_IsOffscreenCamera)
colorRT = m_CurrCameraColorRT;

// If rendering to an intermediate RT we resolve viewport on blit due to offset not being supported
// while rendering to a RT.
if (!intermeaditeTexture && !LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DefaultViewport))
if (!intermediateTexture && !LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DefaultViewport))
float renderScale = (m_CurrCamera.cameraType == CameraType.Game) ? m_Asset.RenderScale : 1.0f;
int rtWidth = (int)((float)m_CurrCamera.pixelWidth * renderScale);
int rtHeight = (int)((float)m_CurrCamera.pixelHeight * renderScale);
return new LightweightSettings()
{
colorBuffer = colorRT,
depthBuffer = depthRT,
configuration = renderingConfig,
rtWidth = rtWidth,
rtHeight = rtHeight
};
}
private void EndForwardRendering(ref ScriptableRenderContext context, FrameRenderingConfiguration renderingConfig)

正在加载...
取消
保存