浏览代码

Stereo-ize writes to output buffers + enable stereo!

g_LayeredOffset  and g_logBaseBuffer are stereo eye index dependent, so generate the correct offsets/indices into the proper eye-dependent half of the buffer.

And finally, enable stereo-ized clustered light list generation!

The next piece of work is to enable stereo-ized light list reads in the light loop!  Next branch/PR!
/main
Robert Srinivasiah 7 年前
当前提交
e606b3b4
共有 2 个文件被更改,包括 16 次插入9 次删除
  1. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  2. 21
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-clustered.compute

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


var numTilesX = GetNumTileClusteredX(hdCamera);
var numTilesY = GetNumTileClusteredY(hdCamera);
cmd.DispatchCompute(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, numTilesX, numTilesY, 1);
int numEyes = m_FrameSettings.enableStereo ? 2 : 1;
//cmd.DispatchCompute(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, numTilesX, numTilesY, 1);
cmd.DispatchCompute(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, numTilesX, numTilesY, numEyes);
}
public void BuildGPULightListsCommon(HDCamera hdCamera, CommandBuffer cmd, RenderTargetIdentifier cameraDepthBufferRT, RenderTargetIdentifier stencilTextureRT, bool skyEnabled)

21
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-clustered.compute


#define NR_THREADS 64
// XRTODO: Stereo-ize writes to these buffers (except g_LayeredSingleIdxBuffer)
// output buffer
// XRTODO - DONE: Stereo-ize writes to g_LayeredOffset
// g_vLayeredLightList is a dynamically allocated cluster list, and g_LayeredSingleIdxBuffer tracks allocations
// so these do not need to be stereoized.
// XRTODO: Stereo-ize writes to g_logBaseBuffer
// XRTODO - DONE: Stereo-ize writes to g_logBaseBuffer
#ifdef ENABLE_DEPTH_TEXTURE_BACKPLANE
RWStructuredBuffer<float> g_logBaseBuffer : register( u3 ); // don't support RWBuffer yet in unity
#endif

// 'iSpaceAvail' is how many total lights are in this cluster.
// This allocation might be roughly over, because CheckIntersectionBasic is a very basic check.
// XRTODO: For stereo, we don't have to adjust anything into g_LayeredSingleIdxBuffer. Each thread is processing it's own
// XRTODO - DONE: For stereo, we don't have to adjust anything into g_LayeredSingleIdxBuffer. Each thread is processing it's own
// cluster, so we just need to make sure there is enough memory allocated in g_vLayeredLightList for two eyes worth of
// lists. The offset we get from start is good enough. We do have to store the offset into the
// stereo-corrected half of g_LayeredOffset.

// The encoded offsets are assuming the lights are sorted by category in the cluster list
uint localOffs=0;
// XRTODO: Stereo-ize this initial 'offs' to jump into the correct half of g_LayeredOffs.
// XRTODO - DONE: Stereo-ize this initial 'offs' to jump into the correct half of g_LayeredOffs.
offs = i*nrTilesX*nrTilesY + tileIDX.y*nrTilesX + tileIDX.x;
// TODO: Functionalize g_LayeredOffset indexing?
uint layeredOffsetBase = eyeIndex * LIGHTCATEGORY_COUNT * (nrClusters*nrTilesX*nrTilesY);
offs = layeredOffsetBase + (i*nrTilesX*nrTilesY) + (tileIDX.y*nrTilesX) + tileIDX.x;
for(int category=0; category<LIGHTCATEGORY_COUNT; category++)
{
int numLights = min(categoryListCount[category],31); // only allow 5 bits

}
#ifdef ENABLE_DEPTH_TEXTURE_BACKPLANE
// XRTODO: Stereo-ize this, as this is per-eye set of tiles
// XRTODO - DONE: Stereo-ize this, as this is per-eye set of tiles
if(threadID==0) g_logBaseBuffer[tileIDX.y*nrTilesX + tileIDX.x] = suggestedBase;
uint logBaseIndex = (eyeIndex * nrTilesY * nrTilesX) + (tileIDX.y*nrTilesX) + tileIDX.x;
if(threadID==0) g_logBaseBuffer[logBaseIndex] = suggestedBase;
#endif
}

正在加载...
取消
保存