@@ -269,21 +269,22 @@ void FLidarIntensitySceneViewExtension::PrePostProcessPass_RenderThread(
269269 }
270270 }
271271
272- // Create buffers for CURRENT frame
273- TArray<float > InitialData;
274- InitialData.SetNumZeroed (NumPoints * 4 );
272+ // Guard: nothing to dispatch if NumPoints is zero.
273+ if (NumPoints == 0 ) {
274+ return ;
275+ }
276+
277+ // Create an RDG structured buffer for the compute shader output.
278+ // We do NOT upload initial data here (no nullptr crash); the shader writes
279+ // every slot, and AddClearUAVFloatPass zeroes any slots it misses.
275280 FRDGBufferRef PointCloudBufferRDG =
276- CreateStructuredBuffer (GraphBuilder,
277- TEXT (" FLidarPointCloudCS_PointCloudBuffer" ),
278- sizeof (float ), NumPoints * 4 , nullptr ,
279- BufferSize);
280-
281- CreateStructuredBuffer (GraphBuilder,
282- TEXT (" FLidarPointCloudCS_PointCloudBuffer_StructuredBuffer" ),
283- sizeof (float ),
284- NumPoints * 4 , InitialData.GetData (), BufferSize);
285- FRDGBufferUAVRef PointCloudBufferUAV = GraphBuilder.CreateUAV (
286- PointCloudBufferRDG, PF_FloatRGBA, ERDGUnorderedAccessViewFlags::None);
281+ GraphBuilder.CreateBuffer (
282+ FRDGBufferDesc::CreateStructuredDesc (sizeof (float ), NumPoints * 4 ),
283+ TEXT (" FLidarPointCloudCS_PointCloudBuffer" ));
284+
285+ // Structured UAV — no pixel format; must match RWStructuredBuffer<float> in HLSL.
286+ FRDGBufferUAVRef PointCloudBufferUAV = GraphBuilder.CreateUAV (PointCloudBufferRDG);
287+ AddClearUAVFloatPass (GraphBuilder, PointCloudBufferUAV, -1 .0f );
287288
288289 FLidarPointCloudCS::FParameters* PassParameters =
289290 GraphBuilder.AllocParameters <FLidarPointCloudCS::FParameters>();
0 commit comments