From ea439349dc9461f4d18eab143fe705e4cbf10c81 Mon Sep 17 00:00:00 2001 From: keptsecret Date: Wed, 27 Aug 2025 16:29:26 +0700 Subject: [PATCH 01/11] added tests for iridescent bxdfs --- .../app_resources/test_compile.comp.hlsl | 7 ++++ 66_HLSLBxDFTests/app_resources/tests.hlsl | 35 +++++++++++++++++-- 66_HLSLBxDFTests/main.cpp | 10 +++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl index 6673a1c34..d10b8ee0b 100644 --- a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl @@ -31,6 +31,7 @@ void main(uint32_t3 ID : SV_DispatchThreadID) bxdf::reflection::SBeckmannAnisotropic beckmannAnisoBRDF; bxdf::reflection::SGGXIsotropic ggxIsoBRDF; bxdf::reflection::SGGXAnisotropic ggxAnisoBRDF; + bxdf::reflection::SIridescent iridBRDF; bxdf::transmission::SLambertian lambertianBSDF; bxdf::transmission::SSmoothDielectric smoothDielectricBSDF; @@ -39,6 +40,7 @@ void main(uint32_t3 ID : SV_DispatchThreadID) bxdf::transmission::SBeckmannDielectricAnisotropic beckmannAnisoBSDF; bxdf::transmission::SGGXDielectricIsotropic ggxIsoBSDF; bxdf::transmission::SGGXDielectricAnisotropic ggxAnisoBSDF; + bxdf::transmission::SIridescent iridBRDF; // do some nonsense calculations, but call all the relevant functions @@ -74,6 +76,11 @@ void main(uint32_t3 ID : SV_DispatchThreadID) s = ggxAnisoBRDF.generate(anisointer, u.xy, cache); L += s.L.direction; + iso_cache icache; + typename bxdf::reflection::SIridescent::query_type query6 = iridBRDF.createQuery(s, isointer); + qp = iridBRDF.quotient_and_pdf(query6, s, isointer, icache); + L -= qp.quotient; + typename bxdf::reflection::SGGXAnisotropic::query_type query1 = ggxAnisoBRDF.createQuery(s, anisointer); qp = ggxAnisoBRDF.quotient_and_pdf(query1, s, anisointer, cache); L -= qp.quotient; diff --git a/66_HLSLBxDFTests/app_resources/tests.hlsl b/66_HLSLBxDFTests/app_resources/tests.hlsl index ba388dbdb..9aa735b83 100644 --- a/66_HLSLBxDFTests/app_resources/tests.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests.hlsl @@ -343,6 +343,20 @@ struct TestBxDF> : } }; +template<> +struct TestBxDF> : TestBxDFBase> +{ + using base_t = TestBxDFBase>; + + void initBxDF(SBxDFTestResources _rc) + { + base_t::bxdf = bxdf::reflection::SIridescent::create(rc.alpha.x,1600.0,hlsl::promote(1.0),hlsl::promote(1.8),hlsl::promote(rc.ior.x),hlsl::promote(rc.ior.y)); +#ifndef __HLSL_VERSION + base_t::name = "Iridescent BRDF"; +#endif + } +}; + template<> struct TestBxDF> : TestBxDFBase> { @@ -431,6 +445,21 @@ struct TestBxDF +struct TestBxDF> : TestBxDFBase> +{ + using base_t = TestBxDFBase>; + + void initBxDF(SBxDFTestResources _rc) + { + base_t::bxdf = bxdf::transmission::SIridescent::create(rc.alpha.x,1600.0,hlsl::promote(1.0),hlsl::promote(1.8),hlsl::promote(rc.ior.x)); +#ifndef __HLSL_VERSION + base_t::name = "Iridescent BSDF"; +#endif + } +}; + + template struct is_basic_brdf : bool_constant< @@ -445,7 +474,8 @@ struct is_microfacet_brdf : bool_constant< is_same>::value || is_same>::value || is_same>::value || - is_same>::value + is_same>::value || + is_same>::value > {}; template @@ -463,7 +493,8 @@ struct is_microfacet_bsdf : bool_constant< is_same>::value || is_same>::value || is_same>::value || - is_same>::value + is_same>::value || + is_same>::value > {}; template diff --git a/66_HLSLBxDFTests/main.cpp b/66_HLSLBxDFTests/main.cpp index 627b09d82..c21d52cba 100644 --- a/66_HLSLBxDFTests/main.cpp +++ b/66_HLSLBxDFTests/main.cpp @@ -66,7 +66,7 @@ struct PrintFailureCallback : FailureCallback } }; -#define FOR_EACH_BEGIN(r) std::for_each(std::execution::par_unseq, r.begin(), r.end(), [&](uint32_t i) { +#define FOR_EACH_BEGIN(r) std::for_each(std::execution::seq, r.begin(), r.end(), [&](uint32_t i) { #define FOR_EACH_END }); int main(int argc, char** argv) @@ -173,6 +173,7 @@ int main(int argc, char** argv) TestJacobian, true>::run(initparams, cb); TestJacobian, false>::run(initparams, cb); TestJacobian,true>::run(initparams, cb); + TestJacobian, false>::run(initparams, cb); TestJacobian>::run(initparams, cb); TestJacobian >::run(initparams, cb); @@ -181,6 +182,7 @@ int main(int argc, char** argv) TestJacobian, true>::run(initparams, cb); TestJacobian, false>::run(initparams, cb); TestJacobian,true>::run(initparams, cb); + TestJacobian, false>::run(initparams, cb); FOR_EACH_END @@ -197,6 +199,7 @@ int main(int argc, char** argv) TestReciprocity, true>::run(initparams, cb); TestReciprocity, false>::run(initparams, cb); TestReciprocity, true>::run(initparams, cb); + TestReciprocity, false>::run(initparams, cb); TestReciprocity>::run(initparams, cb); TestReciprocity>::run(initparams, cb); @@ -205,6 +208,7 @@ int main(int argc, char** argv) TestReciprocity, true>::run(initparams, cb); TestReciprocity, false>::run(initparams, cb); TestReciprocity, true>::run(initparams, cb); + TestReciprocity, false>::run(initparams, cb); FOR_EACH_END @@ -223,6 +227,7 @@ int main(int argc, char** argv) TestBucket, true>::run(initparams, cb); TestBucket, false>::run(initparams, cb); TestBucket, true>::run(initparams, cb); + TestBucket, false>::run(initparams, cb); TestBucket>::run(initparams, cb); //TestBucket>::run(initparams, cb); @@ -231,6 +236,7 @@ int main(int argc, char** argv) TestBucket, true>::run(initparams, cb); TestBucket, false>::run(initparams, cb); TestBucket, true>::run(initparams, cb); + TestBucket, false>::run(initparams, cb); FOR_EACH_END @@ -251,6 +257,7 @@ int main(int argc, char** argv) TestChi2, true>::run(initparams, cb); TestChi2, false>::run(initparams, cb); TestChi2, true>::run(initparams, cb); + TestChi2, false>::run(initparams, cb); TestChi2>::run(initparams, cb); //TestChi2>::run(initparams, cb); @@ -259,6 +266,7 @@ int main(int argc, char** argv) TestChi2, true>::run(initparams, cb); TestChi2, false>::run(initparams, cb); TestChi2, true>::run(initparams, cb); + TestChi2, false>::run(initparams, cb); FOR_EACH_END // test arccos angle sums From 91658e3f0737d192cafba9e073c5d67cc6eaaac6 Mon Sep 17 00:00:00 2001 From: keptsecret Date: Thu, 28 Aug 2025 10:43:24 +0700 Subject: [PATCH 02/11] fix small typo --- 66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl index d10b8ee0b..6f48228e9 100644 --- a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl @@ -40,7 +40,7 @@ void main(uint32_t3 ID : SV_DispatchThreadID) bxdf::transmission::SBeckmannDielectricAnisotropic beckmannAnisoBSDF; bxdf::transmission::SGGXDielectricIsotropic ggxIsoBSDF; bxdf::transmission::SGGXDielectricAnisotropic ggxAnisoBSDF; - bxdf::transmission::SIridescent iridBRDF; + bxdf::transmission::SIridescent iridBSDF; // do some nonsense calculations, but call all the relevant functions From 6b5f3e83ece1e279abce0efaac5cc599eaeec0bf Mon Sep 17 00:00:00 2001 From: keptsecret Date: Thu, 28 Aug 2025 15:52:54 +0700 Subject: [PATCH 03/11] forgot to set parallel execution --- 66_HLSLBxDFTests/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/66_HLSLBxDFTests/main.cpp b/66_HLSLBxDFTests/main.cpp index c21d52cba..56e8e4217 100644 --- a/66_HLSLBxDFTests/main.cpp +++ b/66_HLSLBxDFTests/main.cpp @@ -66,7 +66,7 @@ struct PrintFailureCallback : FailureCallback } }; -#define FOR_EACH_BEGIN(r) std::for_each(std::execution::seq, r.begin(), r.end(), [&](uint32_t i) { +#define FOR_EACH_BEGIN(r) std::for_each(std::execution::par_unseq, r.begin(), r.end(), [&](uint32_t i) { #define FOR_EACH_END }); int main(int argc, char** argv) From 99206836d6afd6fe55735b88f4a576a0b52e10a2 Mon Sep 17 00:00:00 2001 From: keptsecret Date: Thu, 28 Aug 2025 16:21:54 +0700 Subject: [PATCH 04/11] refactor changes to colorspace stuff --- 28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl b/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl index eaecb5d0f..07694b5cf 100644 --- a/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl +++ b/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl @@ -1,5 +1,5 @@ #include "fft_mirror_common.hlsl" -#include "nbl/builtin/hlsl/colorspace/encodeCIEXYZ.hlsl" +#include "nbl/builtin/hlsl/colorspace.hlsl" [[vk::binding(2, 0)]] RWTexture2DArray kernelChannels; @@ -192,7 +192,7 @@ struct PreloadedSecondAxisAccessor : MultiChannelPreloadedAccessorMirrorTradeBas if (!workgroup::SubgroupContiguousIndex()) { const vector channelWiseSums = { preloaded[0][0].real(), preloaded[1][0].real(), preloaded[2][0].real() }; - const scalar_t power = mul(vector(colorspace::scRGBtoXYZ._m10_m11_m12), channelWiseSums); + const scalar_t power = mul(vector(colorspace::scRGB::ToXYZ()._m10_m11_m12), channelWiseSums); vk::RawBufferStore(pushConstants.rowMajorBufferAddress, scalar_t(1) / power); } } From c022a23df046404efa43ff7a78e4ed080fff607a Mon Sep 17 00:00:00 2001 From: keptsecret Date: Tue, 4 Nov 2025 10:20:18 +0700 Subject: [PATCH 05/11] revert using colorspace mat --- 28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl b/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl index 07694b5cf..eaecb5d0f 100644 --- a/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl +++ b/28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl @@ -1,5 +1,5 @@ #include "fft_mirror_common.hlsl" -#include "nbl/builtin/hlsl/colorspace.hlsl" +#include "nbl/builtin/hlsl/colorspace/encodeCIEXYZ.hlsl" [[vk::binding(2, 0)]] RWTexture2DArray kernelChannels; @@ -192,7 +192,7 @@ struct PreloadedSecondAxisAccessor : MultiChannelPreloadedAccessorMirrorTradeBas if (!workgroup::SubgroupContiguousIndex()) { const vector channelWiseSums = { preloaded[0][0].real(), preloaded[1][0].real(), preloaded[2][0].real() }; - const scalar_t power = mul(vector(colorspace::scRGB::ToXYZ()._m10_m11_m12), channelWiseSums); + const scalar_t power = mul(vector(colorspace::scRGBtoXYZ._m10_m11_m12), channelWiseSums); vk::RawBufferStore(pushConstants.rowMajorBufferAddress, scalar_t(1) / power); } } From f6371c7023d8d1f32a0b73bf946ba5b21ec12a1f Mon Sep 17 00:00:00 2001 From: keptsecret Date: Tue, 4 Nov 2025 16:10:01 +0700 Subject: [PATCH 06/11] a number of minor test fixes, disabled iridescent test temporarily --- .../app_resources/test_compile.comp.hlsl | 12 ++--- .../app_resources/test_components.hlsl | 4 +- .../app_resources/tests_common.hlsl | 8 +++ 66_HLSLBxDFTests/main.cpp | 49 ++++++++++++------- 4 files changed, 47 insertions(+), 26 deletions(-) diff --git a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl index c45f20c72..a98188277 100644 --- a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl @@ -32,7 +32,7 @@ void main(uint32_t3 ID : SV_DispatchThreadID) bxdf::reflection::SBeckmannAnisotropic beckmannAnisoBRDF; bxdf::reflection::SGGXIsotropic ggxIsoBRDF; bxdf::reflection::SGGXAnisotropic ggxAnisoBRDF; - bxdf::reflection::SIridescent iridBRDF; + // bxdf::reflection::SIridescent iridBRDF; bxdf::transmission::SLambertian lambertianBSDF; bxdf::transmission::SOrenNayar orenNayarBSDF; @@ -43,7 +43,7 @@ void main(uint32_t3 ID : SV_DispatchThreadID) bxdf::transmission::SBeckmannDielectricAnisotropic beckmannAnisoBSDF; bxdf::transmission::SGGXDielectricIsotropic ggxIsoBSDF; bxdf::transmission::SGGXDielectricAnisotropic ggxAnisoBSDF; - bxdf::transmission::SIridescent iridBSDF; + // bxdf::transmission::SIridescent iridBSDF; // do some nonsense calculations, but call all the relevant functions @@ -78,10 +78,10 @@ void main(uint32_t3 ID : SV_DispatchThreadID) s = ggxAnisoBRDF.generate(anisointer, u.xy, cache); L += s.L.direction; - iso_cache icache; - typename bxdf::reflection::SIridescent::query_type query6 = iridBRDF.createQuery(s, isointer); - qp = iridBRDF.quotient_and_pdf(query6, s, isointer, icache); - L -= qp.quotient; + // iso_cache icache; + // typename bxdf::reflection::SIridescent::query_type query6 = iridBRDF.createQuery(s, isointer); + // qp = iridBRDF.quotient_and_pdf(query6, s, isointer, icache); + // L -= qp.quotient; qp = ggxAnisoBRDF.quotient_and_pdf(s, anisointer, cache); L -= qp.quotient; diff --git a/66_HLSLBxDFTests/app_resources/test_components.hlsl b/66_HLSLBxDFTests/app_resources/test_components.hlsl index 9631db05d..cd2aa5cb6 100644 --- a/66_HLSLBxDFTests/app_resources/test_components.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_components.hlsl @@ -90,7 +90,7 @@ struct TestNDF : TestBxDF NBL_IF_CONSTEXPR(aniso) { dg1_query_type dq = base_t::bxdf.ndf.template createDG1Query(base_t::anisointer, cache); - fresnel_type _f = bxdf::impl::getOrientedFresnel::__call(base_t::bxdf.fresnel, base_t::anisointer.getNdotV()); + fresnel_type _f = base_t::bxdf_t::getOrientedFresnel(base_t::bxdf.fresnel, base_t::anisointer.getNdotV()); quant_query_type qq = bxdf::impl::quant_query_helper::template __call(base_t::bxdf.ndf, _f, cache); quant_type DG1 = base_t::bxdf.ndf.template DG1(dq, qq, s, base_t::anisointer); dg1 = DG1.microfacetMeasure * hlsl::abs(cache.getVdotH() / base_t::anisointer.getNdotV()); @@ -101,7 +101,7 @@ struct TestNDF : TestBxDF else { dg1_query_type dq = base_t::bxdf.ndf.template createDG1Query(base_t::isointer, isocache); - fresnel_type _f = bxdf::impl::getOrientedFresnel::__call(base_t::bxdf.fresnel, base_t::isointer.getNdotV()); + fresnel_type _f = base_t::bxdf_t::getOrientedFresnel(base_t::bxdf.fresnel, base_t::isointer.getNdotV()); quant_query_type qq = bxdf::impl::quant_query_helper::template __call(base_t::bxdf.ndf, _f, isocache); quant_type DG1 = base_t::bxdf.ndf.template DG1(dq, qq, s, base_t::isointer); dg1 = DG1.microfacetMeasure * hlsl::abs(isocache.getVdotH() / base_t::isointer.getNdotV()); diff --git a/66_HLSLBxDFTests/app_resources/tests_common.hlsl b/66_HLSLBxDFTests/app_resources/tests_common.hlsl index c0a8d9614..c1e8e319a 100644 --- a/66_HLSLBxDFTests/app_resources/tests_common.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests_common.hlsl @@ -81,6 +81,14 @@ bool checkEq(T a, T b, float32_t eps) return nbl::hlsl::all::Dimension> >(nbl::hlsl::max(_a / _b, _b / _a) <= hlsl::promote(1 + eps)); } +template<> +bool checkEq(float32_t a, float32_t b, float32_t eps) +{ + float32_t _a = hlsl::abs(a); + float32_t _b = hlsl::abs(b); + return nbl::hlsl::max(_a / _b, _b / _a) <= float32_t(1 + eps); +} + template bool checkLt(T a, T b) { diff --git a/66_HLSLBxDFTests/main.cpp b/66_HLSLBxDFTests/main.cpp index 472eaa05d..a03e6ab83 100644 --- a/66_HLSLBxDFTests/main.cpp +++ b/66_HLSLBxDFTests/main.cpp @@ -193,7 +193,7 @@ int main(int argc, char** argv) TestJacobian, true>::run(initparams, cb); TestJacobian, false>::run(initparams, cb); TestJacobian,true>::run(initparams, cb); - TestJacobian, false>::run(initparams, cb); + //TestJacobian, false>::run(initparams, cb); TestJacobian>::run(initparams, cb); TestJacobian>::run(initparams, cb); @@ -204,7 +204,7 @@ int main(int argc, char** argv) TestJacobian, true>::run(initparams, cb); TestJacobian, false>::run(initparams, cb); TestJacobian,true>::run(initparams, cb); - TestJacobian, false>::run(initparams, cb); + //TestJacobian, false>::run(initparams, cb); FOR_EACH_END @@ -223,7 +223,7 @@ int main(int argc, char** argv) TestReciprocity, true>::run(initparams, cb); TestReciprocity, false>::run(initparams, cb); TestReciprocity, true>::run(initparams, cb); - TestReciprocity, false>::run(initparams, cb); + //TestReciprocity, false>::run(initparams, cb); TestReciprocity>::run(initparams, cb); TestReciprocity>::run(initparams, cb); @@ -234,7 +234,7 @@ int main(int argc, char** argv) TestReciprocity, true>::run(initparams, cb); TestReciprocity, false>::run(initparams, cb); TestReciprocity, true>::run(initparams, cb); - TestReciprocity, false>::run(initparams, cb); + //TestReciprocity, false>::run(initparams, cb); FOR_EACH_END @@ -253,7 +253,7 @@ int main(int argc, char** argv) TestBucket, true>::run(initparams, cb); TestBucket, false>::run(initparams, cb); TestBucket, true>::run(initparams, cb); - TestBucket, false>::run(initparams, cb); + //TestBucket, false>::run(initparams, cb); TestBucket>::run(initparams, cb); TestBucket>::run(initparams, cb); @@ -261,7 +261,7 @@ int main(int argc, char** argv) TestBucket, true>::run(initparams, cb); TestBucket, false>::run(initparams, cb); TestBucket, true>::run(initparams, cb); - TestBucket, false>::run(initparams, cb); + //TestBucket, false>::run(initparams, cb); FOR_EACH_END @@ -282,7 +282,7 @@ int main(int argc, char** argv) TestChi2, true>::run(initparams, cb); TestChi2, false>::run(initparams, cb); TestChi2, true>::run(initparams, cb); - TestChi2, false>::run(initparams, cb); + //TestChi2, false>::run(initparams, cb); TestChi2>::run(initparams, cb); TestChi2>::run(initparams, cb); @@ -290,7 +290,7 @@ int main(int argc, char** argv) TestChi2, true>::run(initparams, cb); TestChi2, false>::run(initparams, cb); TestChi2, true>::run(initparams, cb); - TestChi2, false>::run(initparams, cb); + //TestChi2, false>::run(initparams, cb); FOR_EACH_END #if 0 @@ -338,22 +338,35 @@ int main(int argc, char** argv) // test arccos angle sums { Xoroshiro64Star rng = Xoroshiro64Star::construct(uint32_t2(4, 2)); + math::sincos_accumulator angle_adder; + + auto Sin = [&](const float cosA) -> float + { + return nbl::hlsl::sqrt(1.f - cosA * cosA); + }; + for (uint32_t i = 0; i < 10; i++) { - const float a = rng() * numbers::pi; - const float b = rng() * numbers::pi; - const float c = rng() * numbers::pi; - const float d = rng() * numbers::pi; + const float a = ConvertToFloat01::__call(rng()) * 2.f - 1.f; + const float b = ConvertToFloat01::__call(rng()) * 2.f - 1.f; + const float c = ConvertToFloat01::__call(rng()) * 2.f - 1.f; + const float d = ConvertToFloat01::__call(rng()) * 2.f - 1.f; const float exAB = acos(a) + acos(b); - float res = math::getSumofArccosAB(a, b); - if (res != exAB) - fprintf(stderr, "[ERROR] math::getSumofArccosAB failed! expected %f, got %f\n", exAB, res); + angle_adder = math::sincos_accumulator::create(a, Sin(a)); + angle_adder.addCosine(b, Sin(b)); + float res = angle_adder.getSumofArccos(); + if (!checkEq(res, exAB, 1e-3)) + fprintf(stderr, "[ERROR] angle adding (2 angles) failed! expected %f, got %f\n", exAB, res); const float exABCD = exAB + acos(c) + acos(d); - res = math::getSumofArccosABCD(a, b, c, d); - if (res != exABCD) - fprintf(stderr, "[ERROR] math::getSumofArccosABCD failed! expected %f, got %f\n", exABCD, res); + angle_adder = math::sincos_accumulator::create(a, Sin(a)); + angle_adder.addCosine(b, Sin(b)); + angle_adder.addCosine(c, Sin(c)); + angle_adder.addCosine(d, Sin(d)); + res = angle_adder.getSumofArccos(); + if (!checkEq(res, exABCD, 1e-3)) + fprintf(stderr, "[ERROR] angle adding (4 angles) failed! expected %f, got %f\n", exABCD, res); } } From 9d79107b8798f86b857ecb1f169cb6018d80b357 Mon Sep 17 00:00:00 2001 From: keptsecret Date: Thu, 6 Nov 2025 16:41:42 +0700 Subject: [PATCH 07/11] refactor new interaction template --- .../app_resources/test_compile.comp.hlsl | 4 +-- 66_HLSLBxDFTests/app_resources/tests.hlsl | 1 + .../app_resources/tests_common.hlsl | 34 ++++++++++++++----- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl index a98188277..16236ce63 100644 --- a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl @@ -8,14 +8,14 @@ using namespace nbl::hlsl; +using spectral_t = vector; using ray_dir_info_t = bxdf::ray_dir_info::SBasic; -using iso_interaction = bxdf::surface_interactions::SIsotropic; +using iso_interaction = bxdf::surface_interactions::SIsotropic; using aniso_interaction = bxdf::surface_interactions::SAnisotropic; using sample_t = bxdf::SLightSample; using iso_cache = bxdf::SIsotropicMicrofacetCache; using aniso_cache = bxdf::SAnisotropicMicrofacetCache; using quotient_pdf_t = sampling::quotient_and_pdf; -using spectral_t = vector; using iso_config_t = bxdf::SConfiguration; using aniso_config_t = bxdf::SConfiguration; diff --git a/66_HLSLBxDFTests/app_resources/tests.hlsl b/66_HLSLBxDFTests/app_resources/tests.hlsl index 9011aa2e5..62d65f1ad 100644 --- a/66_HLSLBxDFTests/app_resources/tests.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests.hlsl @@ -264,6 +264,7 @@ struct TestReciprocity : TestBxDF rec_s = sample_t::createFromTangentSpace(rec_localL, anisointer.getFromTangentSpace()); rec_isointer = iso_interaction_t::create(rec_V, base_t::rc.N); + rec_isointer.luminosityContributionHint = isointer.luminosityContributionHint; rec_anisointer = aniso_interaction_t::create(rec_isointer, base_t::rc.T, base_t::rc.B); rec_cache = cache; rec_cache.iso_cache.VdotH = cache.iso_cache.getLdotH(); diff --git a/66_HLSLBxDFTests/app_resources/tests_common.hlsl b/66_HLSLBxDFTests/app_resources/tests_common.hlsl index c1e8e319a..eff94bce9 100644 --- a/66_HLSLBxDFTests/app_resources/tests_common.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests_common.hlsl @@ -46,14 +46,14 @@ namespace nbl namespace hlsl { +using spectral_t = vector; using ray_dir_info_t = bxdf::ray_dir_info::SBasic; -using iso_interaction = bxdf::surface_interactions::SIsotropic; +using iso_interaction = bxdf::surface_interactions::SIsotropic; using aniso_interaction = bxdf::surface_interactions::SAnisotropic; using sample_t = bxdf::SLightSample; using iso_cache = bxdf::SIsotropicMicrofacetCache; using aniso_cache = bxdf::SAnisotropicMicrofacetCache; using quotient_pdf_t = sampling::quotient_and_pdf; -using spectral_t = vector; using iso_config_t = bxdf::SConfiguration; using aniso_config_t = bxdf::SConfiguration; @@ -192,6 +192,7 @@ struct TestBase rc = SBxDFTestResources::create(seed); isointer = iso_interaction::create(rc.V, rc.N); + isointer.luminosityContributionHint = rc.luma_coeff; anisointer = aniso_interaction::create(isointer, rc.T, rc.B); } @@ -449,34 +450,40 @@ struct TestBxDF> : TestBxD namespace reciprocity_test_impl { -template) +template && concepts::FloatingPointLikeVectorial) struct SIsotropic { + using this_t = SIsotropic; using ray_dir_info_type = RayDirInfo; using scalar_type = typename RayDirInfo::scalar_type; using vector3_type = typename RayDirInfo::vector3_type; + using spectral_type = Spectrum; // WARNING: Changed since GLSL, now arguments need to be normalized! - static SIsotropic create(NBL_CONST_REF_ARG(RayDirInfo) normalizedV, const vector3_type normalizedN) + static this_t create(NBL_CONST_REF_ARG(RayDirInfo) normalizedV, const vector3_type normalizedN) { - SIsotropic retval; + this_t retval; retval.V = normalizedV; retval.N = normalizedN; retval.NdotV = nbl::hlsl::dot(retval.N, retval.V.getDirection()); retval.NdotV2 = retval.NdotV * retval.NdotV; + retval.luminosityContributionHint = hlsl::promote(1.0); + retval.throughputWeights = hlsl::promote(1.0); return retval; } template) - static SIsotropic copy(NBL_CONST_REF_ARG(I) other) + static this_t copy(NBL_CONST_REF_ARG(I) other) { - SIsotropic retval; + this_t retval; retval.V = other.getV(); retval.N = other.getN(); retval.NdotV = other.getNdotV(); retval.NdotV2 = other.getNdotV2(); retval.pathOrigin = bxdf::PathOrigin::PO_SENSOR; + retval.luminosityContributionHint = other.luminosityContributionHint; + retval.throughputWeights = other.throughputWeights; return retval; } @@ -489,12 +496,20 @@ struct SIsotropic scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return NdotV2; } bxdf::PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return pathOrigin; } + spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return luminosityContributionHint; } + spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC + { + spectral_type prefixThroughputWeights = luminosityContributionHint * throughputWeights; + return prefixThroughputWeights / math::lpNorm(prefixThroughputWeights); + } RayDirInfo V; vector3_type N; scalar_type NdotV; scalar_type NdotV2; bxdf::PathOrigin pathOrigin; + spectral_type luminosityContributionHint; + spectral_type throughputWeights; // product of all quotients so far }; template) @@ -506,6 +521,7 @@ struct SAnisotropic using scalar_type = typename ray_dir_info_type::scalar_type; using vector3_type = typename ray_dir_info_type::vector3_type; using matrix3x3_type = matrix; + using spectral_type = typename isotropic_interaction_type::spectral_type; // WARNING: Changed since GLSL, now arguments need to be normalized! static this_t create( @@ -559,6 +575,8 @@ struct SAnisotropic scalar_type getNdotV(bxdf::BxDFClampMode _clamp = bxdf::BxDFClampMode::BCM_NONE) NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV(_clamp); } scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV2(); } bxdf::PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return isotropic.getPathOrigin(); } + spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return isotropic.getLuminosityContributionHint(); } + spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC { return isotropic.getPrefixThroughputWeights(); } vector3_type getT() NBL_CONST_MEMBER_FUNC { return T; } vector3_type getB() NBL_CONST_MEMBER_FUNC { return B; } @@ -607,7 +625,7 @@ struct CustomIsoMicrofacetConfiguration; +using rectest_iso_interaction = reciprocity_test_impl::SIsotropic; using rectest_aniso_interaction = reciprocity_test_impl::SAnisotropic; using rectest_iso_microfacet_config_t = reciprocity_test_impl::CustomIsoMicrofacetConfiguration; using rectest_aniso_microfacet_config_t = bxdf::SMicrofacetConfiguration; From a20e33d2b6d2c54bf44baeb8545d4fa0575ede12 Mon Sep 17 00:00:00 2001 From: keptsecret Date: Fri, 7 Nov 2025 16:17:08 +0700 Subject: [PATCH 08/11] enable tests for iridescent bxdf --- .../app_resources/test_compile.comp.hlsl | 8 ++-- .../app_resources/tests_common.hlsl | 38 ++++++++++++++++++- 66_HLSLBxDFTests/main.cpp | 18 ++++----- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl index 16236ce63..68fe8b633 100644 --- a/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_compile.comp.hlsl @@ -32,7 +32,7 @@ void main(uint32_t3 ID : SV_DispatchThreadID) bxdf::reflection::SBeckmannAnisotropic beckmannAnisoBRDF; bxdf::reflection::SGGXIsotropic ggxIsoBRDF; bxdf::reflection::SGGXAnisotropic ggxAnisoBRDF; - // bxdf::reflection::SIridescent iridBRDF; + bxdf::reflection::SIridescent iridBRDF; bxdf::transmission::SLambertian lambertianBSDF; bxdf::transmission::SOrenNayar orenNayarBSDF; @@ -78,10 +78,8 @@ void main(uint32_t3 ID : SV_DispatchThreadID) s = ggxAnisoBRDF.generate(anisointer, u.xy, cache); L += s.L.direction; - // iso_cache icache; - // typename bxdf::reflection::SIridescent::query_type query6 = iridBRDF.createQuery(s, isointer); - // qp = iridBRDF.quotient_and_pdf(query6, s, isointer, icache); - // L -= qp.quotient; + qp = iridBRDF.quotient_and_pdf(s, anisointer, cache); + L -= qp.quotient; qp = ggxAnisoBRDF.quotient_and_pdf(s, anisointer, cache); L -= qp.quotient; diff --git a/66_HLSLBxDFTests/app_resources/tests_common.hlsl b/66_HLSLBxDFTests/app_resources/tests_common.hlsl index eff94bce9..89d3bcf71 100644 --- a/66_HLSLBxDFTests/app_resources/tests_common.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests_common.hlsl @@ -139,6 +139,9 @@ struct SBxDFTestResources retval.alpha.y = ConvertToFloat01::__call(retval.rng()); retval.eta = ConvertToFloat01::__call(rng_vec2()) * hlsl::promote(1.5) + hlsl::promote(1.1); // range [1.1,2.6], also only do eta = eta/1.0 (air) retval.luma_coeff = float32_t3(0.2126, 0.7152, 0.0722); // luma coefficients for Rec. 709 + + retval.Dinc = ConvertToFloat01::__call(retval.rng()) * 2400.0f + 100.0f; + retval.etaThinFilm = ConvertToFloat01::__call(retval.rng()) * 0.5 + 1.1f; // range [1.1,1.6] return retval; } @@ -155,6 +158,10 @@ struct SBxDFTestResources float32_t2 alpha; float32_t2 eta; // (eta, etak) float32_t3 luma_coeff; + + // thin film stuff; + float Dinc; // in nm [100, 2500] + float etaThinFilm; }; struct STestInitParams @@ -324,6 +331,21 @@ struct TestBxDF> : } }; +template<> +struct TestBxDF> : TestBxDFBase> +{ + using base_t = TestBxDFBase>; + + void initBxDF(SBxDFTestResources _rc) + { + base_t::bxdf.ndf = base_t::bxdf_t::ndf_type::create(_rc.alpha.x); + base_t::bxdf.fresnel = base_t::bxdf_t::fresnel_type::create(_rc.Dinc,hlsl::promote(1.0),hlsl::promote(_rc.etaThinFilm),hlsl::promote(_rc.eta.x),hlsl::promote(_rc.eta.y)); +#ifndef __HLSL_VERSION + base_t::name = "Iridescent BRDF"; +#endif + } +}; + template<> struct TestBxDF> : TestBxDFBase> { @@ -363,7 +385,6 @@ struct TestBxDF> : TestB { using spectral_type = typename base_t::bxdf_t::spectral_type; base_t::bxdf.fresnel = bxdf::fresnel::Dielectric::create(bxdf::fresnel::OrientedEtas::create(base_t::isointer.getNdotV(bxdf::BxDFClampMode::BCM_ABS), hlsl::promote(_rc.eta.x))); - base_t::bxdf.luminosityContributionHint = _rc.luma_coeff; #ifndef __HLSL_VERSION base_t::name = "Thin smooth dielectric BSDF"; #endif @@ -447,6 +468,21 @@ struct TestBxDF> : TestBxD } }; +template +struct TestBxDF> : TestBxDFBase> +{ + using base_t = TestBxDFBase>; + + void initBxDF(SBxDFTestResources _rc) + { + base_t::bxdf.ndf = base_t::bxdf_t::ndf_type::create(_rc.alpha.x); + base_t::bxdf.fresnel = base_t::bxdf_t::fresnel_type::create(_rc.Dinc,hlsl::promote(1.0),hlsl::promote(_rc.etaThinFilm),hlsl::promote(_rc.eta.x)); +#ifndef __HLSL_VERSION + base_t::name = "Iridescent BSDF"; +#endif + } +}; + namespace reciprocity_test_impl { diff --git a/66_HLSLBxDFTests/main.cpp b/66_HLSLBxDFTests/main.cpp index a03e6ab83..876965875 100644 --- a/66_HLSLBxDFTests/main.cpp +++ b/66_HLSLBxDFTests/main.cpp @@ -193,7 +193,7 @@ int main(int argc, char** argv) TestJacobian, true>::run(initparams, cb); TestJacobian, false>::run(initparams, cb); TestJacobian,true>::run(initparams, cb); - //TestJacobian, false>::run(initparams, cb); + TestJacobian, false>::run(initparams, cb); TestJacobian>::run(initparams, cb); TestJacobian>::run(initparams, cb); @@ -204,7 +204,7 @@ int main(int argc, char** argv) TestJacobian, true>::run(initparams, cb); TestJacobian, false>::run(initparams, cb); TestJacobian,true>::run(initparams, cb); - //TestJacobian, false>::run(initparams, cb); + TestJacobian, false>::run(initparams, cb); FOR_EACH_END @@ -213,7 +213,7 @@ int main(int argc, char** argv) auto rReciprocity = std::ranges::views::iota(0u, runs); FOR_EACH_BEGIN(rReciprocity) STestInitParams initparams{ .logInfo = logInfo }; - initparams.state = 3; + initparams.state = i; initparams.verbose = testconfigs["TestReciprocity"]["verbose"]; TestReciprocity>::run(initparams, cb); @@ -223,7 +223,7 @@ int main(int argc, char** argv) TestReciprocity, true>::run(initparams, cb); TestReciprocity, false>::run(initparams, cb); TestReciprocity, true>::run(initparams, cb); - //TestReciprocity, false>::run(initparams, cb); + TestReciprocity, false>::run(initparams, cb); TestReciprocity>::run(initparams, cb); TestReciprocity>::run(initparams, cb); @@ -234,7 +234,7 @@ int main(int argc, char** argv) TestReciprocity, true>::run(initparams, cb); TestReciprocity, false>::run(initparams, cb); TestReciprocity, true>::run(initparams, cb); - //TestReciprocity, false>::run(initparams, cb); + //TestReciprocity, false>::run(initparams, cb); // viewing angle changes result? FOR_EACH_END @@ -253,7 +253,7 @@ int main(int argc, char** argv) TestBucket, true>::run(initparams, cb); TestBucket, false>::run(initparams, cb); TestBucket, true>::run(initparams, cb); - //TestBucket, false>::run(initparams, cb); + TestBucket, false>::run(initparams, cb); TestBucket>::run(initparams, cb); TestBucket>::run(initparams, cb); @@ -261,7 +261,7 @@ int main(int argc, char** argv) TestBucket, true>::run(initparams, cb); TestBucket, false>::run(initparams, cb); TestBucket, true>::run(initparams, cb); - //TestBucket, false>::run(initparams, cb); + TestBucket, false>::run(initparams, cb); FOR_EACH_END @@ -282,7 +282,7 @@ int main(int argc, char** argv) TestChi2, true>::run(initparams, cb); TestChi2, false>::run(initparams, cb); TestChi2, true>::run(initparams, cb); - //TestChi2, false>::run(initparams, cb); + TestChi2, false>::run(initparams, cb); TestChi2>::run(initparams, cb); TestChi2>::run(initparams, cb); @@ -290,7 +290,7 @@ int main(int argc, char** argv) TestChi2, true>::run(initparams, cb); TestChi2, false>::run(initparams, cb); TestChi2, true>::run(initparams, cb); - //TestChi2, false>::run(initparams, cb); + TestChi2, false>::run(initparams, cb); FOR_EACH_END #if 0 From a98036428817d40463d7f2f10f35d3968a0c73e1 Mon Sep 17 00:00:00 2001 From: keptsecret Date: Mon, 10 Nov 2025 12:14:52 +0700 Subject: [PATCH 09/11] refactor tests, remove todo comments --- 66_HLSLBxDFTests/app_resources/tests.hlsl | 2 -- .../app_resources/tests_common.hlsl | 29 ++++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/66_HLSLBxDFTests/app_resources/tests.hlsl b/66_HLSLBxDFTests/app_resources/tests.hlsl index 62d65f1ad..650449df5 100644 --- a/66_HLSLBxDFTests/app_resources/tests.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests.hlsl @@ -69,7 +69,6 @@ struct TestJacobian : TestBxDF if (!(s.isValid() && sx.isValid() && sy.isValid())) return BET_INVALID; - // TODO: add checks with need clamp trait if (traits_t::type == bxdf::BT_BRDF) { if (s.getNdotL() <= bit_cast(numeric_limits::min)) @@ -245,7 +244,6 @@ struct TestReciprocity : TestBxDF if (!s.isValid()) return BET_INVALID; - // TODO: add checks with need clamp trait if (bxdf::traits::type == bxdf::BT_BRDF) { if (s.getNdotL() <= bit_cast(numeric_limits::min)) diff --git a/66_HLSLBxDFTests/app_resources/tests_common.hlsl b/66_HLSLBxDFTests/app_resources/tests_common.hlsl index 89d3bcf71..9de407e39 100644 --- a/66_HLSLBxDFTests/app_resources/tests_common.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests_common.hlsl @@ -118,12 +118,9 @@ struct SBxDFTestResources retval.u = ConvertToFloat01::__call(rng_vec3()); retval.u.x = hlsl::clamp(retval.u.x, retval.eps, 1.f-retval.eps); retval.u.y = hlsl::clamp(retval.u.y, retval.eps, 1.f-retval.eps); - // retval.u.z = 0.0; retval.V.direction = nbl::hlsl::normalize(sampling::UniformSphere::generate(ConvertToFloat01::__call(rng_vec2()))); retval.N = nbl::hlsl::normalize(sampling::UniformSphere::generate(ConvertToFloat01::__call(rng_vec2()))); - // if (hlsl::dot(retval.N, retval.V.direction) < 0) - // retval.V.direction = -retval.V.direction; float32_t3 tangent, bitangent; math::frisvad(retval.N, tangent, bitangent); @@ -339,7 +336,14 @@ struct TestBxDF> : TestBx void initBxDF(SBxDFTestResources _rc) { base_t::bxdf.ndf = base_t::bxdf_t::ndf_type::create(_rc.alpha.x); - base_t::bxdf.fresnel = base_t::bxdf_t::fresnel_type::create(_rc.Dinc,hlsl::promote(1.0),hlsl::promote(_rc.etaThinFilm),hlsl::promote(_rc.eta.x),hlsl::promote(_rc.eta.y)); + using fresnel_params_t = base_t::bxdf_t::fresnel_type::creation_params_type; + fresnel_params_t params; + params.Dinc = _rc.Dinc; + params.ior1 = hlsl::promote(1.0); + params.ior2 = hlsl::promote(_rc.etaThinFilm); + params.ior3 = hlsl::promote(_rc.eta.x); + params.iork3 = hlsl::promote(_rc.eta.y); + base_t::bxdf.fresnel = base_t::bxdf_t::fresnel_type::create(params); #ifndef __HLSL_VERSION base_t::name = "Iridescent BRDF"; #endif @@ -476,7 +480,13 @@ struct TestBxDF> : TestBxDFBase(1.0),hlsl::promote(_rc.etaThinFilm),hlsl::promote(_rc.eta.x)); + using fresnel_params_t = base_t::bxdf_t::fresnel_type::creation_params_type; + fresnel_params_t params; + params.Dinc = _rc.Dinc; + params.ior1 = hlsl::promote(1.0); + params.ior2 = hlsl::promote(_rc.etaThinFilm); + params.ior3 = hlsl::promote(_rc.eta.x); + base_t::bxdf.fresnel = base_t::bxdf_t::fresnel_type::create(params); #ifndef __HLSL_VERSION base_t::name = "Iridescent BSDF"; #endif @@ -504,7 +514,6 @@ struct SIsotropic retval.NdotV = nbl::hlsl::dot(retval.N, retval.V.getDirection()); retval.NdotV2 = retval.NdotV * retval.NdotV; retval.luminosityContributionHint = hlsl::promote(1.0); - retval.throughputWeights = hlsl::promote(1.0); return retval; } @@ -519,7 +528,6 @@ struct SIsotropic retval.NdotV2 = other.getNdotV2(); retval.pathOrigin = bxdf::PathOrigin::PO_SENSOR; retval.luminosityContributionHint = other.luminosityContributionHint; - retval.throughputWeights = other.throughputWeights; return retval; } @@ -533,11 +541,6 @@ struct SIsotropic bxdf::PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return pathOrigin; } spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return luminosityContributionHint; } - spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC - { - spectral_type prefixThroughputWeights = luminosityContributionHint * throughputWeights; - return prefixThroughputWeights / math::lpNorm(prefixThroughputWeights); - } RayDirInfo V; vector3_type N; @@ -545,7 +548,6 @@ struct SIsotropic scalar_type NdotV2; bxdf::PathOrigin pathOrigin; spectral_type luminosityContributionHint; - spectral_type throughputWeights; // product of all quotients so far }; template) @@ -612,7 +614,6 @@ struct SAnisotropic scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV2(); } bxdf::PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return isotropic.getPathOrigin(); } spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return isotropic.getLuminosityContributionHint(); } - spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC { return isotropic.getPrefixThroughputWeights(); } vector3_type getT() NBL_CONST_MEMBER_FUNC { return T; } vector3_type getB() NBL_CONST_MEMBER_FUNC { return B; } From 1e1a008efb143870649a89dbde8019717c4b410f Mon Sep 17 00:00:00 2001 From: keptsecret Date: Tue, 11 Nov 2025 15:49:21 +0700 Subject: [PATCH 10/11] refactor tests, enable all of them --- .../app_resources/test_components.hlsl | 16 ++++++---- .../app_resources/tests_common.hlsl | 31 ++++++++++--------- 66_HLSLBxDFTests/main.cpp | 13 +++----- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/66_HLSLBxDFTests/app_resources/test_components.hlsl b/66_HLSLBxDFTests/app_resources/test_components.hlsl index cd2aa5cb6..7938b8a31 100644 --- a/66_HLSLBxDFTests/app_resources/test_components.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_components.hlsl @@ -87,12 +87,13 @@ struct TestNDF : TestBxDF float reflectance; bool transmitted; + bool isNdfInfinity; NBL_IF_CONSTEXPR(aniso) { dg1_query_type dq = base_t::bxdf.ndf.template createDG1Query(base_t::anisointer, cache); - fresnel_type _f = base_t::bxdf_t::getOrientedFresnel(base_t::bxdf.fresnel, base_t::anisointer.getNdotV()); - quant_query_type qq = bxdf::impl::quant_query_helper::template __call(base_t::bxdf.ndf, _f, cache); - quant_type DG1 = base_t::bxdf.ndf.template DG1(dq, qq, s, base_t::anisointer); + fresnel_type _f = base_t::bxdf_t::__getOrientedFresnel(base_t::bxdf.fresnel, base_t::anisointer.getNdotV()); + quant_query_type qq = bxdf::impl::quant_query_helper::template __call(base_t::bxdf.ndf, _f, base_t::anisointer, cache); + quant_type DG1 = base_t::bxdf.ndf.template DG1(dq, qq, s, base_t::anisointer, isNdfInfinity); dg1 = DG1.microfacetMeasure * hlsl::abs(cache.getVdotH() / base_t::anisointer.getNdotV()); reflectance = _f(cache.getVdotH())[0]; NdotH = cache.getAbsNdotH(); @@ -101,15 +102,18 @@ struct TestNDF : TestBxDF else { dg1_query_type dq = base_t::bxdf.ndf.template createDG1Query(base_t::isointer, isocache); - fresnel_type _f = base_t::bxdf_t::getOrientedFresnel(base_t::bxdf.fresnel, base_t::isointer.getNdotV()); - quant_query_type qq = bxdf::impl::quant_query_helper::template __call(base_t::bxdf.ndf, _f, isocache); - quant_type DG1 = base_t::bxdf.ndf.template DG1(dq, qq, s, base_t::isointer); + fresnel_type _f = base_t::bxdf_t::__getOrientedFresnel(base_t::bxdf.fresnel, base_t::isointer.getNdotV()); + quant_query_type qq = bxdf::impl::quant_query_helper::template __call(base_t::bxdf.ndf, _f, base_t::isointer, isocache); + quant_type DG1 = base_t::bxdf.ndf.template DG1(dq, qq, s, base_t::isointer, isNdfInfinity); dg1 = DG1.microfacetMeasure * hlsl::abs(isocache.getVdotH() / base_t::isointer.getNdotV()); reflectance = _f(isocache.getVdotH())[0]; NdotH = isocache.getAbsNdotH(); transmitted = isocache.isTransmission(); } + if (isNdfInfinity) + return BET_INVALID; + if (transmitted) { float eta = base_t::rc.eta.x; diff --git a/66_HLSLBxDFTests/app_resources/tests_common.hlsl b/66_HLSLBxDFTests/app_resources/tests_common.hlsl index 9de407e39..eca63a7f8 100644 --- a/66_HLSLBxDFTests/app_resources/tests_common.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests_common.hlsl @@ -336,14 +336,14 @@ struct TestBxDF> : TestBx void initBxDF(SBxDFTestResources _rc) { base_t::bxdf.ndf = base_t::bxdf_t::ndf_type::create(_rc.alpha.x); - using fresnel_params_t = base_t::bxdf_t::fresnel_type::creation_params_type; - fresnel_params_t params; - params.Dinc = _rc.Dinc; - params.ior1 = hlsl::promote(1.0); - params.ior2 = hlsl::promote(_rc.etaThinFilm); - params.ior3 = hlsl::promote(_rc.eta.x); - params.iork3 = hlsl::promote(_rc.eta.y); - base_t::bxdf.fresnel = base_t::bxdf_t::fresnel_type::create(params); + using fresnel_base_t = base_t::bxdf_t::fresnel_type::base_type; + fresnel_base_t base; + base.Dinc = _rc.Dinc; + base.thinFilmIor = hlsl::promote(_rc.etaThinFilm); + base.eta12 = hlsl::promote(_rc.etaThinFilm) / hlsl::promote(1.0); + base.eta23 = hlsl::promote(_rc.eta.x) / hlsl::promote(_rc.etaThinFilm); + base.etak23 = hlsl::promote(_rc.eta.y) / hlsl::promote(_rc.etaThinFilm); + base_t::bxdf.fresnel.__base = base; #ifndef __HLSL_VERSION base_t::name = "Iridescent BRDF"; #endif @@ -480,13 +480,14 @@ struct TestBxDF> : TestBxDFBase(1.0); - params.ior2 = hlsl::promote(_rc.etaThinFilm); - params.ior3 = hlsl::promote(_rc.eta.x); - base_t::bxdf.fresnel = base_t::bxdf_t::fresnel_type::create(params); + using fresnel_base_t = base_t::bxdf_t::fresnel_type::base_type; + fresnel_base_t base; + base.Dinc = _rc.Dinc; + base.thinFilmIor = hlsl::promote(_rc.etaThinFilm); + base.eta12 = hlsl::promote(_rc.etaThinFilm) / hlsl::promote(1.0); + base.eta23 = hlsl::promote(_rc.eta.x) / hlsl::promote(_rc.etaThinFilm); + base.etak23 = hlsl::promote(0.0); + base_t::bxdf.fresnel.__base = base; #ifndef __HLSL_VERSION base_t::name = "Iridescent BSDF"; #endif diff --git a/66_HLSLBxDFTests/main.cpp b/66_HLSLBxDFTests/main.cpp index 876965875..1b06fb0f6 100644 --- a/66_HLSLBxDFTests/main.cpp +++ b/66_HLSLBxDFTests/main.cpp @@ -293,7 +293,6 @@ int main(int argc, char** argv) TestChi2, false>::run(initparams, cb); FOR_EACH_END -#if 0 // testing ndf jacobian * dg1, ONLY for cook torrance bxdfs runs = testconfigs["TestNDF"]["runs"]; auto rNdf = std::ranges::views::iota(0u, runs); @@ -312,8 +311,7 @@ int main(int argc, char** argv) TestNDF, false>::run(initparams, cb); TestNDF, true>::run(initparams, cb); FOR_EACH_END -#endif -#if 0 + // test generated H that NdotV*VdotH>=0.0, VdotL calculation runs = testconfigs["TestCTGenerateH"]["runs"]; auto rGenerateH = std::ranges::views::iota(0u, runs); @@ -333,7 +331,6 @@ int main(int argc, char** argv) TestCTGenerateH, false>::run(initparams, cb); TestCTGenerateH, true>::run(initparams, cb); FOR_EACH_END -#endif // test arccos angle sums { @@ -354,16 +351,16 @@ int main(int argc, char** argv) const float exAB = acos(a) + acos(b); angle_adder = math::sincos_accumulator::create(a, Sin(a)); - angle_adder.addCosine(b, Sin(b)); + angle_adder.addAngle(b, Sin(b)); float res = angle_adder.getSumofArccos(); if (!checkEq(res, exAB, 1e-3)) fprintf(stderr, "[ERROR] angle adding (2 angles) failed! expected %f, got %f\n", exAB, res); const float exABCD = exAB + acos(c) + acos(d); angle_adder = math::sincos_accumulator::create(a, Sin(a)); - angle_adder.addCosine(b, Sin(b)); - angle_adder.addCosine(c, Sin(c)); - angle_adder.addCosine(d, Sin(d)); + angle_adder.addAngle(b, Sin(b)); + angle_adder.addAngle(c, Sin(c)); + angle_adder.addAngle(d, Sin(d)); res = angle_adder.getSumofArccos(); if (!checkEq(res, exABCD, 1e-3)) fprintf(stderr, "[ERROR] angle adding (4 angles) failed! expected %f, got %f\n", exABCD, res); From 6d0a3fe49997a1157e39483e0ec42e32f562e157 Mon Sep 17 00:00:00 2001 From: keptsecret Date: Tue, 11 Nov 2025 16:34:35 +0700 Subject: [PATCH 11/11] move example from nbl::hlsl namespace, minor fixes --- .../app_resources/test_components.hlsl | 22 ++++------ 66_HLSLBxDFTests/app_resources/tests.hlsl | 40 ++++++++----------- .../app_resources/tests_common.hlsl | 35 +++++++--------- 66_HLSLBxDFTests/main.cpp | 32 +++++++-------- 4 files changed, 54 insertions(+), 75 deletions(-) diff --git a/66_HLSLBxDFTests/app_resources/test_components.hlsl b/66_HLSLBxDFTests/app_resources/test_components.hlsl index 7938b8a31..a2db7ef53 100644 --- a/66_HLSLBxDFTests/app_resources/test_components.hlsl +++ b/66_HLSLBxDFTests/app_resources/test_components.hlsl @@ -3,11 +3,6 @@ #include "tests_common.hlsl" -namespace nbl -{ -namespace hlsl -{ - template // only for cook torrance bxdfs struct TestNDF : TestBxDF { @@ -75,7 +70,7 @@ struct TestNDF : TestBxDF } else if (traits_t::type == bxdf::BT_BSDF) { - if (abs(s.getNdotL()) <= bit_cast(numeric_limits::min)) + if (hlsl::abs(s.getNdotL()) <= bit_cast(numeric_limits::min)) return BET_INVALID; } @@ -152,7 +147,7 @@ struct TestNDF : TestBxDF } else if (traits_t::type == bxdf::BT_BSDF) { - if (abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) + if (hlsl::abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) return BET_INVALID; } @@ -185,13 +180,13 @@ struct TestNDF : TestBxDF static void run(NBL_CONST_REF_ARG(STestInitParams) initparams, NBL_REF_ARG(FailureCallback) cb) { - random::PCG32 pcg = random::PCG32::construct(initparams.state); + random::PCG32 pcg = random::PCG32::construct(initparams.halfSeed); random::DimAdaptorRecursive rand2d = random::DimAdaptorRecursive::construct(pcg); uint32_t2 state = rand2d(); this_t t; t.init(state); - t.rc.state = initparams.state; + t.rc.halfSeed = initparams.halfSeed; t.verbose = initparams.verbose; t.initBxDF(t.rc); @@ -326,7 +321,7 @@ struct TestCTGenerateH : TestBxDF if (base_t::isointer.getNdotV() <= numeric_limits::min) return BET_INVALID; else if (traits_t::type == bxdf::BT_BSDF) - if (abs(base_t::isointer.getNdotV()) <= numeric_limits::min) + if (hlsl::abs(base_t::isointer.getNdotV()) <= numeric_limits::min) return BET_INVALID; ErrorType res = compute(); @@ -338,13 +333,13 @@ struct TestCTGenerateH : TestBxDF static void run(NBL_CONST_REF_ARG(STestInitParams) initparams, NBL_REF_ARG(FailureCallback) cb) { - random::PCG32 pcg = random::PCG32::construct(initparams.state); + random::PCG32 pcg = random::PCG32::construct(initparams.halfSeed); random::DimAdaptorRecursive rand2d = random::DimAdaptorRecursive::construct(pcg); uint32_t2 state = rand2d(); this_t t; t.init(state); - t.rc.state = initparams.state; + t.rc.halfSeed = initparams.halfSeed; t.numSamples = initparams.samples; t.immediateFail = initparams.immediateFail; t.initBxDF(t.rc); @@ -380,7 +375,4 @@ struct TestCTGenerateH : TestBxDF }; #endif -} -} - #endif \ No newline at end of file diff --git a/66_HLSLBxDFTests/app_resources/tests.hlsl b/66_HLSLBxDFTests/app_resources/tests.hlsl index 650449df5..8f26bc4ee 100644 --- a/66_HLSLBxDFTests/app_resources/tests.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests.hlsl @@ -3,11 +3,6 @@ #include "tests_common.hlsl" -namespace nbl -{ -namespace hlsl -{ - template struct TestJacobian : TestBxDF { @@ -76,7 +71,7 @@ struct TestJacobian : TestBxDF } else if (traits_t::type == bxdf::BT_BSDF) { - if (abs(s.getNdotL()) <= bit_cast(numeric_limits::min)) + if (hlsl::abs(s.getNdotL()) <= bit_cast(numeric_limits::min)) return BET_INVALID; } @@ -114,7 +109,7 @@ struct TestJacobian : TestBxDF } else if (traits_t::type == bxdf::BT_BSDF) { - if (abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) + if (hlsl::abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) return BET_INVALID; } @@ -162,13 +157,13 @@ struct TestJacobian : TestBxDF static void run(NBL_CONST_REF_ARG(STestInitParams) initparams, NBL_REF_ARG(FailureCallback) cb) { - random::PCG32 pcg = random::PCG32::construct(initparams.state); + random::PCG32 pcg = random::PCG32::construct(initparams.halfSeed); random::DimAdaptorRecursive rand2d = random::DimAdaptorRecursive::construct(pcg); uint32_t2 state = rand2d(); this_t t; t.init(state); - t.rc.state = initparams.state; + t.rc.halfSeed = initparams.halfSeed; t.verbose = initparams.verbose; t.initBxDF(t.rc); @@ -251,7 +246,7 @@ struct TestReciprocity : TestBxDF } else if (bxdf::traits::type == bxdf::BT_BSDF) { - if (abs(s.getNdotL()) <= bit_cast(numeric_limits::min)) + if (hlsl::abs(s.getNdotL()) <= bit_cast(numeric_limits::min)) return BET_INVALID; } @@ -329,7 +324,7 @@ struct TestReciprocity : TestBxDF } else if (traits_t::type == bxdf::BT_BSDF) { - if (abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) + if (hlsl::abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) return BET_INVALID; } @@ -362,13 +357,13 @@ struct TestReciprocity : TestBxDF static void run(NBL_CONST_REF_ARG(STestInitParams) initparams, NBL_REF_ARG(FailureCallback) cb) { - random::PCG32 pcg = random::PCG32::construct(initparams.state); + random::PCG32 pcg = random::PCG32::construct(initparams.halfSeed); random::DimAdaptorRecursive rand2d = random::DimAdaptorRecursive::construct(pcg); uint32_t2 state = rand2d(); this_t t; t.init(state); - t.rc.state = initparams.state; + t.rc.halfSeed = initparams.halfSeed; t.verbose = initparams.verbose; t.initBxDF(t.rc); @@ -516,7 +511,7 @@ struct TestBucket : TestBxDF } else if (traits_t::type == bxdf::BT_BSDF) { - if (abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) + if (hlsl::abs(base_t::isointer.getNdotV()) <= bit_cast(numeric_limits::min)) return BET_INVALID; } @@ -529,13 +524,13 @@ struct TestBucket : TestBxDF static void run(NBL_CONST_REF_ARG(STestInitParams) initparams, NBL_REF_ARG(FailureCallback) cb) { - random::PCG32 pcg = random::PCG32::construct(initparams.state); + random::PCG32 pcg = random::PCG32::construct(initparams.halfSeed); random::DimAdaptorRecursive rand2d = random::DimAdaptorRecursive::construct(pcg); uint32_t2 state = rand2d(); this_t t; t.init(state); - t.rc.state = initparams.state; + t.rc.halfSeed = initparams.halfSeed; t.numSamples = initparams.samples; t.initBxDF(t.rc); @@ -734,7 +729,7 @@ struct TestChi2 : TestBxDF void writeToEXR() { - std::string filename = std::format("chi2test_{}_{}.exr", base_t::rc.state, base_t::name); + std::string filename = std::format("chi2test_{}_{}.exr", base_t::rc.halfSeed, base_t::name); int totalWidth = phiSplits; int totalHeight = 2 * thetaSplits + 1; @@ -868,7 +863,7 @@ struct TestChi2 : TestBxDF cache.iso_cache.absNdotH = hlsl::abs(hlsl::dot(N, H)); cache.iso_cache.NdotH2 = cache.iso_cache.absNdotH * cache.iso_cache.absNdotH; - if (!cache.isValid(bxdf::fresnel::OrientedEtas >::create(1.f, hlsl::promote >(eta)))) + if (!cache.isValid(bxdf::fresnel::OrientedEtas >::create(1.f, hlsl::promote >(eta)))) return 0.f; const float32_t3 T = base_t::anisointer.getT(); @@ -910,7 +905,7 @@ struct TestChi2 : TestBxDF if (base_t::isointer.getNdotV() <= numeric_limits::min) return BET_INVALID; else if (traits_t::type == bxdf::BT_BSDF) - if (abs(base_t::isointer.getNdotV()) <= numeric_limits::min) + if (hlsl::abs(base_t::isointer.getNdotV()) <= numeric_limits::min) return BET_INVALID; ErrorType res = compute(); @@ -993,13 +988,13 @@ struct TestChi2 : TestBxDF static void run(NBL_CONST_REF_ARG(STestInitParams) initparams, NBL_REF_ARG(FailureCallback) cb) { - random::PCG32 pcg = random::PCG32::construct(initparams.state); + random::PCG32 pcg = random::PCG32::construct(initparams.halfSeed); random::DimAdaptorRecursive rand2d = random::DimAdaptorRecursive::construct(pcg); uint32_t2 state = rand2d(); this_t t; t.init(state); - t.rc.state = initparams.state; + t.rc.halfSeed = initparams.halfSeed; t.numSamples = initparams.samples; t.thetaSplits = initparams.thetaSplits; t.phiSplits = initparams.phiSplits; @@ -1033,7 +1028,4 @@ struct TestChi2 : TestBxDF }; #endif -} -} - #endif \ No newline at end of file diff --git a/66_HLSLBxDFTests/app_resources/tests_common.hlsl b/66_HLSLBxDFTests/app_resources/tests_common.hlsl index eca63a7f8..f15451fce 100644 --- a/66_HLSLBxDFTests/app_resources/tests_common.hlsl +++ b/66_HLSLBxDFTests/app_resources/tests_common.hlsl @@ -41,12 +41,10 @@ using namespace IMATH; using json = nlohmann::json; #endif -namespace nbl -{ -namespace hlsl -{ +using namespace nbl; +using namespace hlsl; -using spectral_t = vector; +using spectral_t = hlsl::vector; using ray_dir_info_t = bxdf::ray_dir_info::SBasic; using iso_interaction = bxdf::surface_interactions::SIsotropic; using aniso_interaction = bxdf::surface_interactions::SAnisotropic; @@ -60,12 +58,12 @@ using aniso_config_t = bxdf::SConfiguration; using aniso_microfacet_config_t = bxdf::SMicrofacetConfiguration; -using bool32_t3 = vector; +using bool32_t3 = hlsl::vector; template struct ConvertToFloat01 { - using ret_t = conditional_t::Dimension==1, float, vector::Dimension> >; + using ret_t = conditional_t::Dimension==1, float, hlsl::vector::Dimension> >; static ret_t __call(T x) { @@ -78,7 +76,7 @@ bool checkEq(T a, T b, float32_t eps) { T _a = hlsl::abs(a); T _b = hlsl::abs(b); - return nbl::hlsl::all::Dimension> >(nbl::hlsl::max(_a / _b, _b / _a) <= hlsl::promote(1 + eps)); + return nbl::hlsl::all::Dimension> >(nbl::hlsl::max(_a / _b, _b / _a) <= hlsl::promote(1 + eps)); } template<> @@ -92,13 +90,13 @@ bool checkEq(float32_t a, float32_t b, float32_t eps) template bool checkLt(T a, T b) { - return nbl::hlsl::all::Dimension> >(a < b); + return nbl::hlsl::all::Dimension> >(a < b); } template bool checkZero(T a, float32_t eps) { - return nbl::hlsl::all::Dimension> >(nbl::hlsl::abs(a) < hlsl::promote(eps)); + return nbl::hlsl::all::Dimension> >(nbl::hlsl::abs(a) < hlsl::promote(eps)); } template<> @@ -143,7 +141,7 @@ struct SBxDFTestResources } float eps = 1e-3; // epsilon - uint32_t state; // init state seed, for debugging + uint32_t halfSeed; // init state seed, for debugging nbl::hlsl::Xoroshiro64Star rng; ray_dir_info_t V; @@ -164,7 +162,7 @@ struct SBxDFTestResources struct STestInitParams { bool logInfo; - uint32_t state; + uint32_t halfSeed; uint32_t samples; uint32_t thetaSplits; uint32_t phiSplits; @@ -559,7 +557,7 @@ struct SAnisotropic using ray_dir_info_type = typename isotropic_interaction_type::ray_dir_info_type; using scalar_type = typename ray_dir_info_type::scalar_type; using vector3_type = typename ray_dir_info_type::vector3_type; - using matrix3x3_type = matrix; + using matrix3x3_type = hlsl::matrix; using spectral_type = typename isotropic_interaction_type::spectral_type; // WARNING: Changed since GLSL, now arguments need to be normalized! @@ -649,10 +647,10 @@ struct CustomIsoMicrofacetConfiguration; - using vector3_type = vector; - using monochrome_type = vector; - using matrix3x3_type = matrix; + using vector2_type = hlsl::vector; + using vector3_type = hlsl::vector; + using monochrome_type = hlsl::vector; + using matrix3x3_type = hlsl::matrix; using isotropic_interaction_type = Interaction; using anisotropic_interaction_type = reciprocity_test_impl::SAnisotropic; using sample_type = LS; @@ -668,7 +666,4 @@ using rectest_aniso_interaction = reciprocity_test_impl::SAnisotropic; using rectest_aniso_microfacet_config_t = bxdf::SMicrofacetConfiguration; -} -} - #endif diff --git a/66_HLSLBxDFTests/main.cpp b/66_HLSLBxDFTests/main.cpp index 1b06fb0f6..8989cfe1e 100644 --- a/66_HLSLBxDFTests/main.cpp +++ b/66_HLSLBxDFTests/main.cpp @@ -33,34 +33,34 @@ struct PrintFailureCallback : FailureCallback { case BET_INVALID: if (logInfo) - fprintf(stderr, "[INFO] seed %u: %s skipping test due to invalid NdotV/NdotL config\n", failedFor.rc.state, failedFor.name.c_str()); + fprintf(stderr, "[INFO] seed %u: %s skipping test due to invalid NdotV/NdotL config\n", failedFor.rc.halfSeed, failedFor.name.c_str()); break; case BET_NEGATIVE_VAL: - fprintf(stderr, "[ERROR] seed %u: %s pdf/quotient/eval < 0\n", failedFor.rc.state, failedFor.name.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s pdf/quotient/eval < 0\n", failedFor.rc.halfSeed, failedFor.name.c_str()); break; case BET_PDF_ZERO: - fprintf(stderr, "[ERROR] seed %u: %s pdf = 0\n", failedFor.rc.state, failedFor.name.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s pdf = 0\n", failedFor.rc.halfSeed, failedFor.name.c_str()); break; case BET_QUOTIENT_INF: - fprintf(stderr, "[ERROR] seed %u: %s quotient -> inf\n", failedFor.rc.state, failedFor.name.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s quotient -> inf\n", failedFor.rc.halfSeed, failedFor.name.c_str()); break; case BET_JACOBIAN: - fprintf(stderr, "[ERROR] seed %u: %s failed the jacobian * pdf test %s\n", failedFor.rc.state, failedFor.name.c_str(), failedFor.errMsg.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s failed the jacobian * pdf test %s\n", failedFor.rc.halfSeed, failedFor.name.c_str(), failedFor.errMsg.c_str()); break; case BET_PDF_EVAL_DIFF: - fprintf(stderr, "[ERROR] seed %u: %s quotient * pdf != eval %s\n", failedFor.rc.state, failedFor.name.c_str(), failedFor.errMsg.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s quotient * pdf != eval %s\n", failedFor.rc.halfSeed, failedFor.name.c_str(), failedFor.errMsg.c_str()); break; case BET_RECIPROCITY: - fprintf(stderr, "[ERROR] seed %u: %s failed the reciprocity test %s\n", failedFor.rc.state, failedFor.name.c_str(), failedFor.errMsg.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s failed the reciprocity test %s\n", failedFor.rc.halfSeed, failedFor.name.c_str(), failedFor.errMsg.c_str()); break; case BET_PRINT_MSG: - fprintf(stderr, "[ERROR] seed %u: %s error message\n%s\n", failedFor.rc.state, failedFor.name.c_str(), failedFor.errMsg.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s error message\n%s\n", failedFor.rc.halfSeed, failedFor.name.c_str(), failedFor.errMsg.c_str()); break; case BET_GENERATE_H: - fprintf(stderr, "[ERROR] seed %u: %s failed invalid H configuration generated %s\n", failedFor.rc.state, failedFor.name.c_str(), failedFor.errMsg.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s failed invalid H configuration generated %s\n", failedFor.rc.halfSeed, failedFor.name.c_str(), failedFor.errMsg.c_str()); break; default: - fprintf(stderr, "[ERROR] seed %u: %s unknown error\n", failedFor.rc.state, failedFor.name.c_str()); + fprintf(stderr, "[ERROR] seed %u: %s unknown error\n", failedFor.rc.halfSeed, failedFor.name.c_str()); } #ifdef _NBL_DEBUG @@ -183,7 +183,7 @@ int main(int argc, char** argv) auto rJacobian = std::ranges::views::iota(0u, runs); FOR_EACH_BEGIN(rJacobian) STestInitParams initparams{ .logInfo = logInfo }; - initparams.state = i; + initparams.halfSeed = i; initparams.verbose = testconfigs["TestJacobian"]["verbose"]; TestJacobian>::run(initparams, cb); @@ -213,7 +213,7 @@ int main(int argc, char** argv) auto rReciprocity = std::ranges::views::iota(0u, runs); FOR_EACH_BEGIN(rReciprocity) STestInitParams initparams{ .logInfo = logInfo }; - initparams.state = i; + initparams.halfSeed = i; initparams.verbose = testconfigs["TestReciprocity"]["verbose"]; TestReciprocity>::run(initparams, cb); @@ -244,7 +244,7 @@ int main(int argc, char** argv) auto rBucket = std::ranges::views::iota(0u, runs); FOR_EACH_BEGIN(rBucket) STestInitParams initparams{ .logInfo = logInfo }; - initparams.state = i; + initparams.halfSeed = i; initparams.samples = testconfigs["TestBucket"]["samples"]; TestBucket>::run(initparams, cb); @@ -270,7 +270,7 @@ int main(int argc, char** argv) auto rChi2 = std::ranges::views::iota(0u, runs); FOR_EACH_BEGIN_EX(rChi2, std::execution::par_unseq) STestInitParams initparams{ .logInfo = logInfo }; - initparams.state = i; + initparams.halfSeed = i; initparams.samples = testconfigs["TestChi2"]["samples"]; initparams.thetaSplits = testconfigs["TestChi2"]["thetaSplits"]; initparams.phiSplits = testconfigs["TestChi2"]["phiSplits"]; @@ -298,7 +298,7 @@ int main(int argc, char** argv) auto rNdf = std::ranges::views::iota(0u, runs); FOR_EACH_BEGIN(rNdf) STestInitParams initparams{ .logInfo = logInfo }; - initparams.state = i; + initparams.halfSeed = i; initparams.verbose = testconfigs["TestNDF"]["verbose"]; TestNDF, false>::run(initparams, cb); @@ -317,7 +317,7 @@ int main(int argc, char** argv) auto rGenerateH = std::ranges::views::iota(0u, runs); FOR_EACH_BEGIN_EX(rGenerateH, std::execution::par_unseq) STestInitParams initparams{ .logInfo = logInfo }; - initparams.state = i; + initparams.halfSeed = i; initparams.samples = testconfigs["TestCTGenerateH"]["samples"]; initparams.immediateFail = testconfigs["TestCTGenerateH"]["immediateFail"];