From 684437383a7908fc82f6f24f3345c742852fc148 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Nov 2026 00:54:38 +0100 Subject: [PATCH 1/3] [cleanup] Removing signed vs unsigned compare warnings by replacing some int variables with uint32_t --- openpgl/data/PathSegmentDataStorage.h | 12 +- openpgl/data/SampleDataStorage.h | 50 ++++---- .../directional/OutgoingRadianceHistogram.h | 4 +- .../vmm/AdaptiveSplitandMergeFactory.h | 16 +-- .../vmm/ParallaxAwareVonMisesFisherMixture.h | 21 ++-- ...llaxAwareVonMisesFisherWeightedEMFactory.h | 118 +++++++++--------- .../vmm/VMMChiSquareComponentMerger.h | 4 +- .../vmm/VMMChiSquareComponentSplitter.h | 14 +-- openpgl/field/Field.h | 6 +- openpgl/imagespace/ImageSpaceGuidingBuffer.h | 8 +- openpgl/include/openpgl/config.h | 8 +- openpgl/spatial/KNN.h | 4 +- openpgl/spatial/kdtree/KDTree.h | 4 +- 13 files changed, 135 insertions(+), 134 deletions(-) diff --git a/openpgl/data/PathSegmentDataStorage.h b/openpgl/data/PathSegmentDataStorage.h index 9fe31df4..6c15c7a0 100644 --- a/openpgl/data/PathSegmentDataStorage.h +++ b/openpgl/data/PathSegmentDataStorage.h @@ -66,7 +66,7 @@ struct PathSegmentDataStorage void reserve(const size_t &size) { #if defined(OPENPGL_PATHSEGMENT_STORAGE_USE_ARRAY) - if (m_max_sample_size == size) + if ((uint32_t)m_max_sample_size == size) return; if (m_segmentStorage) delete[] m_segmentStorage; @@ -248,8 +248,8 @@ struct PathSegmentDataStorage openpgl::Vector3(currentPathSegment.scatteringWeight.x, currentPathSegment.scatteringWeight.y, currentPathSegment.scatteringWeight.z); openpgl::Vector3 scatteredContribution = openpgl::Vector3(currentPathSegment.scatteredContribution.x, currentPathSegment.scatteredContribution.y, currentPathSegment.scatteredContribution.z); - openpgl::Vector3 directContribution = - openpgl::Vector3(currentPathSegment.directContribution.x, currentPathSegment.directContribution.y, currentPathSegment.directContribution.z); + //openpgl::Vector3 directContribution = + // openpgl::Vector3(currentPathSegment.directContribution.x, currentPathSegment.directContribution.y, currentPathSegment.directContribution.z); #endif float pdf = std::max(minPDF, currentPathSegment.pdfDirectionIn); uint32_t flags{0}; @@ -296,7 +296,7 @@ struct PathSegmentDataStorage } if (directContribution[0] > 0.f || directContribution[1] > 0.f || directContribution[2] > 0.f) { - if (j == i + 1) + if ((int)j == i + 1) { if (contribution[0] > 0.f || contribution[1] > 0.f || contribution[2] > 0.f) { @@ -579,7 +579,7 @@ struct PathSegmentDataStorage #endif bool valid = true; - for (int s = 0; s < numSegments; s++) + for (uint32_t s = 0; s < numSegments; s++) { PathSegmentData psd = m_segmentStorage[s]; valid = valid && isValid(psd); @@ -605,7 +605,7 @@ struct PathSegmentDataStorage std::stringstream ss; ss << "PathSegmentDataStorage:" << std::endl; ss << "segment storage: size = " << numSegments << std::endl; - for (int s = 0; s < numSegments; s++) + for (uint32_t s = 0; s < numSegments; s++) { PathSegmentData psd = m_segmentStorage[s]; ss << "seg[" << s << "]: " << openpgl::toString(psd); diff --git a/openpgl/data/SampleDataStorage.h b/openpgl/data/SampleDataStorage.h index 4285cf4a..dd081be9 100644 --- a/openpgl/data/SampleDataStorage.h +++ b/openpgl/data/SampleDataStorage.h @@ -132,7 +132,7 @@ struct SampleDataStorage return m_surfaceContainer.samples.size(); } - inline SampleData getSampleSurface(const int idx) const + inline SampleData getSampleSurface(const uint32_t idx) const { OPENPGL_ASSERT(idx >= 0); OPENPGL_ASSERT(idx < m_surfaceContainer.samples.size()); @@ -165,7 +165,7 @@ struct SampleDataStorage return m_volumeContainer.samples.size(); } - inline SampleData getSampleVolume(const int idx) const + inline SampleData getSampleVolume(const uint32_t idx) const { OPENPGL_ASSERT(idx >= 0); OPENPGL_ASSERT(idx < m_volumeContainer.samples.size()); @@ -198,7 +198,7 @@ struct SampleDataStorage return m_surfaceContainer.zeroValueSamples.size(); } - inline ZeroValueSampleData getZeroValueSampleSurface(const int idx) const + inline ZeroValueSampleData getZeroValueSampleSurface(const uint32_t idx) const { OPENPGL_ASSERT(idx >= 0); OPENPGL_ASSERT(idx < m_surfaceContainer.zeroValueSamples.size()); @@ -231,7 +231,7 @@ struct SampleDataStorage return m_volumeContainer.zeroValueSamples.size(); } - inline ZeroValueSampleData getZeroValueSampleVolume(const int idx) const + inline ZeroValueSampleData getZeroValueSampleVolume(const uint32_t idx) const { OPENPGL_ASSERT(idx >= 0); OPENPGL_ASSERT(idx < m_volumeContainer.zeroValueSamples.size()); @@ -351,12 +351,12 @@ struct SampleDataStorage bool validate() const { bool valid = true; - for (int i = 0; i < m_surfaceContainer.samples.size(); i++) + for (uint32_t i = 0; i < m_surfaceContainer.samples.size(); i++) { valid = valid && isValid(m_surfaceContainer.samples[i]); } - for (int i = 0; i < m_volumeContainer.samples.size(); i++) + for (uint32_t i = 0; i < m_volumeContainer.samples.size(); i++) { valid = valid && isValid(m_volumeContainer.samples[i]); } @@ -365,22 +365,22 @@ struct SampleDataStorage void merge(const SampleDataStorage &b) { - for (int i = 0; i < b.m_surfaceContainer.samples.size(); i++) + for (uint32_t i = 0; i < b.m_surfaceContainer.samples.size(); i++) { m_surfaceContainer.samples.push_back(b.m_surfaceContainer.samples[i]); } - for (int i = 0; i < b.m_volumeContainer.samples.size(); i++) + for (uint32_t i = 0; i < b.m_volumeContainer.samples.size(); i++) { m_volumeContainer.samples.push_back(b.m_volumeContainer.samples[i]); } - for (int i = 0; i < b.m_surfaceContainer.zeroValueSamples.size(); i++) + for (uint32_t i = 0; i < b.m_surfaceContainer.zeroValueSamples.size(); i++) { m_surfaceContainer.zeroValueSamples.push_back(b.m_surfaceContainer.zeroValueSamples[i]); } - for (int i = 0; i < b.m_volumeContainer.zeroValueSamples.size(); i++) + for (uint32_t i = 0; i < b.m_volumeContainer.zeroValueSamples.size(); i++) { m_volumeContainer.zeroValueSamples.push_back(b.m_volumeContainer.zeroValueSamples[i]); } @@ -403,13 +403,13 @@ struct SampleDataStorage surfaceSampleDataA.resize(m_surfaceContainer.samples.size()); volumeSampleDataA.resize(m_volumeContainer.samples.size()); - for (int i = 0; i < m_surfaceContainer.samples.size(); i++) + for (uint32_t i = 0; i < m_surfaceContainer.samples.size(); i++) { surfaceSampleDataA[i] = m_surfaceContainer.samples[i]; } tbb::parallel_sort(surfaceSampleDataA.begin(), surfaceSampleDataA.end(), SampleDataLess); - for (int i = 0; i < m_volumeContainer.samples.size(); i++) + for (uint32_t i = 0; i < m_volumeContainer.samples.size(); i++) { volumeSampleDataA[i] = m_volumeContainer.samples[i]; } @@ -418,13 +418,13 @@ struct SampleDataStorage surfaceZeroValueSampleDataA.resize(m_surfaceContainer.zeroValueSamples.size()); volumeZeroValueSampleDataA.resize(m_volumeContainer.zeroValueSamples.size()); - for (int i = 0; i < m_surfaceContainer.zeroValueSamples.size(); i++) + for (uint32_t i = 0; i < m_surfaceContainer.zeroValueSamples.size(); i++) { surfaceZeroValueSampleDataA[i] = m_surfaceContainer.zeroValueSamples[i]; } tbb::parallel_sort(surfaceZeroValueSampleDataA.begin(), surfaceZeroValueSampleDataA.end(), ZeroValueSampleDataLess); - for (int i = 0; i < m_volumeContainer.zeroValueSamples.size(); i++) + for (uint32_t i = 0; i < m_volumeContainer.zeroValueSamples.size(); i++) { volumeZeroValueSampleDataA[i] = m_volumeContainer.zeroValueSamples[i]; } @@ -433,13 +433,13 @@ struct SampleDataStorage surfaceSampleDataB.resize(b.m_surfaceContainer.samples.size()); volumeSampleDataB.resize(b.m_volumeContainer.samples.size()); - for (int i = 0; i < b.m_surfaceContainer.samples.size(); i++) + for (uint32_t i = 0; i < b.m_surfaceContainer.samples.size(); i++) { surfaceSampleDataB[i] = b.m_surfaceContainer.samples[i]; } tbb::parallel_sort(surfaceSampleDataB.begin(), surfaceSampleDataB.end(), SampleDataLess); - for (int i = 0; i < b.m_volumeContainer.samples.size(); i++) + for (uint32_t i = 0; i < b.m_volumeContainer.samples.size(); i++) { volumeSampleDataB[i] = b.m_volumeContainer.samples[i]; } @@ -448,21 +448,21 @@ struct SampleDataStorage surfaceZeroValueSampleDataB.resize(b.m_surfaceContainer.zeroValueSamples.size()); volumeZeroValueSampleDataB.resize(b.m_volumeContainer.zeroValueSamples.size()); - for (int i = 0; i < b.m_surfaceContainer.zeroValueSamples.size(); i++) + for (uint32_t i = 0; i < b.m_surfaceContainer.zeroValueSamples.size(); i++) { surfaceZeroValueSampleDataB[i] = b.m_surfaceContainer.zeroValueSamples[i]; } tbb::parallel_sort(surfaceZeroValueSampleDataB.begin(), surfaceZeroValueSampleDataB.end(), ZeroValueSampleDataLess); - for (int i = 0; i < b.m_volumeContainer.zeroValueSamples.size(); i++) + for (uint32_t i = 0; i < b.m_volumeContainer.zeroValueSamples.size(); i++) { volumeZeroValueSampleDataB[i] = b.m_volumeContainer.zeroValueSamples[i]; } tbb::parallel_sort(volumeZeroValueSampleDataB.begin(), volumeZeroValueSampleDataB.end(), ZeroValueSampleDataLess); bool equal = true; - int sizeB = surfaceSampleDataB.size(); - for (int i = 0; i < surfaceSampleDataA.size(); i++) + uint32_t sizeB = surfaceSampleDataB.size(); + for (uint32_t i = 0; i < surfaceSampleDataA.size(); i++) { if (i < sizeB && !SampleDataEqual(surfaceSampleDataA[i], surfaceSampleDataB[i])) { @@ -471,7 +471,7 @@ struct SampleDataStorage } sizeB = surfaceZeroValueSampleDataB.size(); - for (int i = 0; i < surfaceZeroValueSampleDataA.size(); i++) + for (uint32_t i = 0; i < surfaceZeroValueSampleDataA.size(); i++) { if (i < sizeB && !ZeroValueSampleDataEqual(surfaceZeroValueSampleDataA[i], surfaceZeroValueSampleDataB[i])) { @@ -480,7 +480,7 @@ struct SampleDataStorage } sizeB = volumeSampleDataB.size(); - for (int i = 0; i < volumeSampleDataA.size(); i++) + for (uint32_t i = 0; i < volumeSampleDataA.size(); i++) { if (i < sizeB && !SampleDataEqual(volumeSampleDataA[i], volumeSampleDataB[i])) { @@ -489,7 +489,7 @@ struct SampleDataStorage } sizeB = volumeZeroValueSampleDataB.size(); - for (int i = 0; i < volumeZeroValueSampleDataA.size(); i++) + for (uint32_t i = 0; i < volumeZeroValueSampleDataA.size(); i++) { if (i < sizeB && !ZeroValueSampleDataEqual(volumeZeroValueSampleDataA[i], volumeZeroValueSampleDataB[i])) { @@ -505,7 +505,7 @@ struct SampleDataStorage { std::vector subSampledData; subSampledData.reserve(sampleContainer.size()); - for (size_t i = 0; i < sampleContainer.size(); i++) + for (uint32_t i = 0; i < sampleContainer.size(); i++) { subSampledData.push_back(sampleContainer[i]); } @@ -538,7 +538,7 @@ struct SampleDataStorage if (!pointsOnly) { - for (int i = 0; i < subSampledData.size(); i++) + for (uint32_t i = 0; i < subSampledData.size(); i++) { objFile << "f " << i * 3 + 1 << "\t" << i * 3 + 2 << "\t" << i * 3 + 3 << std::endl; } diff --git a/openpgl/directional/OutgoingRadianceHistogram.h b/openpgl/directional/OutgoingRadianceHistogram.h index ee0a10f7..4bad7157 100644 --- a/openpgl/directional/OutgoingRadianceHistogram.h +++ b/openpgl/directional/OutgoingRadianceHistogram.h @@ -106,7 +106,7 @@ OPENPGL_INLINE_INTER void OutgoingRadianceHistogram::update(const SampleData *sa const size_t numZeroValueSamples) { // std::cout << "OutgoingRadianceHistogram::update: numSamples = " << numSamples << "\t numZeroValueSamples = " << numZeroValueSamples << std::endl; - for (int n = 0; n < numSamples; n++) + for (uint32_t n = 0; n < numSamples; n++) { pgl_vec3f directionOut = samples[n].directionOut; Vector3 dir = Vector3(directionOut.x, directionOut.y, directionOut.z); @@ -114,7 +114,7 @@ OPENPGL_INLINE_INTER void OutgoingRadianceHistogram::update(const SampleData *sa Vector3 col = Vector3(color.x, color.y, color.z); addSample(dir, col); } - for (int n = 0; n < numZeroValueSamples; n++) + for (uint32_t n = 0; n < numZeroValueSamples; n++) { pgl_vec3f directionOut = zeroValueSamples[n].directionOut; Vector3 dir = Vector3(directionOut.x, directionOut.y, directionOut.z); diff --git a/openpgl/directional/vmm/AdaptiveSplitandMergeFactory.h b/openpgl/directional/vmm/AdaptiveSplitandMergeFactory.h index c676ff62..05f8acba 100644 --- a/openpgl/directional/vmm/AdaptiveSplitandMergeFactory.h +++ b/openpgl/directional/vmm/AdaptiveSplitandMergeFactory.h @@ -41,11 +41,11 @@ struct AdaptiveSplitAndMergeFactory bool useSplitAndMerge{true}; bool partialReFit{false}; - int maxSplitItr{1}; + uint32_t maxSplitItr{1}; - int minSamplesForSplitting{0}; - int minSamplesForPartialRefitting{0}; - int minSamplesForMerging{0}; + uint32_t minSamplesForSplitting{0}; + uint32_t minSamplesForPartialRefitting{0}; + uint32_t minSamplesForMerging{0}; void serialize(std::ostream &stream) const; @@ -254,11 +254,11 @@ void AdaptiveSplitAndMergeFactory::Configuration::serialize(st stream.write(reinterpret_cast(&mergingThreshold), sizeof(float)); stream.write(reinterpret_cast(&partialReFit), sizeof(bool)); - stream.write(reinterpret_cast(&maxSplitItr), sizeof(int)); + stream.write(reinterpret_cast(&maxSplitItr), sizeof(uint32_t)); - stream.write(reinterpret_cast(&minSamplesForSplitting), sizeof(int)); - stream.write(reinterpret_cast(&minSamplesForMerging), sizeof(int)); - stream.write(reinterpret_cast(&minSamplesForPartialRefitting), sizeof(int)); + stream.write(reinterpret_cast(&minSamplesForSplitting), sizeof(uint32_t)); + stream.write(reinterpret_cast(&minSamplesForMerging), sizeof(uint32_t)); + stream.write(reinterpret_cast(&minSamplesForPartialRefitting), sizeof(uint32_t)); } template diff --git a/openpgl/directional/vmm/ParallaxAwareVonMisesFisherMixture.h b/openpgl/directional/vmm/ParallaxAwareVonMisesFisherMixture.h index 55951fc2..3d8e2895 100644 --- a/openpgl/directional/vmm/ParallaxAwareVonMisesFisherMixture.h +++ b/openpgl/directional/vmm/ParallaxAwareVonMisesFisherMixture.h @@ -782,8 +782,8 @@ float ParallaxAwareVonMisesFisherMixture zeros(0.0f); const embree::vfloat zeroKappaNorm(ONE_OVER_FOUR_PI); - const int cnt = (_numComponents + VecSize - 1) / VecSize; - const int rem = _numComponents % VecSize; + const uint32_t cnt = (_numComponents + VecSize - 1) / VecSize; + const uint32_t rem = _numComponents % VecSize; const embree::vfloat weight = _weight; const embree::vfloat kappa = _kappa; @@ -793,7 +793,7 @@ float ParallaxAwareVonMisesFisherMixture productIntegralVec(0.f); - for (int k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { embree::Vec3> newMeanDirection = _kappas[k] * _meanDirections[k] + kappa * meanDirection; embree::vfloat newKappa = embree::sqrt(embree::dot(newMeanDirection, newMeanDirection)); @@ -832,14 +832,14 @@ float ParallaxAwareVonMisesFisherMixture 0) { - for (size_t i = rem; i < VecSize; i++) + for (uint32_t i = rem; i < VecSize; i++) { _meanDirections[cnt - 1].x[i] = 0.0f; _meanDirections[cnt - 1].y[i] = 0.0f; @@ -979,7 +979,8 @@ inline void ParallaxAwareVonMisesFisherMixture= searched || selectedVector >= tmp.quot) + if (sumWeights + cdf >= searched || selectedVector >= quot) { break; } @@ -1002,7 +1003,7 @@ inline void ParallaxAwareVonMisesFisherMixture= searched || selectedVector + 1 >= (tmp.quot + 1)) + if (sumWeights + cdf >= searched || selectedVector + 1 >= (quot + 1)) { break; } @@ -1017,7 +1018,7 @@ inline void ParallaxAwareVonMisesFisherMixture= searched, cdfs[selectedVector]); @@ -1139,7 +1140,7 @@ void ParallaxAwareVonMisesFisherMixture_numComponents + VectorSize - 1) / VectorSize; + const uint32_t cnt = (this->_numComponents + VectorSize - 1) / VectorSize; // const int rem = this->_numComponents % VectorSize; const embree::Vec3> shiftDirectionVec(shiftDirection); diff --git a/openpgl/directional/vmm/ParallaxAwareVonMisesFisherWeightedEMFactory.h b/openpgl/directional/vmm/ParallaxAwareVonMisesFisherWeightedEMFactory.h index 033c67b2..60c41437 100644 --- a/openpgl/directional/vmm/ParallaxAwareVonMisesFisherWeightedEMFactory.h +++ b/openpgl/directional/vmm/ParallaxAwareVonMisesFisherWeightedEMFactory.h @@ -279,8 +279,8 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::SufficientS return; } - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - // const int rem = vmm._numComponents % VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + // const uint32_t rem = vmm._numComponents % VMM::VectorSize; for (uint32_t k = 0; k < cnt; k++) { @@ -301,7 +301,7 @@ bool ParallaxAwareVonMisesFisherWeightedEMFactory::SufficientS { bool valid = true; - for (size_t k = 0; k < numComponents; k++) + for (uint32_t k = 0; k < numComponents; k++) { const div_t tmpK = div(k, VMM::VectorSize); valid = valid && embree::isvalid(sumOfWeightedDirections[tmpK.quot].x[tmpK.rem]); @@ -948,7 +948,7 @@ float ParallaxAwareVonMisesFisherWeightedEMFactory::weightedEx stats.numComponents = vmm._numComponents; stats.numSamples = numSamples; - const int cnt = (stats.numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t cnt = (stats.numComponents + VMM::VectorSize - 1) / VMM::VectorSize; float summedWeightedLogLikelihood{0.f}; @@ -975,7 +975,7 @@ float ParallaxAwareVonMisesFisherWeightedEMFactory::weightedEx summedWeightedLogLikelihood += sampleData.weight * embree::log(softAssign.pdf); - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { stats.sumOfWeightedDirections[k] += sampleDirectionSIMD * softAssign.assignments[k] * sampleWeight; stats.sumOfWeightedStats[k] += softAssign.assignments[k] * sampleWeight; @@ -988,7 +988,7 @@ template void ParallaxAwareVonMisesFisherWeightedEMFactory::estimateMAPWeights(VMM &vmm, const SufficientStatistics ¤tStats, const SufficientStatistics &previousStats, const float &_weightPrior) const { - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; const size_t numComponents = vmm._numComponents; @@ -997,7 +997,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimateMAP const embree::vfloat numSamples = currentStats.numSamples + previousStats.numSamples; // const vfloat numSamples = currentStats.numSamples + previousStats.overallNumSamples; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { //_sumWeights += currentStats.sumOfWeightedStats[k]; embree::vfloat weight = (currentStats.sumOfWeightedStats[k] + previousStats.sumOfWeightedStats[k]); @@ -1033,10 +1033,10 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimateMAP const embree::vfloat meanCosinePrior = cfg.meanCosinePrior; const embree::vfloat meanCosinePriorStrength = cfg.meanCosinePriorStrength; const embree::vfloat maxMeanCosine = cfg.maxMeanCosine; - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - const int rem = vmm._numComponents % VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t rem = vmm._numComponents % VMM::VectorSize; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { // const vfloat partialNumSamples = vmm._weights[k] * numSamples; const embree::vfloat partialNumSamples = vmm._weights[k] * overallNumSamples; @@ -1069,7 +1069,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimateMAP // TODO: find better more efficient way if (rem > 0) { - for (size_t i = rem; i < VMM::VectorSize; i++) + for (uint32_t i = rem; i < VMM::VectorSize; i++) { vmm._meanDirections[cnt - 1].x[i] = 0.0f; vmm._meanDirections[cnt - 1].y[i] = 0.0f; @@ -1114,7 +1114,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimatePar SufficientStatistics &previousStats, const float &_weightPrior) const { const embree::vfloat zeros(0.0f); - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; const size_t numComponents = vmm._numComponents; @@ -1126,7 +1126,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimatePar embree::vfloat sumWeights(0.0f); embree::vfloat sumPartialWeights(0.0f); - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { //_sumWeights += currentStats.sumOfWeightedStats[k]; embree::vfloat weight = (currentStats.sumOfWeightedStats[k] + previousStats.sumOfWeightedStats[k]); @@ -1142,7 +1142,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimatePar embree::vfloat inv_sumPartialWeights = 1.0f / reduce_add(sumPartialWeights); inv_sumPartialWeights *= 1.0f - reduce_add(sumWeights); - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { vmm._weights[k] = select(mask.mask[k], vmm._weights[k] * inv_sumPartialWeights, vmm._weights[k]); } @@ -1150,7 +1150,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimatePar // TODO: find better more efficient way if (vmm._numComponents % VMM::VectorSize > 0) { - for (size_t i = vmm._numComponents % VMM::VectorSize; i < VMM::VectorSize; i++) + for (uint32_t i = vmm._numComponents % VMM::VectorSize; i < VMM::VectorSize; i++) { vmm._weights[cnt - 1][i] = 0.0f; } @@ -1174,10 +1174,10 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimatePar const embree::vfloat meanCosinePrior = cfg.meanCosinePrior; const embree::vfloat meanCosinePriorStrength = cfg.meanCosinePriorStrength; const embree::vfloat maxMeanCosine = cfg.maxMeanCosine; - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - const int rem = vmm._numComponents % VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t rem = vmm._numComponents % VMM::VectorSize; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { // const vfloat partialNumSamples = vmm._weights[k] * numSamples; const embree::vfloat partialNumSamples = vmm._weights[k] * overallNumSamples; @@ -1210,7 +1210,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::estimatePar // TODO: find better more efficient way if (rem > 0) { - for (size_t i = rem; i < VMM::VectorSize; i++) + for (uint32_t i = rem; i < VMM::VectorSize; i++) { vmm._meanDirections[cnt - 1].x[i] = 0.0f; vmm._meanDirections[cnt - 1].y[i] = 0.0f; @@ -1286,10 +1286,10 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::initCompone const embree::vfloat zeros(0.0f); - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - const int rem = vmm._numComponents % VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t rem = vmm._numComponents % VMM::VectorSize; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { batchDistances[k] = zeros; batchSumWeights[k] = zeros; @@ -1298,7 +1298,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::initCompone typename VMM::SoftAssignment softAssign; float sampleDistance; embree::vfloat weights; - for (size_t n = 0; n < numSamples; n++) + for (uint32_t n = 0; n < numSamples; n++) { #ifdef USE_HARMONIC_MEAN sampleDistance = embree::rcp(samples[n].distance); @@ -1309,7 +1309,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::initCompone const Vector3 sampleDirection(direction.x, direction.y, direction.z); if (vmm.softAssignment(sampleDirection, softAssign)) { - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { weights = select(vmm._weights[k] > FLT_EPSILON, samples[n].weight * softAssign.assignments[k] * ((softAssign.assignments[k] * softAssign.pdf) / vmm._weights[k]), zeros); @@ -1322,7 +1322,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::initCompone } } - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { #ifdef USE_HARMONIC_MEAN sufficientStats.sumOfDistanceWeightes[k] = batchSumWeights[k]; @@ -1335,7 +1335,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::initCompone if (rem > 0) { - for (size_t i = rem; i < VMM::VectorSize; i++) + for (uint32_t i = rem; i < VMM::VectorSize; i++) { vmm._distances[cnt - 1][i] = 0.0f; sufficientStats.sumOfDistanceWeightes[cnt - 1][i] = 0.0f; @@ -1353,10 +1353,10 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateCompo embree::vfloat batchSumWeights[VMM::NumVectors]; const embree::vfloat zeros(0.0f); - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - const int rem = vmm._numComponents % VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t rem = vmm._numComponents % VMM::VectorSize; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { batchDistances[k] = zeros; batchSumWeights[k] = zeros; @@ -1365,7 +1365,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateCompo typename VMM::SoftAssignment softAssign; float sampleDistance; embree::vfloat weights; - for (size_t n = 0; n < numSamples; n++) + for (uint32_t n = 0; n < numSamples; n++) { OPENPGL_ASSERT(samples[n].distance > 0); OPENPGL_ASSERT(embree::isvalid(samples[n].distance)); @@ -1378,7 +1378,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateCompo const Vector3 sampleDirection(direction.x, direction.y, direction.z); if (vmm.softAssignment(sampleDirection, softAssign)) { - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { weights = samples[n].weight * softAssign.assignments[k] * ((softAssign.assignments[k] * softAssign.pdf) / vmm._weights[k]); batchDistances[k] += weights * sampleDistance; @@ -1387,7 +1387,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateCompo } } - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { #ifdef USE_HARMONIC_MEAN // embree::vfloat sumInverseDistances = (sufficientStats.sumOfDistanceWeightes[k] / vmm._distances[k]) + batchDistances[k]; @@ -1404,7 +1404,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateCompo if (rem > 0) { - for (size_t i = rem; i < VMM::VectorSize; i++) + for (uint32_t i = rem; i < VMM::VectorSize; i++) { vmm._distances[cnt - 1][i] = 0.0f; sufficientStats.sumOfDistanceWeightes[cnt - 1][i] = 0.0f; @@ -1415,7 +1415,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateCompo #ifdef OPENPGL_RADIANCE_CACHES template void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluenceEstimate(VMM &vmm, const SampleData *samples, const size_t numSamples, - const size_t numZeroValueSamples, const SampleStatistics &sampleStatistics) const + const size_t numZeroValueSamples, [[maybe_unused]]const SampleStatistics &sampleStatistics) const { #ifdef MC_ESTIMATE_INCOMING_RADIANCE // calcualting fluence and the RGB per lob estiamtions using the MC samples if (numSamples == 0) @@ -1423,8 +1423,8 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen return; } - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - const int rem = vmm._numComponents % VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t rem = vmm._numComponents % VMM::VectorSize; const embree::vfloat zeros(0.0f); @@ -1436,7 +1436,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen embree::Vec3 > sumFluenceRGBWeightsWithMIS[VMM::NumVectors]; typename VMM::SoftAssignment softAssign; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { sumFluenceRGBWeights[k].x = zeros; sumFluenceRGBWeights[k].y = zeros; @@ -1447,7 +1447,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen sumFluenceRGBWeightsWithMIS[k].z = zeros; } - for (size_t n = 0; n < numSamples; n++) + for (uint32_t n = 0; n < numSamples; n++) { // sumFluence += samples[n].weight; pgl_vec3f direction = samples[n].direction; @@ -1462,7 +1462,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen sumFluenceRGBWithMIS += radianceIn; if (vmm.softAssignment(sampleDirection, softAssign)) { - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { sumFluenceRGBWeights[k].x += radianceInNoMIS.x * softAssign.assignments[k]; sumFluenceRGBWeights[k].y += radianceInNoMIS.y * softAssign.assignments[k]; @@ -1480,7 +1480,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen if (rem > 0) { - for (size_t i = rem; i < VMM::VectorSize; i++) + for (uint32_t i = rem; i < VMM::VectorSize; i++) { sumFluenceRGBWeights[cnt - 1].x[i] = 0.0f; sumFluenceRGBWeights[cnt - 1].y[i] = 0.0f; @@ -1493,7 +1493,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen } // TODO: switch to numerical more stable version - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { vmm._fluenceRGBWeights[k].x = ((vmm._fluenceRGBWeights[k].x * oldNumFluenceSamples) + sumFluenceRGBWeights[k].x) / newNumFluenceSamples; vmm._fluenceRGBWeights[k].y = ((vmm._fluenceRGBWeights[k].y * oldNumFluenceSamples) + sumFluenceRGBWeights[k].y) / newNumFluenceSamples; @@ -1512,7 +1512,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen // maybe drop this code const embree::vfloat zeros(0.0f); const embree::vfloat ones(1.0f); - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; if (numSamples == 0) { @@ -1527,7 +1527,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen Vector3 sumFluenceRGBMC{0.f, 0.f, 0.f}; typename VMM::SoftAssignment softAssign; - for (int k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { sumPdfs[k] = zeros; sumFluenceRGBWeights[k].x = zeros; @@ -1535,7 +1535,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen sumFluenceRGBWeights[k].z = zeros; } - for (size_t n = 0; n < numSamples; n++) + for (uint32_t n = 0; n < numSamples; n++) { const Vector3 sampleDirection(samples[n].direction.x, samples[n].direction.y, samples[n].direction.z); embree::Vec3 > sampleDirectionVec(sampleDirection[0], sampleDirection[1], sampleDirection[2]); @@ -1546,7 +1546,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen if (vmm.softAssignment(sampleDirection, softAssign)) { - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { const embree::vfloat cosTheta = embree::dot(sampleDirectionVec, vmm._meanDirections[k]); const embree::vfloat cosThetaMinusOne = embree::min(cosTheta - ones, zeros); @@ -1563,7 +1563,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen } } - for (int k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { sumFluenceRGBWeights[k].x = select(sumPdfs[k] > 0.0f, sumFluenceRGBWeights[k].x / sumPdfs[k], zeros) * (4.0f * M_PI_F); OPENPGL_ASSERT(embree::isvalid(sumFluenceRGBWeights[k].x)); @@ -1580,7 +1580,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateFluen const float newNumFluenceSamples = (oldNumFluenceSamples + float(numSamples)); float alpha = float(numSamples) / (vmm._numFluenceSamples + numSamples); - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { vmm._fluenceRGBWeightsWithMIS[k].x = (vmm._fluenceRGBWeightsWithMIS[k].x * (1.f - alpha)) + alpha * sumFluenceRGBWeights[k].x; vmm._fluenceRGBWeightsWithMIS[k].y = (vmm._fluenceRGBWeightsWithMIS[k].y * (1.f - alpha)) + alpha * sumFluenceRGBWeights[k].y; @@ -1660,7 +1660,7 @@ template void ParallaxAwareVonMisesFisherWeightedEMFactory::PartialFittingMask::resetToFalse() { const embree::vbool vFalse(false); - for (size_t k = 0; k < ((VMM::MaxComponents + (VMM::VectorSize - 1)) / VMM::VectorSize); k++) + for (uint32_t k = 0; k < ((VMM::MaxComponents + (VMM::VectorSize - 1)) / VMM::VectorSize); k++) { mask[k] = vFalse; } @@ -1670,8 +1670,8 @@ template void ParallaxAwareVonMisesFisherWeightedEMFactory::PartialFittingMask::resetToTrue(const size_t &numComponents) { const embree::vbool vTrue(true); - const int cnt = (numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - for (size_t k = 0; k < cnt; k++) + const uint32_t cnt = (numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + for (uint32_t k = 0; k < cnt; k++) { mask[k] = vTrue; } @@ -1730,15 +1730,15 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateVolum return; } - const int cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - const int rem = vmm._numComponents % VMM::VectorSize; + const uint32_t cnt = (vmm._numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t rem = vmm._numComponents % VMM::VectorSize; const embree::vfloat zeros(0.0f); const embree::vfloat ones(1.0f); typename VMM::SoftAssignment softAssign; - for (size_t n = 0; n < numSamples; n++) + for (uint32_t n = 0; n < numSamples; n++) { const float weight = samples[n].weight; pgl_vec3f direction = samples[n].direction; @@ -1746,7 +1746,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateVolum if (vmm.softAssignment(sampleDirection, softAssign)) { - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { if (isNextEventVolume(samples[n])) { @@ -1782,14 +1782,14 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateVolum } } - for (size_t n = 0; n < numZeroValueSamples; n++) + for (uint32_t n = 0; n < numZeroValueSamples; n++) { pgl_vec3f direction = zeroValueSamples[n].direction; const Vector3 sampleDirection(direction.x, direction.y, direction.z); if (vmm.softAssignment(sampleDirection, softAssign)) { - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { if (isNextEventVolume(zeroValueSamples[n])) { @@ -1807,7 +1807,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateVolum if (rem > 0) { - for (size_t i = rem; i < VMM::VectorSize; i++) + for (uint32_t i = rem; i < VMM::VectorSize; i++) { vmm._volumeScatterProbabilityWeights[cnt - 1][i] = 0.0f; sufficientStats.volumeContributionWeights[cnt - 1][i] = 0.0f; @@ -1817,7 +1817,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateVolum } } - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { embree::vfloat numVolSamples = sufficientStats.volumeSampleNumberWeights[k]; embree::vfloat numSurfSamples = sufficientStats.surfaceSampleNumberWeights[k]; @@ -1851,7 +1851,7 @@ void ParallaxAwareVonMisesFisherWeightedEMFactory::updateVolum if (rem > 0) { - for (size_t i = rem; i < VMM::VectorSize; i++) + for (uint32_t i = rem; i < VMM::VectorSize; i++) { vmm._volumeScatterProbabilityWeights[cnt - 1][i] = 0.0f; sufficientStats.volumeContributionWeights[cnt - 1][i] = 0.0f; diff --git a/openpgl/directional/vmm/VMMChiSquareComponentMerger.h b/openpgl/directional/vmm/VMMChiSquareComponentMerger.h index d27e6787..6c3affe1 100644 --- a/openpgl/directional/vmm/VMMChiSquareComponentMerger.h +++ b/openpgl/directional/vmm/VMMChiSquareComponentMerger.h @@ -212,10 +212,10 @@ bool VonMisesFisherChiSquareComponentMerger::ThresholdedMergeNext(V float minMergeCost = std::numeric_limits::max(); bool foundMergeCandidates = false; - for (size_t i = 0; i < K - 1; i++) + for (int i = 0; i < K - 1; i++) { const div_t tmpI = div(i, static_cast(VMM::VectorSize)); - for (size_t j = i + 1; j < K; j++) + for (int j = i + 1; j < K; j++) { const div_t tmpJ = div(j, static_cast(VMM::VectorSize)); float mergeCost = CalculateMergeCost(vmm, i, j); diff --git a/openpgl/directional/vmm/VMMChiSquareComponentSplitter.h b/openpgl/directional/vmm/VMMChiSquareComponentSplitter.h index dabfaa5d..1ea72c6b 100644 --- a/openpgl/directional/vmm/VMMChiSquareComponentSplitter.h +++ b/openpgl/directional/vmm/VMMChiSquareComponentSplitter.h @@ -468,7 +468,7 @@ void VonMisesFisherChiSquareComponentSplitter::UpdateSplitStatistic typename VMM::SoftAssignment softAssign; const embree::vfloat zeros(0.f); - const int cnt = (splitStats.numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t cnt = (splitStats.numComponents + VMM::VectorSize - 1) / VMM::VectorSize; // size_t validDataCount = 0.0f; for (size_t n = 0; n < numData; n++) @@ -482,7 +482,7 @@ void VonMisesFisherChiSquareComponentSplitter::UpdateSplitStatistic const embree::vfloat samplePDF = sample.pdf; const embree::vfloat value = weight * samplePDF; // std::cout << "data[" << n << "]: " << "value: " << value << "\t samplePDF: " << samplePDF; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { OPENPGL_ASSERT(embree::all(embree::isvalid(splitStats.splitMeans[k].x))); OPENPGL_ASSERT(embree::all(embree::isvalid(splitStats.splitMeans[k].y))); @@ -1166,9 +1166,9 @@ void VonMisesFisherChiSquareComponentSplitter::ComponentSplitStatis const embree::vfloat zeros(0.f); this->numComponents = _numComponents; - const int cnt = (this->numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t cnt = (this->numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { chiSquareMCEstimates[k] = zeros; splitWeightedSampleCovariances[k].x = zeros; @@ -1187,9 +1187,9 @@ void VonMisesFisherChiSquareComponentSplitter::ComponentSplitStatis template void VonMisesFisherChiSquareComponentSplitter::ComponentSplitStatistics::decay(const float &alpha) { - const int cnt = (this->numComponents + VMM::VectorSize - 1) / VMM::VectorSize; + const uint32_t cnt = (this->numComponents + VMM::VectorSize - 1) / VMM::VectorSize; - for (size_t k = 0; k < cnt; k++) + for (uint32_t k = 0; k < cnt; k++) { splitWeightedSampleCovariances[k].x *= alpha; splitWeightedSampleCovariances[k].y *= alpha; @@ -1206,7 +1206,7 @@ size_t VonMisesFisherChiSquareComponentSplitter::ComponentSplitStat { size_t maxIdx = 0; float maxChiSquareValue = chiSquareMCEstimates[0][0]; - for (size_t k = 1; k < numComponents; k++) + for (uint32_t k = 1; k < numComponents; k++) { const div_t tmp = div(k, static_cast(VMM::VectorSize)); if (chiSquareMCEstimates[tmp.quot][tmp.rem] > maxChiSquareValue) diff --git a/openpgl/field/Field.h b/openpgl/field/Field.h index 70dc7187..7bc8cbf5 100644 --- a/openpgl/field/Field.h +++ b/openpgl/field/Field.h @@ -353,7 +353,7 @@ struct Field { bool valid = true; size_t nGuidingRegions = m_regionStorageContainer.size(); - for (int n = 0; n < nGuidingRegions; n++) + for (uint32_t n = 0; n < nGuidingRegions; n++) { valid = valid && m_regionStorageContainer[n].first.isValid() && m_regionStorageContainer[n].first.valid; valid = valid && m_regionStorageContainer[n].second.isValid(); @@ -689,7 +689,7 @@ struct Field return equal; } - for (int n = 0; n < treeNodesA.size(); n++) + for (uint32_t n = 0; n < treeNodesA.size(); n++) { if (!treeNodesA[n].operator==(treeNodesB[n])) { @@ -697,7 +697,7 @@ struct Field } } - for (int n = 0; n < dataStorageIndicesA.size(); n++) + for (uint32_t n = 0; n < dataStorageIndicesA.size(); n++) { size_t idxA = dataStorageIndicesA[n]; size_t idxB = dataStorageIndicesB[n]; diff --git a/openpgl/imagespace/ImageSpaceGuidingBuffer.h b/openpgl/imagespace/ImageSpaceGuidingBuffer.h index 3833c0e9..d7402733 100644 --- a/openpgl/imagespace/ImageSpaceGuidingBuffer.h +++ b/openpgl/imagespace/ImageSpaceGuidingBuffer.h @@ -152,7 +152,7 @@ struct ImageSpaceGuidingBuffer m_cfg.vspEstimate = false; m_cfg.vspType = PGLVSPTypes::EVSPContribution; #endif - for (int i = 0; i < layer_names.size(); i++) + for (uint32_t i = 0; i < layer_names.size(); i++) { std::string layerName = layer_names[i]; if (layerName == "Contrib" || layerName == "Contrib2nd") @@ -192,7 +192,7 @@ struct ImageSpaceGuidingBuffer } #endif - for (int i = 0; i < layer_names.size(); i++) + for (uint32_t i = 0; i < layer_names.size(); i++) { std::string layerName = layer_names[i]; std::vector channels; @@ -517,7 +517,7 @@ struct ImageSpaceGuidingBuffer int totalNumLayers = layerChannels.size(); int totalNumChannels = 0; - for (int i = 0; i < numChannels.size(); i++) + for (uint32_t i = 0; i < numChannels.size(); i++) { totalNumChannels += numChannels[i]; } @@ -759,7 +759,7 @@ struct ImageSpaceGuidingBuffer m_contributionEstimateBuffers->spp[pixelIdx] += 1; float alpha = 1.f / m_contributionEstimateBuffers->spp[pixelIdx]; - const pgl_vec3f quantity = m_cfg.contributionType == PGLContributionTypes::EContribContribution ? sample.contribution : sample.contribution * sample.contribution; + //const pgl_vec3f quantity = m_cfg.contributionType == PGLContributionTypes::EContribContribution ? sample.contribution : sample.contribution * sample.contribution; m_contributionEstimateBuffers->contribution[pixelIdx] = (1.f - alpha) * m_contributionEstimateBuffers->contribution[pixelIdx] + alpha * sample.contribution; m_contributionEstimateBuffers->albedo[pixelIdx] = (1.f - alpha) * m_contributionEstimateBuffers->albedo[pixelIdx] + alpha * sample.albedo; m_contributionEstimateBuffers->normal[pixelIdx] = (1.f - alpha) * m_contributionEstimateBuffers->normal[pixelIdx] + alpha * sample.normal; diff --git a/openpgl/include/openpgl/config.h b/openpgl/include/openpgl/config.h index 240333a7..9908f836 100644 --- a/openpgl/include/openpgl/config.h +++ b/openpgl/include/openpgl/config.h @@ -83,11 +83,11 @@ extern "C" float mergingThreshold{0.025f}; bool partialReFit{true}; - int maxSplitItr{1}; + uint32_t maxSplitItr{1}; - int minSamplesForSplitting{PGL_TREE_MAX_SAMPLE_PER_LEAF / 8}; - int minSamplesForPartialRefitting{PGL_TREE_MAX_SAMPLE_PER_LEAF / 8}; - int minSamplesForMerging{PGL_TREE_MAX_SAMPLE_PER_LEAF / 4}; + uint32_t minSamplesForSplitting{PGL_TREE_MAX_SAMPLE_PER_LEAF / 8}; + uint32_t minSamplesForPartialRefitting{PGL_TREE_MAX_SAMPLE_PER_LEAF / 8}; + uint32_t minSamplesForMerging{PGL_TREE_MAX_SAMPLE_PER_LEAF / 4}; }; enum PGLDQTLeafEstimator diff --git a/openpgl/spatial/KNN.h b/openpgl/spatial/KNN.h index 8649ec3b..d344203a 100644 --- a/openpgl/spatial/KNN.h +++ b/openpgl/spatial/KNN.h @@ -366,11 +366,11 @@ struct KNearestRegionsSearchTree auto &nh = neighbours[n]; nh.size = num_results; - int i = 0; + uint32_t i = 0; for (; i < num_results; i++) { size_t idx = ret_index[i]; - selfIsIn = selfIsIn || idx == n; + selfIsIn = selfIsIn || idx == (uint32_t)n; nh.set(i, idx, points[idx].p.x, points[idx].p.y, points[idx].p.z); } for (; i < NUM_KNN_NEIGHBOURS; i++) diff --git a/openpgl/spatial/kdtree/KDTree.h b/openpgl/spatial/kdtree/KDTree.h index 9c70be44..7e1b5cd2 100644 --- a/openpgl/spatial/kdtree/KDTree.h +++ b/openpgl/spatial/kdtree/KDTree.h @@ -303,7 +303,7 @@ struct KDTree if (nNodes > 0) { m_nodesPtr = new KDNode[nNodes]; - for (int n = 0; n < nNodes; n++) + for (uint32_t n = 0; n < nNodes; n++) { m_nodesPtr[n] = m_nodes[n]; } @@ -657,7 +657,7 @@ struct KDTree if (m_nodes.size() == b.m_nodes.size()) { - for (int n = 0; n < m_nodes.size(); n++) + for (uint32_t n = 0; n < m_nodes.size(); n++) { if (!m_nodes[n].operator==(b.m_nodes[n])) { From 2c193e45bcce8cecd2c51d9e264260c848387205 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Nov 2026 00:41:41 +0100 Subject: [PATCH 2/3] [cmake] Switching to C++ 17 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5935e963..e4c3e05d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) From 3236643de529307f28ed527f30d087aa3771926e Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Nov 2026 01:32:46 +0100 Subject: [PATCH 3/3] [embree] Avoiding some double to float conversion warnings --- .../embreeSrc/common/math/transcendental.h | 162 +++++++++--------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/third-party/embreeSrc/common/math/transcendental.h b/third-party/embreeSrc/common/math/transcendental.h index daf9dd96..ddfbc7e5 100644 --- a/third-party/embreeSrc/common/math/transcendental.h +++ b/third-party/embreeSrc/common/math/transcendental.h @@ -18,8 +18,8 @@ namespace fastapprox template __forceinline T sin(const T &v) { - static const float piOverTwoVec = 1.57079637050628662109375; - static const float twoOverPiVec = 0.636619746685028076171875; + static const float piOverTwoVec = 1.57079637050628662109375f; + static const float twoOverPiVec = 0.636619746685028076171875f; auto scaled = v * twoOverPiVec; auto kReal = floor(scaled); auto k = toInt(kReal); @@ -32,17 +32,17 @@ __forceinline T sin(const T &v) // These coefficients are from sollya with fpminimax(sin(x)/x, [|0, 2, // 4, 6, 8, 10|], [|single...|], [0;Pi/2]); - static const float sinC2 = -0.16666667163372039794921875; - static const float sinC4 = +8.333347737789154052734375e-3; - static const float sinC6 = -1.9842604524455964565277099609375e-4; - static const float sinC8 = +2.760012648650445044040679931640625e-6; - static const float sinC10 = -2.50293279435709337121807038784027099609375e-8; - - static const float cosC2 = -0.5; - static const float cosC4 = +4.166664183139801025390625e-2; - static const float cosC6 = -1.388833043165504932403564453125e-3; - static const float cosC8 = +2.47562347794882953166961669921875e-5; - static const float cosC10 = -2.59630184018533327616751194000244140625e-7; + static const float sinC2 = -0.16666667163372039794921875f; + static const float sinC4 = +8.333347737789154052734375e-3f; + static const float sinC6 = -1.9842604524455964565277099609375e-4f; + static const float sinC8 = +2.760012648650445044040679931640625e-6f; + static const float sinC10 = -2.50293279435709337121807038784027099609375e-8f; + + static const float cosC2 = -0.5f; + static const float cosC4 = +4.166664183139801025390625e-2f; + static const float cosC6 = -1.388833043165504932403564453125e-3f; + static const float cosC8 = +2.47562347794882953166961669921875e-5f; + static const float cosC10 = -2.59630184018533327616751194000244140625e-7f; auto outside = select(sinUseCos, 1., x); auto c2 = select(sinUseCos, T(cosC2), T(sinC2)); @@ -66,8 +66,8 @@ __forceinline T sin(const T &v) template __forceinline T cos(const T &v) { - static const float piOverTwoVec = 1.57079637050628662109375; - static const float twoOverPiVec = 0.636619746685028076171875; + static const float piOverTwoVec = 1.57079637050628662109375f; + static const float twoOverPiVec = 0.636619746685028076171875f; auto scaled = v * twoOverPiVec; auto kReal = floor(scaled); auto k = toInt(kReal); @@ -79,17 +79,17 @@ __forceinline T cos(const T &v) auto cosUseCos = (kMod4 == 0) | (kMod4 == 2); auto flipSign = (kMod4 == 1) | (kMod4 == 2); - const float sinC2 = -0.16666667163372039794921875; - const float sinC4 = +8.333347737789154052734375e-3; - const float sinC6 = -1.9842604524455964565277099609375e-4; - const float sinC8 = +2.760012648650445044040679931640625e-6; - const float sinC10 = -2.50293279435709337121807038784027099609375e-8; + const float sinC2 = -0.16666667163372039794921875f; + const float sinC4 = +8.333347737789154052734375e-3f; + const float sinC6 = -1.9842604524455964565277099609375e-4f; + const float sinC8 = +2.760012648650445044040679931640625e-6f; + const float sinC10 = -2.50293279435709337121807038784027099609375e-8f; - const float cosC2 = -0.5; - const float cosC4 = +4.166664183139801025390625e-2; - const float cosC6 = -1.388833043165504932403564453125e-3; - const float cosC8 = +2.47562347794882953166961669921875e-5; - const float cosC10 = -2.59630184018533327616751194000244140625e-7; + const float cosC2 = -0.5f; + const float cosC4 = +4.166664183139801025390625e-2f; + const float cosC6 = -1.388833043165504932403564453125e-3f; + const float cosC8 = +2.47562347794882953166961669921875e-5f; + const float cosC10 = -2.59630184018533327616751194000244140625e-7f; auto outside = select(cosUseCos, 1., x); auto c2 = select(cosUseCos, T(cosC2), T(sinC2)); @@ -113,8 +113,8 @@ __forceinline T cos(const T &v) template __forceinline void sincos(const T &v, T &sinResult, T &cosResult) { - const float piOverTwoVec = 1.57079637050628662109375; - const float twoOverPiVec = 0.636619746685028076171875; + const float piOverTwoVec = 1.57079637050628662109375f; + const float twoOverPiVec = 0.636619746685028076171875f; auto scaled = v * twoOverPiVec; auto kReal = floor(scaled); auto k = toInt(kReal); @@ -128,17 +128,17 @@ __forceinline void sincos(const T &v, T &sinResult, T &cosResult) auto cosFlipSign = ((kMod4 == 1) | (kMod4 == 2)); const float oneVec = +1.; - const float sinC2 = -0.16666667163372039794921875; - const float sinC4 = +8.333347737789154052734375e-3; - const float sinC6 = -1.9842604524455964565277099609375e-4; - const float sinC8 = +2.760012648650445044040679931640625e-6; - const float sinC10 = -2.50293279435709337121807038784027099609375e-8; - - const float cosC2 = -0.5; - const float cosC4 = +4.166664183139801025390625e-2; - const float cosC6 = -1.388833043165504932403564453125e-3; - const float cosC8 = +2.47562347794882953166961669921875e-5; - const float cosC10 = -2.59630184018533327616751194000244140625e-7; + const float sinC2 = -0.16666667163372039794921875f; + const float sinC4 = +8.333347737789154052734375e-3f; + const float sinC6 = -1.9842604524455964565277099609375e-4f; + const float sinC8 = +2.760012648650445044040679931640625e-6f; + const float sinC10 = -2.50293279435709337121807038784027099609375e-8f; + + const float cosC2 = -0.5f; + const float cosC4 = +4.166664183139801025390625e-2f; + const float cosC6 = -1.388833043165504932403564453125e-3f; + const float cosC8 = +2.47562347794882953166961669921875e-5f; + const float cosC10 = -2.59630184018533327616751194000244140625e-7f; auto x2 = x * x; @@ -168,8 +168,8 @@ __forceinline void sincos(const T &v, T &sinResult, T &cosResult) template __forceinline T tan(const T &v) { - const float piOverFourVec = 0.785398185253143310546875; - const float fourOverPiVec = 1.27323949337005615234375; + const float piOverFourVec = 0.785398185253143310546875f; + const float fourOverPiVec = 1.27323949337005615234375f; auto xLt0 = v < 0.; auto y = select(xLt0, -v, v); @@ -190,19 +190,19 @@ __forceinline T tan(const T &v) const float oneVec = 1.0; - const float tanC2 = +0.33333075046539306640625; - const float tanC4 = +0.13339905440807342529296875; - const float tanC6 = +5.3348250687122344970703125e-2; - const float tanC8 = +2.46033705770969390869140625e-2; - const float tanC10 = +2.892402000725269317626953125e-3; - const float tanC12 = +9.500005282461643218994140625e-3; + const float tanC2 = +0.33333075046539306640625f; + const float tanC4 = +0.13339905440807342529296875f; + const float tanC6 = +5.3348250687122344970703125e-2f; + const float tanC8 = +2.46033705770969390869140625e-2f; + const float tanC10 = +2.892402000725269317626953125e-3f; + const float tanC12 = +9.500005282461643218994140625e-3f; - const float cotC2 = -0.3333333432674407958984375; - const float cotC4 = -2.222204394638538360595703125e-2; - const float cotC6 = -2.11752182804048061370849609375e-3; - const float cotC8 = -2.0846328698098659515380859375e-4; - const float cotC10 = -2.548247357481159269809722900390625e-5; - const float cotC12 = -3.5257363606433500535786151885986328125e-7; + const float cotC2 = -0.3333333432674407958984375f; + const float cotC4 = -2.222204394638538360595703125e-2f; + const float cotC6 = -2.11752182804048061370849609375e-3f; + const float cotC8 = -2.0846328698098659515380859375e-4f; + const float cotC10 = -2.548247357481159269809722900390625e-5f; + const float cotC12 = -3.5257363606433500535786151885986328125e-7f; auto x2 = x * x; T z; @@ -271,7 +271,7 @@ __forceinline T acos(const T &v) template __forceinline T atan(const T &v) { - const float piOverTwoVec = 1.57079637050628662109375; + const float piOverTwoVec = 1.57079637050628662109375f; // atan(-x) = -atan(x) (so flip from negative to positive first) // If x > 1 -> atan(x) = Pi/2 - atan(1/x) auto xNeg = v < 0.f; @@ -281,14 +281,14 @@ __forceinline T atan(const T &v) auto x = select(xGt1, rcpSafe(xFlipped), xFlipped); // These coefficients approximate atan(x)/x - const float atanC0 = +0.99999988079071044921875; - const float atanC2 = -0.3333191573619842529296875; - const float atanC4 = +0.199689209461212158203125; - const float atanC6 = -0.14015688002109527587890625; - const float atanC8 = +9.905083477497100830078125e-2; - const float atanC10 = -5.93664981424808502197265625e-2; - const float atanC12 = +2.417283318936824798583984375e-2; - const float atanC14 = -4.6721356920897960662841796875e-3; + const float atanC0 = +0.99999988079071044921875f; + const float atanC2 = -0.3333191573619842529296875f; + const float atanC4 = +0.199689209461212158203125f; + const float atanC6 = -0.14015688002109527587890625f; + const float atanC8 = +9.905083477497100830078125e-2f; + const float atanC10 = -5.93664981424808502197265625e-2f; + const float atanC12 = +2.417283318936824798583984375e-2f; + const float atanC14 = -4.6721356920897960662841796875e-3f; auto x2 = x * x; auto result = x2 * atanC14 + atanC12; @@ -308,7 +308,7 @@ __forceinline T atan(const T &v) template __forceinline T atan2(const T &y, const T &x) { - const float piVec = 3.1415926536; + const float piVec = 3.1415926536f; // atan2(y, x) = // // atan2(y > 0, x = +-0) -> Pi/2 @@ -333,9 +333,9 @@ __forceinline T atan2(const T &y, const T &x) template __forceinline T exp(const T &v) { - const float ln2Part1 = 0.6931457519; - const float ln2Part2 = 1.4286067653e-6; - const float oneOverLn2 = 1.44269502162933349609375; + const float ln2Part1 = 0.6931457519f; + const float ln2Part2 = 1.4286067653e-6f; + const float oneOverLn2 = 1.44269502162933349609375f; auto scaled = v * oneOverLn2; auto kReal = floor(scaled); @@ -347,12 +347,12 @@ __forceinline T exp(const T &v) // These coefficients are for e^x in [0, ln(2)] const float one = 1.; - const float c2 = 0.4999999105930328369140625; - const float c3 = 0.166668415069580078125; - const float c4 = 4.16539050638675689697265625e-2; - const float c5 = 8.378830738365650177001953125e-3; - const float c6 = 1.304379315115511417388916015625e-3; - const float c7 = 2.7555381529964506626129150390625e-4; + const float c2 = 0.4999999105930328369140625f; + const float c3 = 0.166668415069580078125f; + const float c4 = 4.16539050638675689697265625e-2f; + const float c5 = 8.378830738365650177001953125e-3f; + const float c6 = 1.304379315115511417388916015625e-3f; + const float c7 = 2.7555381529964506626129150390625e-4f; auto result = x * c7 + c6; result = x * result + c5; @@ -439,18 +439,18 @@ __forceinline T log(const T &v) auto patched = select(exceptional, one, v); __rangeReduceLog(patched, reduced, exponent); - const float ln2 = 0.693147182464599609375; + const float ln2 = 0.693147182464599609375f; auto x1 = one - reduced; - const float c1 = +0.50000095367431640625; - const float c2 = +0.33326041698455810546875; - const float c3 = +0.2519190013408660888671875; - const float c4 = +0.17541764676570892333984375; - const float c5 = +0.3424419462680816650390625; - const float c6 = -0.599632322788238525390625; - const float c7 = +1.98442304134368896484375; - const float c8 = -2.4899270534515380859375; - const float c9 = +1.7491014003753662109375; + const float c1 = +0.50000095367431640625f; + const float c2 = +0.33326041698455810546875f; + const float c3 = +0.2519190013408660888671875f; + const float c4 = +0.17541764676570892333984375f; + const float c5 = +0.3424419462680816650390625f; + const float c6 = -0.599632322788238525390625f; + const float c7 = +1.98442304134368896484375f; + const float c8 = -2.4899270534515380859375f; + const float c9 = +1.7491014003753662109375f; auto result = x1 * c9 + c8; result = x1 * result + c7;