浏览代码

Another round of clean

/main
sebastienlagarde 7 年前
当前提交
d2d35aec
共有 1 个文件被更改,包括 40 次插入110 次删除
  1. 150
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs

150
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


cmd.EndSample("Build Light List");
}
// This is a workaround for global properties not being accessible from compute.
// When activeComputeShader is set, all calls to SetGlobalXXX will set the property on the select compute shader instead of the global scope.
private ComputeShader activeComputeShader;
private int activeComputeKernel;
private CommandBuffer activeCommandBuffer;
private void SetGlobalPropertyRedirect(ComputeShader computeShader, int computeKernel, CommandBuffer commandBuffer)
{
activeComputeShader = computeShader;
activeComputeKernel = computeKernel;
activeCommandBuffer = commandBuffer;
}
private void SetGlobalTexture(int nameID, Texture value)
{
if (activeComputeShader)
activeCommandBuffer.SetComputeTextureParam(activeComputeShader, activeComputeKernel, nameID, value);
else
activeCommandBuffer.SetGlobalTexture(nameID, value);
}
private void SetGlobalBuffer(int nameID, ComputeBuffer buffer)
{
if (activeComputeShader)
activeCommandBuffer.SetComputeBufferParam(activeComputeShader, activeComputeKernel, nameID, buffer);
else
activeCommandBuffer.SetGlobalBuffer(nameID, buffer);
}
private void SetGlobalInt(int nameID, int value)
{
if (activeComputeShader)
activeCommandBuffer.SetComputeIntParam(activeComputeShader, nameID, value);
else
activeCommandBuffer.SetGlobalInt(nameID, value);
}
private void SetGlobalFloat(int nameID, float value)
{
if (activeComputeShader)
activeCommandBuffer.SetComputeFloatParam(activeComputeShader, nameID, value);
else
activeCommandBuffer.SetGlobalFloat(nameID, value);
}
private void SetGlobalVector(int nameID, Vector4 value)
{
if (activeComputeShader)
activeCommandBuffer.SetComputeVectorParam(activeComputeShader, nameID, value);
else
activeCommandBuffer.SetGlobalVector(nameID, value);
}
private void SetGlobalVectorArray(int nameID, Vector4[] values)
{
if (activeComputeShader)
{
activeCommandBuffer.SetComputeVectorArrayParam(activeComputeShader, nameID, values);
}
else
{
activeCommandBuffer.SetGlobalVectorArray(nameID, values);
}
}
private void UpdateDataBuffers()
{
s_DirectionalLightDatas.SetData(m_lightList.directionalLights);

private void BindGlobalParams(CommandBuffer cmd, Camera camera, bool forceClustered)
{
m_ShadowMgr.BindResources(cmd, activeComputeShader, activeComputeKernel);
SetGlobalBuffer(HDShaderIDs.g_vLightListGlobal, (forceClustered || !usingFptl) ? s_PerVoxelLightLists : s_LightList); // opaques list (unless MSAA possibly)
}
SetGlobalTexture(HDShaderIDs._CookieTextures, m_CookieTexArray.GetTexCache());
SetGlobalTexture(HDShaderIDs._CookieCubeTextures, m_CubeCookieTexArray.GetTexCache());
SetGlobalTexture(HDShaderIDs._EnvTextures, m_CubeReflTexArray.GetTexCache());
public void PushGlobalParams(Camera camera, CommandBuffer cmd, ComputeShader computeShader, int kernelIndex, bool forceClustered = false)
{
using (new ProfilingSample(cmd, "Push Global Parameters"))
{
// Shadows
m_ShadowMgr.SyncData();
m_ShadowMgr.BindResources(cmd, computeShader, kernelIndex);
SetGlobalBuffer(HDShaderIDs._DirectionalLightDatas, s_DirectionalLightDatas);
SetGlobalInt(HDShaderIDs._DirectionalLightCount, m_lightList.directionalLights.Count);
SetGlobalBuffer(HDShaderIDs._LightDatas, s_LightDatas);
SetGlobalInt(HDShaderIDs._PunctualLightCount, m_punctualLightCount);
SetGlobalInt(HDShaderIDs._AreaLightCount, m_areaLightCount);
SetGlobalBuffer(HDShaderIDs._EnvLightDatas, s_EnvLightDatas);
SetGlobalInt(HDShaderIDs._EnvLightCount, m_lightList.envLights.Count);
SetGlobalBuffer(HDShaderIDs._ShadowDatas, s_shadowDatas);
SetGlobalVectorArray(HDShaderIDs._DirShadowSplitSpheres, m_lightList.directionalShadowSplitSphereSqr);
cmd.SetGlobalBuffer(HDShaderIDs.g_vLightListGlobal, (forceClustered || !usingFptl) ? s_PerVoxelLightLists : s_LightList); // opaques list (unless MSAA possibly)
SetGlobalInt(HDShaderIDs._NumTileFtplX, GetNumTileFtplX(camera));
SetGlobalInt(HDShaderIDs._NumTileFtplY, GetNumTileFtplY(camera));
cmd.SetGlobalTexture(HDShaderIDs._CookieTextures, m_CookieTexArray.GetTexCache());
cmd.SetGlobalTexture(HDShaderIDs._CookieCubeTextures, m_CubeCookieTexArray.GetTexCache());
cmd.SetGlobalTexture(HDShaderIDs._EnvTextures, m_CubeReflTexArray.GetTexCache());
SetGlobalInt(HDShaderIDs._NumTileClusteredX, GetNumTileClusteredX(camera));
SetGlobalInt(HDShaderIDs._NumTileClusteredY, GetNumTileClusteredY(camera));
cmd.SetGlobalBuffer(HDShaderIDs._DirectionalLightDatas, s_DirectionalLightDatas);
cmd.SetGlobalInt(HDShaderIDs._DirectionalLightCount, m_lightList.directionalLights.Count);
cmd.SetGlobalBuffer(HDShaderIDs._LightDatas, s_LightDatas);
cmd.SetGlobalInt(HDShaderIDs._PunctualLightCount, m_punctualLightCount);
cmd.SetGlobalInt(HDShaderIDs._AreaLightCount, m_areaLightCount);
cmd.SetGlobalBuffer(HDShaderIDs._EnvLightDatas, s_EnvLightDatas);
cmd.SetGlobalInt(HDShaderIDs._EnvLightCount, m_lightList.envLights.Count);
cmd.SetGlobalBuffer(HDShaderIDs._ShadowDatas, s_shadowDatas);
cmd.SetGlobalVectorArray(HDShaderIDs._DirShadowSplitSpheres, m_lightList.directionalShadowSplitSphereSqr);
if (m_TileSettings.enableBigTilePrepass)
SetGlobalBuffer(HDShaderIDs.g_vBigTileLightList, s_BigTileLightList);
cmd.SetGlobalInt(HDShaderIDs._NumTileFtplX, GetNumTileFtplX(camera));
cmd.SetGlobalInt(HDShaderIDs._NumTileFtplY, GetNumTileFtplY(camera));
if (m_TileSettings.enableClustered)
{
SetGlobalFloat(HDShaderIDs.g_fClustScale, m_ClustScale);
SetGlobalFloat(HDShaderIDs.g_fClustBase, k_ClustLogBase);
SetGlobalFloat(HDShaderIDs.g_fNearPlane, camera.nearClipPlane);
SetGlobalFloat(HDShaderIDs.g_fFarPlane, camera.farClipPlane);
SetGlobalInt(HDShaderIDs.g_iLog2NumClusters, k_Log2NumClusters);
cmd.SetGlobalInt(HDShaderIDs._NumTileClusteredX, GetNumTileClusteredX(camera));
cmd.SetGlobalInt(HDShaderIDs._NumTileClusteredY, GetNumTileClusteredY(camera));
SetGlobalInt(HDShaderIDs.g_isLogBaseBufferEnabled, k_UseDepthBuffer ? 1 : 0);
if (m_TileSettings.enableBigTilePrepass)
cmd.SetGlobalBuffer(HDShaderIDs.g_vBigTileLightList, s_BigTileLightList);
SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, s_PerVoxelOffset);
if (k_UseDepthBuffer)
if (m_TileSettings.enableClustered)
SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, s_PerTileLogBaseTweak);
}
}
}
cmd.SetGlobalFloat(HDShaderIDs.g_fClustScale, m_ClustScale);
cmd.SetGlobalFloat(HDShaderIDs.g_fClustBase, k_ClustLogBase);
cmd.SetGlobalFloat(HDShaderIDs.g_fNearPlane, camera.nearClipPlane);
cmd.SetGlobalFloat(HDShaderIDs.g_fFarPlane, camera.farClipPlane);
cmd.SetGlobalInt(HDShaderIDs.g_iLog2NumClusters, k_Log2NumClusters);
public void PushGlobalParams(Camera camera, CommandBuffer cmd, ComputeShader computeShader, int kernelIndex, bool forceClustered = false)
{
using (new ProfilingSample(cmd, "Push Global Parameters"))
{
// Shadows
m_ShadowMgr.SyncData();
cmd.SetGlobalInt(HDShaderIDs.g_isLogBaseBufferEnabled, k_UseDepthBuffer ? 1 : 0);
SetGlobalPropertyRedirect(computeShader, kernelIndex, cmd);
BindGlobalParams(cmd, camera, forceClustered);
SetGlobalPropertyRedirect(null, 0, null);
cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, s_PerVoxelOffset);
if (k_UseDepthBuffer)
{
cmd.SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, s_PerTileLogBaseTweak);
}
}
}
}

CoreUtils.DrawFullScreen(cmd, m_DebugViewTilesMaterial, 0, colorBuffer);
}
SetGlobalPropertyRedirect(null, 0, null);
}
}

CoreUtils.DrawFullScreen(cmd, currentLightingMaterial, colorBuffers[0], depthStencilBuffer);
}
}
SetGlobalPropertyRedirect(null, 0, null);
} // End profiling
}

正在加载...
取消
保存