浏览代码

Cleanup comments

And actually rename s_TempIntArray!
/main
Robert Srinivasiah 7 年前
当前提交
bbed8914
共有 2 个文件被更改,包括 8 次插入56 次删除
  1. 16
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  2. 48
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-bigtile.compute

16
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs


};
// clustered light list specific buffers and data end
static int[] s_TempIntArray = new int[2]; // Used to avoid GC stress when calling SetComputeIntParams
static int[] s_TempScreenDimArray = new int[2]; // Used to avoid GC stress when calling SetComputeIntParams
FrameSettings m_FrameSettings = null;
RenderPipelineResources m_Resources = null;

var w = (int)hdCamera.screenSize.x;
var h = (int)hdCamera.screenSize.y;
s_TempIntArray[0] = w;
s_TempIntArray[1] = h;
s_TempScreenDimArray[0] = w;
s_TempScreenDimArray[1] = h;
var numBigTilesX = (w + 63) / 64;
var numBigTilesY = (h + 63) / 64;

{
cmd.SetComputeIntParam(buildPerBigTileLightListShader, HDShaderIDs.g_iNrVisibLights, m_lightCount);
cmd.SetComputeIntParam(buildPerBigTileLightListShader, HDShaderIDs.g_isOrthographic, isOrthographic ? 1 : 0);
cmd.SetComputeIntParams(buildPerBigTileLightListShader, HDShaderIDs.g_viDimensions, s_TempIntArray);
cmd.SetComputeIntParams(buildPerBigTileLightListShader, HDShaderIDs.g_viDimensions, s_TempScreenDimArray);
// TODO: These two aren't actually used...
//cmd.SetComputeMatrixParam(buildPerBigTileLightListShader, HDShaderIDs.g_mScrProjection, projscrArr[0]);
//cmd.SetComputeMatrixParam(buildPerBigTileLightListShader, HDShaderIDs.g_mInvScrProjection, invProjscrArr[0]);
cmd.SetComputeMatrixArrayParam(buildPerBigTileLightListShader, HDShaderIDs.g_mScrProjectionArr, projscrArr);
cmd.SetComputeMatrixArrayParam(buildPerBigTileLightListShader, HDShaderIDs.g_mInvScrProjectionArr, invProjscrArr);

if (m_FrameSettings.lightLoopSettings.isFptlEnabled)
{
cmd.SetComputeIntParam(buildPerTileLightListShader, HDShaderIDs.g_isOrthographic, isOrthographic ? 1 : 0);
cmd.SetComputeIntParams(buildPerTileLightListShader, HDShaderIDs.g_viDimensions, s_TempIntArray);
cmd.SetComputeIntParams(buildPerTileLightListShader, HDShaderIDs.g_viDimensions, s_TempScreenDimArray);
cmd.SetComputeIntParam(buildPerTileLightListShader, HDShaderIDs._EnvLightIndexShift, m_lightList.lights.Count);
cmd.SetComputeIntParam(buildPerTileLightListShader, HDShaderIDs._DecalIndexShift, m_lightList.lights.Count + m_lightList.envLights.Count);
cmd.SetComputeIntParam(buildPerTileLightListShader, HDShaderIDs.g_iNrVisibLights, m_lightCount);

}
cmd.SetComputeIntParam(buildMaterialFlagsShader, HDShaderIDs.g_BaseFeatureFlags, (int)baseFeatureFlags);
cmd.SetComputeIntParams(buildMaterialFlagsShader, HDShaderIDs.g_viDimensions, s_TempIntArray);
cmd.SetComputeIntParams(buildMaterialFlagsShader, HDShaderIDs.g_viDimensions, s_TempScreenDimArray);
cmd.SetComputeBufferParam(buildMaterialFlagsShader, buildMaterialFlagsKernel, HDShaderIDs.g_TileFeatureFlags, s_TileFeatureFlags);
cmd.SetComputeTextureParam(buildMaterialFlagsShader, buildMaterialFlagsKernel, HDShaderIDs._StencilTexture, stencilTextureRT);

48
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-bigtile.compute


#pragma kernel BigTileLightListGen
#pragma enable_d3d11_debug_symbols
#include "CoreRP/ShaderLibrary/common.hlsl"
#include "LightLoop.cs.hlsl"
#include "LightingConvexHullUtils.hlsl"

uniform int g_iNrVisibLights;
uniform uint2 g_viDimensions;
//uniform float4x4 g_mInvScrProjection;
//uniform float4x4 g_mScrProjection;
uniform float4x4 g_mInvScrProjectionArr[2];
uniform float4x4 g_mScrProjectionArr[2];

uint iWidth = g_viDimensions.x;
uint iHeight = g_viDimensions.y;
// TODO: Should we be re-calculating this?
uint nrBigTilesX = (iWidth+63)/64;
uint nrBigTilesY = (iHeight+63)/64;

float2 vTileLL = float2(viTilLL.x/(float) iWidth, viTilLL.y/(float) iHeight);
float2 vTileUR = float2(viTilUR.x/(float) iWidth, viTilUR.y/(float) iHeight);
// XRTODO: Depending on the eye, make sure you index into the right 'half' of
// g_vBoundsBuffer
// XRTODO - DONE: generate a 'real' index into the correct half of g_vBoundsBuffer
// This index should also correspond to the matching structs in _LightVolumeData and
// g_data, so if I just use this 'real' index, everything just might 'work'.
// If I need to look up the real light, I'll have to decode it, but this is fine for now.
// Actually, g_vBoundsBuffer will be significantly different than _LightVolumeData/g_data
// but I solved this by using helper function
// In the monoscopic mode, there is one set of bounds (min,max -> 2 * g_iNrVisibLights)
// In stereo, there are two sets of bounds (leftMin, leftMax, rightMin, rightMax -> 4 * g_iNrVisibLights)
// Might be worth creating helper functions for this
//const int eyeRelativeBase = 2 * eyeIndex * (int)g_iNrVisibLights;
//const int minBoundsIndex = eyeRelativeBase + l;
//const int maxBoundsIndex = eyeRelativeBase + l + (int)g_iNrVisibLights;
//const int2 boundsIndices = GenerateScreenSpaceBoundsIndices(l, g_iNrVisibLights, eyeIndex);
//const float2 vMi = g_vBoundsBuffer[l].xy;
//const float2 vMa = g_vBoundsBuffer[l+g_iNrVisibLights].xy;
//const float2 vMi = g_vBoundsBuffer[minBoundsIndex].xy;
//const float2 vMa = g_vBoundsBuffer[maxBoundsIndex].xy;
//const float2 vMi = g_vBoundsBuffer[boundsIndices.x].xy;
//const float2 vMa = g_vBoundsBuffer[boundsIndices.y].xy;
const float2 vMi = g_vBoundsBuffer[boundsIndices.min].xy;
const float2 vMa = g_vBoundsBuffer[boundsIndices.max].xy;

unsigned int uIndex;
InterlockedAdd(lightOffs, uInc, uIndex);
// XRTODO - DONE: We store the 'plain' light list index, not stereo-adjusted
if(uIndex<MAX_NR_BIGTILE_LIGHTS) lightsListLDS[uIndex] = l; // add to light list
}
}

if(t==0) lightOffs = 0;
GroupMemoryBarrierWithGroupSync();
int i;
// XRTODO - DONE: Fix up check against g_iNrVisibLights to account for stereo
// If we store the un-adjusted index, we are safe to compare against g_iNrVisibLights
// XRTODO - DONE: Fix up the offset into the stereo-ized big tile list
//int offs = tileIDX.y*nrBigTilesX + tileIDX.x;
// XRTODO - DONE: Do I want to encode the global index, or per-eye-relative index? The light list code later on
// is relative to per-eye, but I'll need the global index anyway. For consistency, it might be worth
// having the per-eye offset happen in the following compute job. Not sure yet.
// I think I want to encode the per-eye-relative-index (the normal one). This helps with tests against g_iNrVisibLights
for(i=t; i<(iNrCoarseLights+1); i+=NR_THREADS)
g_vLightList[MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE*offs + i] = i==0 ? iNrCoarseLights : lightsListLDS[max(i-1, 0)];
}

for(int l=threadID; l<iNrCoarseLights; l+=NR_THREADS)
{
// XRTODO - DONE: Is the value in lightsListLDS[l] stereo-corrected?
// It is not, so we need to correct it before using it in g_data
//SFiniteLightBound lgtDat = g_data[lightsListLDS[l]];
const int boundIndex = GenerateLightCullDataIndex(lightsListLDS[l], g_iNrVisibLights, eyeIndex);
SFiniteLightBound lgtDat = g_data[boundIndex];

const int totNrEdgePairs = 12*nrFrustEdges;
for(int l=0; l<iNrCoarseLights; l++)
{
// XRTODO - DONE: Where does this need to be corrected?
// One index for comparing against g_iNrVisibLights, one index for buffer lookups
// XRTODO - DONE: This is safe with uncorrected indices
// XRTODO - DONE: We need to correct before indexing into _LightVolumeData
//if (canEnter) canEnter = _LightVolumeData[idxCoarse].lightVolume != LIGHTVOLUMETYPE_SPHERE; // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
// XRTODO - DONE: We need to correct before indexing into g_data
//SFiniteLightBound lgtDat = g_data[idxCoarse];
SFiniteLightBound lgtDat = g_data[bufIdxCoarse];
const float3 boxX = lgtDat.boxAxisX.xyz;

正在加载...
取消
保存