History

Polish the debugging of the light volumes

samcake committed 10 years ago

Commit 6aa39ec1 parent a378a6e3 files · +46 −17Browse files

Showing the changes to libraries/render-utils/src/LightClusters.cpp (1 of 3 files). Show all

Unified · Split

libraries/render-utils/src/LightClusters.cpp+26−16
@@ -429,7 +429,6 @@ void LightClusters::updateClusters() { · 428 unmodified lines
429429 }
430430 }
431431
432− // _clusterGrid[i] = (uint32_t)((numLights << 16) | offset);
433432 _clusterGrid[i] = (uint32_t)((0xFF000000 & (numLightsSpot << 24)) | (0x00FF0000 & (numLightsPoint << 16)) | (0x0000FFFF & offset));
434433
435434
@@ -595,16 +594,23 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterContentPipeline() { · 159 unmodified lines
595594
596595
597596 void DebugLightClusters::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Inputs& inputs) {
597+ if (!(doDrawClusterFromDepth || doDrawContent || doDrawGrid)) {
598+ return;
599+ }
600+
598601 auto deferredTransform = inputs.get0();
599602 auto deferredFramebuffer = inputs.get1();
600603 auto lightingModel = inputs.get2();
601604 auto linearDepthTarget = inputs.get3();
602605 auto lightClusters = inputs.get4();
603−
606+
604607 auto args = renderContext->args;
605−
608+
606609 gpu::Batch batch;
607610
611+ batch.enableStereo(false);
612+
613+
608614 // Assign the camera transform
609615 batch.setViewportTransform(args->_viewport);
610616 glm::mat4 projMat;
@@ -661,26 +667,30 @@ void DebugLightClusters::run(const render::SceneContextPointer& sceneContext, co · 50 unmodified lines
661667 batch.setResourceTexture(DEFERRED_BUFFER_LINEAR_DEPTH_UNIT, nullptr);
662668 batch.setUniformBuffer(DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT, nullptr);
663669 }
664−
670+
671+
672+
673+ gpu::Batch drawGridAndCleanBatch;
674+
665675 if (doDrawGrid) {
666676 // bind the one gpu::Pipeline we need
667− batch.setPipeline(getDrawClusterGridPipeline());
668−
677+ drawGridAndCleanBatch.setPipeline(getDrawClusterGridPipeline());
678+
669679 auto dims = lightClusters->_frustumGridBuffer->dims;
670680 glm::ivec3 summedDims(dims.x*dims.y * dims.z, dims.x*dims.y, dims.x);
671− batch.drawInstanced(summedDims.x, gpu::LINES, 24, 0);
681+ drawGridAndCleanBatch.drawInstanced(summedDims.x, gpu::LINES, 24, 0);
672682 }
673683
674− batch.setUniformBuffer(LIGHT_GPU_SLOT, nullptr);
675− batch.setUniformBuffer(LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, nullptr);
676− batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, nullptr);
677− batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, nullptr);
684+ drawGridAndCleanBatch.setUniformBuffer(LIGHT_GPU_SLOT, nullptr);
685+ drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, nullptr);
686+ drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, nullptr);
687+ drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, nullptr);
678688
679− batch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr);
680− batch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr);
681− batch.setResourceTexture(DEFERRED_BUFFER_EMISSIVE_UNIT, nullptr);
682− batch.setResourceTexture(DEFERRED_BUFFER_DEPTH_UNIT, nullptr);
689+ drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr);
690+ drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr);
691+ drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_EMISSIVE_UNIT, nullptr);
692+ drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_DEPTH_UNIT, nullptr);
683693
684694 args->_context->appendFrameBatch(batch);
685−
695+ args->_context->appendFrameBatch(drawGridAndCleanBatch);
686696 }