浏览代码

support for tile binning in async compute (disabled)

/asmdef
runes 7 年前
当前提交
f9d6e4d8
共有 4 个文件被更改,包括 66 次插入10 次删除
  1. 1
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.Styles.cs
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  3. 34
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  4. 38
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs

1
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.Styles.cs


public readonly GUIContent enableComputeMaterialVariants = new GUIContent("Compute Material Variants");
public readonly GUIContent enableFptlForForwardOpaque = new GUIContent("Fptl for forward opaque");
public readonly GUIContent enableBigTilePrepass = new GUIContent("Big tile prepass");
public readonly GUIContent enableAsyncCompute = new GUIContent("Enable Async Compute");
}
static Styles s_Styles;

3
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs


SerializedProperty m_enableComputeMaterialVariants;
SerializedProperty m_enableFptlForForwardOpaque;
SerializedProperty m_enableBigTilePrepass;
SerializedProperty m_enableAsyncCompute;
// Rendering Settings
SerializedProperty m_RenderingUseForwardOnly;

m_enableComputeMaterialVariants = properties.Find(x => x.tileSettings.enableComputeMaterialVariants);
m_enableFptlForForwardOpaque = properties.Find(x => x.tileSettings.enableFptlForForwardOpaque);
m_enableBigTilePrepass = properties.Find(x => x.tileSettings.enableBigTilePrepass);
m_enableAsyncCompute = properties.Find(x => x.tileSettings.enableAsyncCompute);
// Shadow settings
m_ShadowAtlasWidth = properties.Find(x => x.shadowInitParams.shadowAtlasWidth);

EditorGUILayout.PropertyField(m_enableComputeMaterialVariants, s_Styles.enableComputeMaterialVariants);
EditorGUI.indentLevel--;
}
EditorGUILayout.PropertyField(m_enableAsyncCompute, s_Styles.enableAsyncCompute);
}
if (EditorGUI.EndChangeCheck())

34
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Compute Lighting", () => m_Asset.tileSettings.enableComputeLightEvaluation, (value) => m_Asset.tileSettings.enableComputeLightEvaluation = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Light Classification", () => m_Asset.tileSettings.enableComputeLightVariants, (value) => m_Asset.tileSettings.enableComputeLightVariants = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Material Classification", () => m_Asset.tileSettings.enableComputeMaterialVariants, (value) => m_Asset.tileSettings.enableComputeMaterialVariants = (bool)value, DebugItemFlag.RuntimeOnly);
DebugMenuManager.instance.AddDebugItem<bool>("HDRP", "Enable Async Compute", () => m_Asset.tileSettings.enableAsyncCompute, (value) => m_Asset.tileSettings.enableAsyncCompute = (bool)value, DebugItemFlag.RuntimeOnly);
}
void InitializeDebugMaterials()

RenderSSAO(cmd, camera, renderContext, postProcessLayer);
}
bool enableAsyncCompute = m_LightLoop.IsAsyncEnabled();
GPUFence buildGPULightListsCompleteFence = new GPUFence();
if (enableAsyncCompute)
{
GPUFence startFence = cmd.CreateGPUFence();
renderContext.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
cmd = CommandBufferPool.Get("");
buildGPULightListsCompleteFence = m_LightLoop.BuildGPULightListsAsyncBegin(camera, renderContext, m_CameraDepthStencilBufferRT, GetStencilTexture(), startFence);
}
{
{
m_LightLoop.RenderShadows(renderContext, cmd, m_CullResults);
// TODO: check if statement below still apply
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after RenderShadows as it modify our view/proj matrix

PushFullScreenDebugTexture(cmd, m_DeferredShadowBuffer, hdCamera.camera, renderContext, FullScreenDebugMode.DeferredShadows);
}
using (new ProfilingSample(cmd, "Build Light list", GetSampler(CustomSamplerId.BuildLightList)))
if (enableAsyncCompute)
{
m_LightLoop.BuildGPULightListAsyncEnd(camera, cmd, buildGPULightListsCompleteFence);
}
else
m_LightLoop.BuildGPULightLists(camera, cmd, m_CameraDepthStencilBufferRT, GetStencilTexture());
using (new ProfilingSample(cmd, "Build Light list", GetSampler(CustomSamplerId.BuildLightList)))
{
m_LightLoop.BuildGPULightLists(camera, cmd, m_CameraDepthStencilBufferRT, GetStencilTexture());
}
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, cmd);
// Caution: We require sun light here as some sky use the sun light to render, mean UpdateSkyEnvironment
// must be call after BuildGPULightLists.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
UpdateSkyEnvironment(hdCamera, cmd);
RenderDeferredLighting(hdCamera, cmd);

38
ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.cs


// clustered light list specific buffers and data begin
public bool enableBigTilePrepass;
public bool enableAsyncCompute;
public enum TileClusterDebug : int
{
None,

enableFptlForForwardOpaque = true;
enableBigTilePrepass = true;
enableAsyncCompute = false;
}
}

cmd.DispatchCompute(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, numTilesX, numTilesY, 1);
}
public void BuildGPULightLists(Camera camera, CommandBuffer cmd, RenderTargetIdentifier cameraDepthBufferRT, RenderTargetIdentifier stencilTextureRT)
public bool IsAsyncEnabled()
{
return m_LightLoopSettings.enableAsyncCompute;
}
public void BuildGPULightListsCommon(Camera camera, CommandBuffer cmd, RenderTargetIdentifier cameraDepthBufferRT, RenderTargetIdentifier stencilTextureRT)
{
cmd.BeginSample("Build Light List");

var projscr = temp * proj;
var invProjscr = projscr.inverse;
bool isOrthographic = camera.orthographic;
cmd.SetRenderTarget(BuiltinRenderTextureType.None);
// generate screen-space AABBs (used for both fptl and clustered).
if (m_lightCount != 0)

}
cmd.EndSample("Build Light List");
}
public void BuildGPULightLists(Camera camera, CommandBuffer cmd, RenderTargetIdentifier cameraDepthBufferRT, RenderTargetIdentifier stencilTextureRT)
{
cmd.SetRenderTarget(BuiltinRenderTextureType.None);
BuildGPULightListsCommon(camera, cmd, cameraDepthBufferRT, stencilTextureRT);
PushGlobalParams(camera, cmd);
}
public GPUFence BuildGPULightListsAsyncBegin(Camera camera, ScriptableRenderContext renderContext, RenderTargetIdentifier cameraDepthBufferRT, RenderTargetIdentifier stencilTextureRT, GPUFence startFence)
{
var cmd = CommandBufferPool.Get("Build light list");
cmd.WaitOnGPUFence(startFence);
BuildGPULightListsCommon(camera, cmd, cameraDepthBufferRT, stencilTextureRT);
GPUFence completeFence = cmd.CreateGPUFence();
renderContext.ExecuteCommandBufferAsync(cmd, ComputeQueueType.Background);
CommandBufferPool.Release(cmd);
return completeFence;
}
public void BuildGPULightListAsyncEnd(Camera camera, CommandBuffer cmd, GPUFence doneFence)
{
cmd.WaitOnGPUFence(doneFence);
PushGlobalParams(camera, cmd);
}

正在加载...
取消
保存