Adding more counters to understand the cullign bug

This commit is contained in:
samcake 2016-10-06 18:15:32 -07:00
parent 56eb322b7d
commit ac54533433
3 changed files with 41 additions and 13 deletions

View file

@ -311,7 +311,7 @@ uint32_t scanLightVolumeSphere(FrustumGrid& grid, const FrustumGrid::Planes plan
return numClustersTouched;
}
uint32_t LightClusters::updateClusters() {
glm::ivec3 LightClusters::updateClusters() {
// Clean up last info
std::vector< std::vector< LightIndex > > clusterGridPoint(_numClusters);
std::vector< std::vector< LightIndex > > clusterGridSpot(_numClusters);
@ -327,11 +327,14 @@ uint32_t LightClusters::updateClusters() {
glm::ivec3 gridPosToOffset(1, theFrustumGrid.dims.x, theFrustumGrid.dims.x * theFrustumGrid.dims.y);
uint32_t numClusterTouched = 0;
uint32_t numLightsIn = _visibleLightIndices[0];
uint32_t numClusteredLights = 0;
for (size_t lightNum = 1; lightNum < _visibleLightIndices.size(); ++lightNum) {
auto lightId = _visibleLightIndices[lightNum];
auto light = _lightStage->getLight(lightId);
if (!light)
if (!light) {
continue;
}
auto worldOri = light->getPosition();
auto radius = light->getMaximumRadius();
@ -460,6 +463,8 @@ uint32_t LightClusters::updateClusters() {
} else {
numClusterTouched += scanLightVolumeSphere(theFrustumGrid, _gridPlanes, zMin, zMax, yMin, yMax, xMin, xMax, lightId, glm::vec4(glm::vec3(eyeOri), radius), clusterGrid);
}
numClusteredLights++;
}
// Lights have been gathered now reexpress in terms of 2 sequential buffers
@ -502,7 +507,7 @@ uint32_t LightClusters::updateClusters() {
_clusterGridBuffer._buffer->setData(_clusterGridBuffer._size, (gpu::Byte*) _clusterGrid.data());
_clusterContentBuffer._buffer->setSubData(0, indexOffset * sizeof(LightIndex), (gpu::Byte*) _clusterContent.data());
return numClusterTouched;
return glm::ivec3(numLightsIn, numClusteredLights, numClusterTouched);
}
@ -543,12 +548,14 @@ void LightClusteringPass::run(const render::SceneContextPointer& sceneContext, c
_lightClusters->updateLightStage(lightStage);
_lightClusters->updateLightFrame(lightStage->_currentFrame, lightingModel->isPointLightEnabled(), lightingModel->isSpotLightEnabled());
auto numClusterdLights = _lightClusters->updateClusters();
auto clusteringStats = _lightClusters->updateClusters();
output = _lightClusters;
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->setNumClusteredLights(numClusterdLights);
config->setNumInputLights(clusteringStats.x);
config->setNumClusteredLights(clusteringStats.y);
config->setNumClusteredLightReferences(clusteringStats.z);
}
DebugLightClusters::DebugLightClusters() {

View file

@ -74,7 +74,7 @@ public:
void updateLightFrame(const LightStage::Frame& lightFrame, bool points = true, bool spots = true);
uint32_t updateClusters();
glm::ivec3 updateClusters();
ViewFrustum _frustum;
@ -117,6 +117,8 @@ class LightClusteringPassConfig : public render::Job::Config {
Q_PROPERTY(bool freeze MEMBER freeze NOTIFY dirty)
Q_PROPERTY(int numClusteredLightReferences MEMBER numClusteredLightReferences NOTIFY dirty)
Q_PROPERTY(int numInputLights MEMBER numInputLights NOTIFY dirty)
Q_PROPERTY(int numClusteredLights MEMBER numClusteredLights NOTIFY dirty)
public:
LightClusteringPassConfig() : render::Job::Config(true){}
@ -130,6 +132,11 @@ public:
bool freeze{ false };
void setNumClusteredLightReferences(int numRefs) { numClusteredLightReferences = numRefs; emit dirty(); }
int numClusteredLightReferences { 0 };
void setNumInputLights(int numLights) { numInputLights = numLights; emit dirty(); }
int numInputLights { 0 };
void setNumClusteredLights(int numLights) { numClusteredLights = numLights; emit dirty(); }
int numClusteredLights { 0 };
signals:

View file

@ -33,14 +33,28 @@ Column {
label: "time",
scale: 1,
color: "#FFFFFF"
}
]
}
PlotPerf {
title: "Lights"
height: 50
object: Render.getConfig("LightClustering")
valueUnit: ""
valueScale: 1
valueNumDigits: "0"
plots: [
{
object: Render.getConfig("LightClustering"),
prop: "numClusteredLights",
label: "visible",
color: "#D959FE"
},
{
object: Render.getConfig("DrawLight"),
prop: "numDrawn",
unit: "",
scale: 0.01,
numDigits: 0,
label: "Lights",
object: Render.getConfig("LightClustering"),
prop: "numInputLights",
label: "input",
color: "#FED959"
}
]
@ -107,7 +121,7 @@ Column {
onCheckedChanged: { Render.getConfig("DebugLightClusters")["doDrawContent"] = checked }
}
Label {
text: "Num Cluster Items = " + Render.getConfig("LightClustering")["numClusteredLights"].toFixed(0)
text: "Num Cluster Items = " + Render.getConfig("LightClustering")["numClusteredLightReferences"].toFixed(0)
}
}