From 9d3596c58d748f0a0a918dae5b1fed8767540f9f Mon Sep 17 00:00:00 2001 From: Thomas Arcila <134677+tarcila@users.noreply.github.com> Date: Tue, 10 Nov 2026 02:08:07 +0000 Subject: [PATCH 1/6] fix(rtx): keep camera sample ordinals contiguous Keep camera addressing independent of transport sampling and preserve Halton aperture, centering, reset and checkerboard behavior. --- devices/rtx/apps/tests/api/CMakeLists.txt | 5 + .../apps/tests/api/TestSampleAddressing.cpp | 420 ++++++++++++++++++ devices/rtx/apps/tests/unit/CMakeLists.txt | 12 + devices/rtx/apps/tests/unit/haltonReference.h | 30 ++ .../apps/tests/unit/test_SampleOrdinal.cpp | 137 ++++++ devices/rtx/device/gpu/cameraCreateRay.h | 11 +- devices/rtx/device/gpu/halton.h | 13 +- .../rtx/device/gpu/renderer/raygen_helpers.h | 5 +- devices/rtx/device/gpu/sampleOrdinal.h | 20 + devices/rtx/device/renderer/Quality_ptx.cu | 10 +- 10 files changed, 641 insertions(+), 22 deletions(-) create mode 100644 devices/rtx/apps/tests/api/TestSampleAddressing.cpp create mode 100644 devices/rtx/apps/tests/unit/haltonReference.h create mode 100644 devices/rtx/apps/tests/unit/test_SampleOrdinal.cpp create mode 100644 devices/rtx/device/gpu/sampleOrdinal.h diff --git a/devices/rtx/apps/tests/api/CMakeLists.txt b/devices/rtx/apps/tests/api/CMakeLists.txt index 359423ef5..5f5dc14d3 100644 --- a/devices/rtx/apps/tests/api/CMakeLists.txt +++ b/devices/rtx/apps/tests/api/CMakeLists.txt @@ -68,6 +68,11 @@ make_test(TestGroundSphereShadows) make_test(TestPowerLightPick) make_test(TestRayBufferCamera) make_test(TestCameraNearFar) +make_test(TestSampleAddressing) +target_include_directories(TestSampleAddressing PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/../../../device) +target_link_libraries(TestSampleAddressing PRIVATE CUDA::cudart) +set_tests_properties(TestSampleAddressing PROPERTIES TIMEOUT 120) make_test(TestPowerLightPickEnv) make_test(TestEmissiveGeometryLight) make_test(TestQuadLightSide) diff --git a/devices/rtx/apps/tests/api/TestSampleAddressing.cpp b/devices/rtx/apps/tests/api/TestSampleAddressing.cpp new file mode 100644 index 000000000..b7bc3e21b --- /dev/null +++ b/devices/rtx/apps/tests/api/TestSampleAddressing.cpp @@ -0,0 +1,420 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +// Public ANARI regression. A full-coverage quad has a linear vertex-color +// gradient, so its albedo directly observes the camera's subpixel coordinates. +// This checks actual raygen ordinals, mapping and normalization, not an image +// comparison between different PCG-dependent batching schedules. +#include +#include +#include +#include "../unit/haltonReference.h" + +#include +#include +#include +#include +#include + +using Vec3 = std::array; +using Vec4 = std::array; +using UVec2 = std::array; +constexpr unsigned SIZE = 8; + +static void status(const void *, + ANARIDevice, + ANARIObject, + ANARIDataType, + ANARIStatusSeverity severity, + ANARIStatusCode, + const char *message) +{ + if (severity <= ANARI_SEVERITY_ERROR) { + std::fprintf(stderr, "%s\n", message); + std::exit(1); + } +} + +struct Image +{ + std::vector albedo; + std::vector color; + bool operator==(const Image &other) const + { + return albedo == other.albedo && color == other.color; + } +}; + +struct Scene +{ + anari::Device d; + anari::World world; + anari::Camera camera; + anari::Renderer renderer; + + Scene(anari::Device device, + const char *subtype, + int spp, + bool checkerboard, + bool perspective = false, + float aperture = 0.f) + : d(device) + { + const std::array positions = {Vec3{-1.f, -1.f, 0.f}, + Vec3{1.f, -1.f, 0.f}, + Vec3{1.f, 1.f, 0.f}, + Vec3{-1.f, 1.f, 0.f}}; + const std::array colors = {Vec4{0.f, 0.f, .25f, 1.f}, + Vec4{1.f, 0.f, .25f, 1.f}, + Vec4{1.f, 1.f, .25f, 1.f}, + Vec4{0.f, 1.f, .25f, 1.f}}; + auto geometry = anari::newObject(d, "quad"); + anari::setParameterArray1D( + d, geometry, "vertex.position", positions.data(), 4); + anari::setParameterArray1D(d, geometry, "vertex.color", colors.data(), 4); + anari::commitParameters(d, geometry); + auto material = anari::newObject(d, "matte"); + anari::setParameter(d, material, "color", "color"); + anari::commitParameters(d, material); + auto surface = anari::newObject(d); + anari::setAndReleaseParameter(d, surface, "geometry", geometry); + anari::setAndReleaseParameter(d, surface, "material", material); + anari::commitParameters(d, surface); + world = anari::newObject(d); + anari::setParameterArray1D(d, world, "surface", &surface, 1); + anari::release(d, surface); + anari::commitParameters(d, world); + camera = anari::newObject( + d, perspective ? "perspective" : "orthographic"); + // Plane depth is 1, focus depth is 2: lens displacement survives at the + // plane instead of cancelling as it would on the focal plane. + anari::setParameter(d, camera, "fovy", float(std::acos(-1.) / 3.)); + anari::setParameter(d, camera, "focusDistance", 2.f); + anari::setParameter(d, camera, "apertureRadius", aperture); + anari::setParameter(d, camera, "position", Vec3{0.f, 0.f, 1.f}); + anari::setParameter(d, camera, "direction", Vec3{0.f, 0.f, -1.f}); + anari::setParameter(d, camera, "up", Vec3{0.f, 1.f, 0.f}); + anari::setParameter(d, camera, "height", 2.f); + anari::setParameter(d, camera, "aspect", 1.f); + anari::commitParameters(d, camera); + renderer = anari::newObject(d, subtype); + anari::setParameter(d, renderer, "pixelSamples", spp); + anari::setParameter(d, renderer, "checkerboarding", checkerboard); + anari::setParameter(d, renderer, "denoise", false); + anari::setParameter(d, renderer, "fireflyFilterMode", "none"); + anari::setParameter(d, renderer, "ambientRadiance", 1.f); + anari::setParameter(d, renderer, "ambientSamples", 0); + anari::setParameter(d, renderer, "sampleLimit", 0); + anari::commitParameters(d, renderer); + } + ~Scene() + { + anari::release(d, renderer); + anari::release(d, camera); + anari::release(d, world); + } + anari::Frame newFrame() + { + auto f = anari::newObject(d); + anari::setParameter(d, f, "size", UVec2{SIZE, SIZE}); + anari::setParameter(d, f, "channel.color", ANARI_FLOAT32_VEC4); + anari::setParameter(d, f, "channel.albedo", ANARI_FLOAT32_VEC3); + anari::setParameter(d, f, "world", world); + anari::setParameter(d, f, "camera", camera); + anari::setParameter(d, f, "renderer", renderer); + // Explicit public restart avoids unrelated deferred scene finalizations. + anari::setParameter(d, f, "accumulationVersion", uint64_t(1)); + anari::commitParameters(d, f); + return f; + } + Image render(anari::Frame f) + { + anari::render(d, f); + anari::wait(d, f); + Image image; + auto a = anari::map(d, f, "channel.albedo"); + auto c = anari::map(d, f, "channel.color"); + if (!a.data || !c.data || a.width != SIZE || a.height != SIZE + || c.width != SIZE || c.height != SIZE) { + std::fprintf(stderr, "missing or incorrectly sized image channel\n"); + std::exit(1); + } + image.albedo.assign(a.data, a.data + SIZE * SIZE); + image.color.assign(c.data, c.data + SIZE * SIZE); + anari::unmap(d, f, "channel.albedo"); + anari::unmap(d, f, "channel.color"); + return image; + } +}; + +// The expected *prefix* enumerates indices from zero directly. It deliberately +// does not call sampleOrdinal or reproduce the launch's addressing expression. +static Vec3 expected(unsigned x, + unsigned y, + int count, + bool perspective = false, + float aperture = 0.f, + int lensMode = 0) +{ + Vec3 result{0.f, 0.f, .25f}; + // Frozen uint32 mixer answers for this 8x8 fixture, evaluated offline with + // integer modulo-2^32 arithmetic. Do not call a production sampler to form + // camera expectations (including its pixel offset). + static constexpr uint32_t offsets[SIZE * SIZE] = {0xf1a85082u, + 0xa3dca20eu, + 0x1b663695u, + 0x7a812a2du, + 0x893a185cu, + 0xdbd6d9b0u, + 0x4a5b740cu, + 0xc9b47bf5u, + 0x22d29479u, + 0xb524f74eu, + 0xb8fc918du, + 0xf6568bbbu, + 0x1101ab2fu, + 0xb81bc7cbu, + 0x17cc3ccfu, + 0x0c6869beu, + 0x32d981ffu, + 0x339b28e2u, + 0x76818b25u, + 0x4e603b86u, + 0x331c4a7fu, + 0x0815fdbeu, + 0x0d79c747u, + 0x83010ff4u, + 0xe7a498bdu, + 0xbaa53ff9u, + 0x4e09abdfu, + 0x0ac5cc56u, + 0xcecf5e74u, + 0xf2e2503cu, + 0xc231861cu, + 0x31e2b933u, + 0xf9de2d0au, + 0xadfb9945u, + 0x2803a2d8u, + 0x0aad144eu, + 0x3b70d7c6u, + 0x1571c214u, + 0x77d23c2bu, + 0x7c921d9au, + 0x6b790870u, + 0x086baf46u, + 0x6df03b98u, + 0x39039429u, + 0x166335b1u, + 0x67390d72u, + 0xcb0f58eau, + 0xccf66b12u, + 0x7ab1db16u, + 0xa8ac6395u, + 0x04823722u, + 0xbd84c548u, + 0x966d1870u, + 0x9a5f2fe7u, + 0x4f726fafu, + 0x10c6afa9u, + 0x88147784u, + 0x418fb0a2u, + 0x80c7e4a8u, + 0xe135426fu, + 0x35909ff5u, + 0xcf1236f6u, + 0xeee40c54u, + 0x9ab71d6eu}; + const auto offset = offsets[y * SIZE + x]; + for (int ordinal = 0; ordinal < count; ++ordinal) { + const auto h = halton_reference::point(uint32_t(ordinal) + offset); + const double sx = (x + (ordinal == 0 ? .5 : h[0])) / SIZE; + const double sy = (y + (ordinal == 0 ? .5 : h[1])) / SIZE; + if (!perspective) { + result[0] += sx; + result[1] += sy; + } else { + // Independent thin-lens geometry: a ray from lens L to focal-plane + // point F intersects the depth-1 plane at F/2 + L/2. Vertex color + // maps plane [-1,1] to [0,1]. No production camera/disk helper here. + double u = h[2], v = h[3]; + if (lensMode == 1) { + u = 0.; + v = 0.; + } // bypass lens + if (lensMode == 2) { + u = h[3]; + v = h[2]; + } // swap u/v + if (lensMode == 3 && ordinal == 0) { + u = .5; + v = .5; + } + if (lensMode == 4) { + u = h[0]; + v = h[1]; + } // wrong bases + const double radius = aperture * std::sqrt(u); + const double phi = 2. * std::acos(-1.) * v; + result[0] += .5 + (sx - .5) * std::tan(std::acos(-1.) / 6.) + + .25 * radius * std::cos(phi); + result[1] += .5 + (sy - .5) * std::tan(std::acos(-1.) / 6.) + + .25 * radius * std::sin(phi); + } + } + result[0] /= count; + result[1] /= count; + return result; +} + +static bool run(anari::Device d, + const char *subtype, + int spp, + bool checkerboard, + bool perspective = false, + float aperture = 0.f) +{ + Scene scene(d, subtype, spp, checkerboard, perspective, aperture); + // Ensure this fixture can distinguish each lens failure from the intended + // answer, even at ordinal zero (whose jitter alone must be centered). + if (perspective && aperture > 0.f) { + for (int mode = 1; mode <= 4; ++mode) { + double separation = 0.; + for (unsigned y = 0; y < SIZE; ++y) + for (unsigned x = 0; x < SIZE; ++x) { + const auto a = expected(x, y, 1, true, aperture); + const auto b = expected(x, y, 1, true, aperture, mode); + for (int c = 0; c < 2; ++c) + separation = std::max(separation, double(std::abs(a[c] - b[c]))); + } + if (separation < .01) { + std::fprintf( + stderr, "lens fixture insensitive to failure mode %d\n", mode); + return false; + } + } + } + auto frame = scene.newFrame(); + std::vector reference; + // Frame's initial reset precedes its first version latch. Observe the fresh + // image, then let the public version mechanism latch before recording the + // progressive trace. Do not change Frame's inherited reset lifecycle here. + Image fresh = scene.render(frame); + bool pending = false; + anari::getProperty(d, frame, "nextFrameReset", pending, ANARI_WAIT); + bool ok = pending; + const int launches = checkerboard ? 12 : 3; + for (int run = 0; run < 3; ++run) { + if (run == 1) { + anari::setParameter(d, frame, "accumulationVersion", uint64_t(2)); + anari::commitParameters(d, frame); + } else if (run == 2) { + anari::release(d, frame); + frame = scene.newFrame(); + fresh = scene.render(frame); + anari::getProperty(d, frame, "nextFrameReset", pending, ANARI_WAIT); + ok &= pending; + } + for (int launch = 0; launch < launches; ++launch) { + const Image actual = scene.render(frame); + int samples = -1; + if (!anari::getProperty(d, frame, "numSamples", samples, ANARI_WAIT) + || samples + != (checkerboard ? (launch + 1) / 4 : (launch + 1) * spp)) { + std::fprintf(stderr, + "%s spp=%d checker=%d launch=%d: wrong sample count %d\n", + subtype, + spp, + checkerboard, + launch, + samples); + ok = false; + } + for (unsigned y = 0; y < SIZE; ++y) { + for (unsigned x = 0; x < SIZE; ++x) { + int count = (launch + 1) * spp; + const int divisor = checkerboard ? launch / 4 + 1 : launch * spp + 1; + if (checkerboard) { + const int tile = (x & 1) | ((y & 1) << 1); + count = launch / 4 + int(tile <= launch % 4); + } + // The mapped albedo channel retains its existing pre-launch + // (completedSamples+1) divisor, including sparse checkerboard tiles. + // Color compositing has its own normalization/initial tile redirect. + // Preserve both; addressing must not repair counter normalization. + Vec3 want = count ? expected(x, y, count, perspective, aperture) + : Vec3{0.f, 0.f, 0.f}; + for (float &v : want) + v *= float(count) / divisor; + for (int c = 0; c < 3; ++c) { + const float got = actual.albedo[y * SIZE + x][c]; + // Float ray setup, trig, intersection and barycentrics versus + // double rational/analytic oracle: absolute albedo tolerance, + // not inappropriate CPU/GPU bit identity. + if (!std::isfinite(got) || std::abs(got - want[c]) > 2e-6f) { + std::fprintf(stderr, + "%s spp=%d checker=%d run=%d launch=%d pixel=(%u,%u) channel=%d: %.9g != %.9g\n", + subtype, + spp, + checkerboard, + run, + launch, + x, + y, + c, + got, + want[c]); + anari::release(d, frame); + return false; + } + } + } + } + if (launch == 0 && run != 1 && !(fresh == actual)) { + std::fprintf(stderr, + "%s fresh first launch differs from reset ordinal zero\n", + subtype); + ok = false; + } + if (run == 0) + reference.push_back(actual); + else if (!(actual == reference[launch])) { + std::fprintf(stderr, + "%s spp=%d checker=%d run=%d launch=%d not repeatable\n", + subtype, + spp, + checkerboard, + run, + launch); + ok = false; + } + } + } + anari::release(d, frame); + std::printf("%s spp=%d checker=%d perspective=%d aperture=%g: %s\n", + subtype, + spp, + checkerboard, + perspective, + aperture, + ok ? "ok" : "FAIL"); + return ok; +} + +int main() +{ + auto device = makeVisRTXDevice(status); + bool ok = true; + for (const char *subtype : {"quality", "interactive"}) { + for (int spp : {1, 2, 3, 4, 8}) + ok &= run(device, subtype, spp, false); + // Requested spp=8 must be forced to effective spp=1 by the real renderer. + ok &= run(device, subtype, 8, true); + for (float aperture : {0.f, .4f}) { + for (int spp : {1, 3}) + ok &= run(device, subtype, spp, false, true, aperture); + ok &= run(device, subtype, 8, true, true, aperture); + } + } + anari::release(device, device); + return ok ? 0 : 1; +} diff --git a/devices/rtx/apps/tests/unit/CMakeLists.txt b/devices/rtx/apps/tests/unit/CMakeLists.txt index 1f548a8ee..ec547ee71 100644 --- a/devices/rtx/apps/tests/unit/CMakeLists.txt +++ b/devices/rtx/apps/tests/unit/CMakeLists.txt @@ -91,6 +91,18 @@ target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) add_test(NAME rtx::LightGeometryOracle COMMAND ${PROJECT_NAME}) +# Shared production ordinal seam (no GPU initialization). +add_executable(rtx_test_SampleOrdinal test_SampleOrdinal.cpp) +target_include_directories(rtx_test_SampleOrdinal PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/../../../device + ${CMAKE_CURRENT_LIST_DIR}/../../../external/nanovdb/include + ${OptiX_ROOT_DIR}/include) +target_link_libraries(rtx_test_SampleOrdinal PRIVATE + CUDA::cudart visrtx::glm anari::anari_headers) +target_compile_definitions(rtx_test_SampleOrdinal PRIVATE GLM_ENABLE_EXPERIMENTAL) +target_compile_features(rtx_test_SampleOrdinal PRIVATE cxx_std_17) +add_test(NAME rtx::SampleOrdinal COMMAND rtx_test_SampleOrdinal) + # Standard-library-only executor tests. find_package(Threads REQUIRED) add_executable(rtx_test_TaskExecutor diff --git a/devices/rtx/apps/tests/unit/haltonReference.h b/devices/rtx/apps/tests/unit/haltonReference.h new file mode 100644 index 000000000..96685f41d --- /dev/null +++ b/devices/rtx/apps/tests/unit/haltonReference.h @@ -0,0 +1,30 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +#pragma once + +#include +#include +#include + +namespace halton_reference { +// Reverse integer digits into an exact rational before ONE double division. +// Unlike production this does not accumulate rounded float powers of 1/base. +inline double inverse(uint32_t index, uint32_t base) +{ + uint64_t numerator = 0, denominator = 1; + while (index) { + numerator = numerator * base + index % base; + denominator *= base; + index /= base; + } + return std::min( + double(numerator) / double(denominator), double(0x1.fffffep-1f)); +} +inline std::array point(uint32_t index) +{ + return {inverse(index, 2), + inverse(index, 3), + inverse(index, 5), + inverse(index, 7)}; +} +} // namespace halton_reference diff --git a/devices/rtx/apps/tests/unit/test_SampleOrdinal.cpp b/devices/rtx/apps/tests/unit/test_SampleOrdinal.cpp new file mode 100644 index 000000000..e382c4690 --- /dev/null +++ b/devices/rtx/apps/tests/unit/test_SampleOrdinal.cpp @@ -0,0 +1,137 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#include +#include +#include +#include "gpu/cameraCreateRay.h" +#include "gpu/sampleOrdinal.h" + +using visrtx::sampleOrdinal; + +int main() +{ + int failures = 0; + auto check = [&](bool ok, const char *label) { + if (!ok) { + std::fprintf(stderr, "FAIL: %s\n", label); + ++failures; + } + }; + // Independent radical-inverse answers, including the legal zero endpoint. + const auto zero = visrtx::halton4D(0); + const auto one = visrtx::halton4D(1); + const auto two = visrtx::halton4D(2); + check(zero.x == 0.f && zero.y == 0.f && zero.z == 0.f && zero.w == 0.f, + "Halton zero endpoint"); + check(one.x == .5f && one.y == 1.f / 3.f && one.z == 1.f / 5.f + && one.w == 1.f / 7.f && two.x == .25f && two.y == 2.f / 3.f + && two.z == 2.f / 5.f && two.w == 2.f / 7.f, + "Halton bases 2, 3, 5, 7 known answers"); + check(visrtx::haltonPixelHash(0, 0) == 0xf1a85082u + && visrtx::haltonPixelHash(1, 2) == 0x339b28e2u, + "Halton legacy pixel offsets"); + for (uint32_t index : {0u, 1u, 2147483647u, 0xffffffffu}) { + const auto h = visrtx::halton4D(index); + check(h.x >= 0.f && h.x < 1.f && h.y >= 0.f && h.y < 1.f && h.z >= 0.f + && h.z < 1.f && h.w >= 0.f && h.w < 1.f, + "Halton remains half-open at large indices"); + } + // A literal prefix from the specification, independent of batch boundaries. + const std::vector prefix = {0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23}; + for (int spp : {1, 2, 3, 4, 8}) { + for (int run = 0; run < 2; ++run) { // reset restarts at zero + std::vector trace; + for (int completed = 0; completed < 24; completed += spp) + for (int i = 0; i < spp; ++i) + trace.push_back(sampleOrdinal(completed, i)); + check(trace == prefix, "contiguous prefix across batches and reset"); + } + } + check(sampleOrdinal(0, 0) == 0, + "underlying ordinal zero, without camera override"); + // Four checkerboard tiles share the completed count; effective spp is one. + std::vector tiles; + for (int cycle = 0; cycle < 3; ++cycle) + for (int tile = 0; tile < 4; ++tile) + tiles.push_back(sampleOrdinal(cycle, 0)); + check(tiles == std::vector{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}, + "each tile receives cycle ordinal"); + const std::vector nearLimit = {2147483639u, + 2147483640u, + 2147483641u, + 2147483642u, + 2147483643u, + 2147483644u, + 2147483645u, + 2147483646u}; + std::vector trace; + for (int i = 0; i < 8; ++i) + trace.push_back(sampleOrdinal(INT_MAX - 8, i)); + check(trace == nearLimit, "last supported eight-sample batch"); + check((INT_MAX - 8) + 8 == INT_MAX, "frame update remains representable"); + // Exercise the real camera path independently of ordinal addressing. + visrtx::FrameGPUData frame{}; + frame.fb.invSize = visrtx::vec2(1.f / 16.f); + frame.camera.type = visrtx::CameraType::PERSPECTIVE; + frame.camera.region = visrtx::vec4(0.f, 0.f, 1.f, 1.f); + frame.camera.perspective.dir_00 = visrtx::vec3(-1.f, -1.f, -1.f); + frame.camera.perspective.dir_du = visrtx::vec3(2.f, 0.f, 0.f); + frame.camera.perspective.dir_dv = visrtx::vec3(0.f, 2.f, 0.f); + frame.camera.perspective.aspect = 1.f; + frame.camera.perspective.scaledAperture = 0.1f; + visrtx::ScreenSample ss{}; + ss.frameData = &frame; + ss.pixel = visrtx::uvec2(3, 5); + const auto r = visrtx::halton4D(visrtx::haltonPixelHash(3, 5)); + const auto jittered = visrtx::makePrimaryRay(ss, 0, false); + check(ss.screen == visrtx::vec2((3.f + r.x) / 16.f, (5.f + r.y) / 16.f), + "ordinal zero normally uses Halton jitter"); + const auto expectedLens = visrtx::uniformSampleDisk(0.1f, {r.z, r.w}); + check(jittered.org + == visrtx::vec3(2.f * expectedLens.x, 2.f * expectedLens.y, 0.f), + "camera aperture uses Halton bases 5 and 7"); + const auto centered = visrtx::makePrimaryRay(ss, 0, true); + check(ss.screen == visrtx::vec2(3.5f / 16.f, 5.5f / 16.f), + "first accumulated ray overrides pixel jitter"); + check(jittered.dir != centered.dir, + "center override is independently observable"); + check(jittered.org == centered.org && centered.org != frame.camera.pos, + "center override preserves sampled aperture"); + frame.camera.type = visrtx::CameraType::RAY_BUFFER; + frame.camera.rayBuffer = {}; // switch the active camera union member + const visrtx::vec3 rayDirection(0.f, 0.f, -2.f); + frame.camera.rayBuffer.valid = true; + frame.camera.rayBuffer.size = visrtx::uvec2(1); + frame.camera.rayBuffer.dir = &rayDirection; + ss.pixel = visrtx::uvec2(0); + const auto buffered = visrtx::makePrimaryRay(ss, 19, false); + check(buffered.org == frame.camera.pos + && buffered.dir == visrtx::vec3(0.f, 0.f, -1.f) + && ss.screen == visrtx::vec2(0.5f / 16.f), + "ray-buffer bypass ignores jitter and aperture"); + return failures ? 1 : 0; +} diff --git a/devices/rtx/device/gpu/cameraCreateRay.h b/devices/rtx/device/gpu/cameraCreateRay.h index 9654d5961..3815d216a 100644 --- a/devices/rtx/device/gpu/cameraCreateRay.h +++ b/devices/rtx/device/gpu/cameraCreateRay.h @@ -109,12 +109,11 @@ VISRTX_DEVICE Ray rayBufferCreateRay(const CameraGPUData &c, uvec2 pixel) return ray; } -// sampleIdx is a (frame-counter × spp_loop) ordinal advancing once per -// camera sample within the frame's accumulation; combined with a -// per-pixel hash offset it indexes a Halton 4D point used for -// sub-pixel jitter (dims 0/1) + lens aperture (dims 2/3). Halton at -// the camera level converges the AA / DoF integrals strictly faster -// than uniform random — see gpu/halton.h. +// sampleIdx is completedSamples + within-batch iteration (sampleOrdinal), +// advancing once per camera sample, not frame-counter times spp. +// Halton bases 2/3 = pixel jitter, 5/7 = aperture. The first sample overrides +// pixel jitter with the center, but still samples the aperture at ordinal zero. +// Ray-buffer cameras bypass both. Pixel seeds are independent of batching. VISRTX_DEVICE Ray makePrimaryRay( ScreenSample &ss, uint32_t sampleIdx, bool centerPixel = false) { diff --git a/devices/rtx/device/gpu/halton.h b/devices/rtx/device/gpu/halton.h index b24dbf4fb..07bc5eebf 100644 --- a/devices/rtx/device/gpu/halton.h +++ b/devices/rtx/device/gpu/halton.h @@ -34,22 +34,23 @@ #include "gpu/gpu_decl.h" #include // ::float4 +#include #include // Halton low-discrepancy sequence for the 2–4D top of the path (camera -// jitter + DoF lens). Pattern: PCG everywhere, QMC at the camera. +// jitter + DoF lens). Transport uses a separate Sobol sequence with PCG +// fallback. // dims 0..1 (bases 2, 3): pixel x/y sub-pixel jitter // dims 2..3 (bases 5, 7): lens u/v for DoF // // Pixel decorrelation: additive offset = haltonPixelHash(pixel). Not full -// Owen scrambling — adequate at 4D, full scrambling is more code for -// negligible win. +// Owen scrambling. namespace visrtx { // Per-pixel scramble hash — PCG-style integer mixer, additive offset on // the Halton sample index. -VISRTX_DEVICE uint32_t haltonPixelHash(uint32_t x, uint32_t y) +VISRTX_HOST_DEVICE uint32_t haltonPixelHash(uint32_t x, uint32_t y) { // Salt breaks the (0, 0) zero fixed point — otherwise pixel (0, 0) would // share its Halton subsequence with the origin. @@ -66,7 +67,7 @@ VISRTX_DEVICE uint32_t haltonPixelHash(uint32_t x, uint32_t y) // decimal point. Generic loop covers bases 2/3/5/7; Base=2 could specialise // to __brev but the saving is marginal at this dimensionality. template -VISRTX_DEVICE float radicalInverse(uint32_t i) +VISRTX_HOST_DEVICE float radicalInverse(uint32_t i) { static_assert(Base >= 2u, "radicalInverse requires Base >= 2"); constexpr float invBase = 1.0f / float(Base); @@ -83,7 +84,7 @@ VISRTX_DEVICE float radicalInverse(uint32_t i) // Halton 4D point (Φ_2, Φ_3, Φ_5, Φ_7), each in [0, 1). Combine sampleIdx // with haltonPixelHash for per-pixel decorrelation. -VISRTX_DEVICE ::float4 halton4D(uint32_t sampleIdx) +VISRTX_HOST_DEVICE ::float4 halton4D(uint32_t sampleIdx) { return ::float4{ radicalInverse<2>(sampleIdx), diff --git a/devices/rtx/device/gpu/renderer/raygen_helpers.h b/devices/rtx/device/gpu/renderer/raygen_helpers.h index 15a02695e..932ff4319 100644 --- a/devices/rtx/device/gpu/renderer/raygen_helpers.h +++ b/devices/rtx/device/gpu/renderer/raygen_helpers.h @@ -37,6 +37,7 @@ #include "gpu/lightProxyRadiance.h" #include "gpu/renderer/common.h" #include "gpu/renderer/fog.h" +#include "gpu/sampleOrdinal.h" #include "gpu/shadingState.h" #include "gpu/volumeIntegration.h" @@ -89,9 +90,7 @@ VISRTX_DEVICE void renderPixel(FrameGPUData &frameData, ScreenSample ss) for (int i = 0; i < frameData.renderer.numIterations; i++) { bool isVeryFirstRay = i == 0 && ss.frameData->fb.frameID == 0; - const uint32_t sampleIdx = uint32_t(ss.frameData->fb.frameID) - * uint32_t(rendererParams.numIterations) - + uint32_t(i); + const uint32_t sampleIdx = sampleOrdinal(ss.frameData->fb.frameID, i); auto ray = makePrimaryRay(ss, sampleIdx, isVeryFirstRay); // Visibility clipping may re-origin the traversal ray, but fog measures // from the original camera sample (including its sampled lens position). diff --git a/devices/rtx/device/gpu/sampleOrdinal.h b/devices/rtx/device/gpu/sampleOrdinal.h new file mode 100644 index 000000000..1aa3cd39a --- /dev/null +++ b/devices/rtx/device/gpu/sampleOrdinal.h @@ -0,0 +1,20 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#pragma once + +#include "gpu/gpu_decl.h" + +namespace visrtx { + +// completedSamples already counts samples, not launches. Supported inputs: +// nonnegative completedSamples, positive effective spp, 0 <= iteration < spp, +// and completedSamples + spp <= INT_MAX (the existing signed frame counter). +// The sampler has a uint32 period of 2^32; this does not extend the frame +// limit. +VISRTX_HOST_DEVICE uint32_t sampleOrdinal(int completedSamples, int iteration) +{ + return uint32_t(completedSamples) + uint32_t(iteration); +} + +} // namespace visrtx diff --git a/devices/rtx/device/renderer/Quality_ptx.cu b/devices/rtx/device/renderer/Quality_ptx.cu index 66862a9be..c241d3860 100644 --- a/devices/rtx/device/renderer/Quality_ptx.cu +++ b/devices/rtx/device/renderer/Quality_ptx.cu @@ -44,6 +44,7 @@ #include "gpu/renderer/fog.h" #include "gpu/renderer/shadowTransmittance.h" #include "gpu/sampleLight.h" +#include "gpu/sampleOrdinal.h" #include "gpu/shadingState.h" #include "gpu/volumeIntegration.h" @@ -613,13 +614,8 @@ VISRTX_GLOBAL void __raygen__() for (int i = 0; i < rendererParams.numIterations; ++i) { bool isVeryFirstRay = i == 0 && ss.frameData->fb.frameID == 0; - // Halton sample index: per-pixel ordinal across the whole frame's - // sample budget. Using `frameID * numIterations + i` keeps the - // per-pixel Halton indices contiguous [0, totalSpp), which is the - // optimal QMC stratification. - const uint32_t sampleIdx = uint32_t(ss.frameData->fb.frameID) - * uint32_t(rendererParams.numIterations) - + uint32_t(i); + // frameID already counts accumulated samples, not launches. + const uint32_t sampleIdx = sampleOrdinal(ss.frameData->fb.frameID, i); auto ray = makePrimaryRay(ss, sampleIdx, isVeryFirstRay); const vec3 cameraOrigin = ray.org; const vec3 cameraFogColor = fogColor(frameData, ss.pixel, ray.dir); From 2afd1d742f218277866172eea17acef28a4f73fc Mon Sep 17 00:00:00 2001 From: Thomas Arcila <134677+tarcila@users.noreply.github.com> Date: Tue, 10 Nov 2026 02:09:19 +0000 Subject: [PATCH 2/6] feat(rtx): add reference-backed Sobol transport sampler Introduce the immutable attributed table and packed transport roles without reserving camera dimensions or replacing Halton camera sampling. Validate reference outputs before publication and preserve the complete generated header with offline regressions. --- devices/rtx/apps/tests/unit/CMakeLists.txt | 31 ++ .../sobol/FastOwenScrambler.reference.txt | 23 + .../rtx/apps/tests/unit/sobol/LICENSE.joe-kuo | 32 ++ .../rtx/apps/tests/unit/sobol/LICENSE.pbrt | 202 ++++++++ devices/rtx/apps/tests/unit/sobol/NOTICE | 37 ++ .../rtx/apps/tests/unit/sobol/cudaResources.h | 85 +++ devices/rtx/apps/tests/unit/sobol/joe-kuo.txt | 19 + .../rtx/apps/tests/unit/sobol/reference.py | 147 ++++++ .../rtx/apps/tests/unit/sobol/table_header.py | 20 + devices/rtx/apps/tests/unit/sobol/testSobol.h | 350 +++++++++++++ .../apps/tests/unit/sobol/test_reference.py | 100 ++++ .../tests/unit/sobol/test_table_header.py | 42 ++ devices/rtx/apps/tests/unit/sobol/vectors.txt | 482 ++++++++++++++++++ devices/rtx/apps/tests/unit/test_Sobol.cpp | 9 + devices/rtx/apps/tests/unit/test_SobolCUDA.cu | 10 + devices/rtx/device/CMakeLists.txt | 8 + devices/rtx/device/gpu/owenSobol.h | 166 ++++++ devices/rtx/device/gpu/samplerContracts.h | 26 + devices/rtx/device/gpu/sobolDirections.h | 207 ++++++++ 19 files changed, 1996 insertions(+) create mode 100644 devices/rtx/apps/tests/unit/sobol/FastOwenScrambler.reference.txt create mode 100644 devices/rtx/apps/tests/unit/sobol/LICENSE.joe-kuo create mode 100644 devices/rtx/apps/tests/unit/sobol/LICENSE.pbrt create mode 100644 devices/rtx/apps/tests/unit/sobol/NOTICE create mode 100644 devices/rtx/apps/tests/unit/sobol/cudaResources.h create mode 100644 devices/rtx/apps/tests/unit/sobol/joe-kuo.txt create mode 100644 devices/rtx/apps/tests/unit/sobol/reference.py create mode 100644 devices/rtx/apps/tests/unit/sobol/table_header.py create mode 100644 devices/rtx/apps/tests/unit/sobol/testSobol.h create mode 100644 devices/rtx/apps/tests/unit/sobol/test_reference.py create mode 100644 devices/rtx/apps/tests/unit/sobol/test_table_header.py create mode 100644 devices/rtx/apps/tests/unit/sobol/vectors.txt create mode 100644 devices/rtx/apps/tests/unit/test_Sobol.cpp create mode 100644 devices/rtx/apps/tests/unit/test_SobolCUDA.cu create mode 100644 devices/rtx/device/gpu/owenSobol.h create mode 100644 devices/rtx/device/gpu/samplerContracts.h create mode 100644 devices/rtx/device/gpu/sobolDirections.h diff --git a/devices/rtx/apps/tests/unit/CMakeLists.txt b/devices/rtx/apps/tests/unit/CMakeLists.txt index ec547ee71..438cced96 100644 --- a/devices/rtx/apps/tests/unit/CMakeLists.txt +++ b/devices/rtx/apps/tests/unit/CMakeLists.txt @@ -103,6 +103,37 @@ target_compile_definitions(rtx_test_SampleOrdinal PRIVATE GLM_ENABLE_EXPERIMENTA target_compile_features(rtx_test_SampleOrdinal PRIVATE cxx_std_17) add_test(NAME rtx::SampleOrdinal COMMAND rtx_test_SampleOrdinal) +find_package(Python3 REQUIRED COMPONENTS Interpreter) +add_test(NAME rtx::SobolTableHeader + COMMAND Python3::Interpreter -B + ${CMAKE_CURRENT_LIST_DIR}/sobol/test_table_header.py) +add_test(NAME rtx::SobolReferencePublication + COMMAND Python3::Interpreter -B + ${CMAKE_CURRENT_LIST_DIR}/sobol/test_reference.py) +set_tests_properties(rtx::SobolTableHeader rtx::SobolReferencePublication + PROPERTIES TIMEOUT 30) + +# Production Sobol sampler against independently sourced Joe-Kuo parameters. +add_executable(rtx_test_Sobol test_Sobol.cpp) +add_executable(rtx_test_SobolCUDA test_SobolCUDA.cu) +foreach(sobol_target rtx_test_Sobol rtx_test_SobolCUDA) + target_include_directories(${sobol_target} PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/../../../device) + target_link_libraries(${sobol_target} PRIVATE CUDA::cudart) + target_compile_features(${sobol_target} PRIVATE cxx_std_17) + set_target_properties(${sobol_target} PROPERTIES + CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON) + target_compile_definitions(${sobol_target} PRIVATE + SOBOL_PARAMETER_FILE="${CMAKE_CURRENT_LIST_DIR}/sobol/joe-kuo.txt" + SOBOL_VECTOR_FILE="${CMAKE_CURRENT_LIST_DIR}/sobol/vectors.txt") +endforeach() +# Match the RTX PTX's arithmetic configuration. +target_compile_options(rtx_test_SobolCUDA PRIVATE + $<$:--use_fast_math;--expt-relaxed-constexpr>) +add_test(NAME rtx::Sobol COMMAND rtx_test_Sobol) +add_test(NAME rtx::SobolCUDA COMMAND rtx_test_SobolCUDA) +set_tests_properties(rtx::Sobol rtx::SobolCUDA PROPERTIES TIMEOUT 60) + # Standard-library-only executor tests. find_package(Threads REQUIRED) add_executable(rtx_test_TaskExecutor diff --git a/devices/rtx/apps/tests/unit/sobol/FastOwenScrambler.reference.txt b/devices/rtx/apps/tests/unit/sobol/FastOwenScrambler.reference.txt new file mode 100644 index 000000000..e569b5667 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/FastOwenScrambler.reference.txt @@ -0,0 +1,23 @@ +// pbrt is Copyright(c) 1998-2020 Matt Pharr, Wenzel Jakob, and Greg Humphreys. +// The pbrt source code is licensed under the Apache License, Version 2.0. +// SPDX: Apache-2.0 + +// FastOwenScrambler Definition +struct FastOwenScrambler { + PBRT_CPU_GPU + FastOwenScrambler(uint32_t seed) : seed(seed) {} + // FastOwenScrambler Public Methods + PBRT_CPU_GPU + uint32_t operator()(uint32_t v) const { + v = ReverseBits32(v); + v ^= v * 0x3d20adea; + v += seed; + v *= (seed >> 16) | 1; + v ^= v * 0x05526c56; + v ^= v * 0x53a22864; + return ReverseBits32(v); + } + + uint32_t seed; +}; + diff --git a/devices/rtx/apps/tests/unit/sobol/LICENSE.joe-kuo b/devices/rtx/apps/tests/unit/sobol/LICENSE.joe-kuo new file mode 100644 index 000000000..9383513ca --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/LICENSE.joe-kuo @@ -0,0 +1,32 @@ +----------------------------------------------------------------------------- +Licence pertaining to sobol.cc and the accompanying sets of direction numbers + +----------------------------------------------------------------------------- +Copyright (c) 2008, Frances Y. Kuo and Stephen Joe +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the copyright holders nor the names of the + University of New South Wales and the University of Waikato + and its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/devices/rtx/apps/tests/unit/sobol/LICENSE.pbrt b/devices/rtx/apps/tests/unit/sobol/LICENSE.pbrt new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/LICENSE.pbrt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/devices/rtx/apps/tests/unit/sobol/NOTICE b/devices/rtx/apps/tests/unit/sobol/NOTICE new file mode 100644 index 000000000..bed09ae85 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/NOTICE @@ -0,0 +1,37 @@ +// pbrt is Copyright(c) 1998-2020 Matt Pharr, Wenzel Jakob, and Greg Humphreys. +// The pbrt source code is licensed under the Apache License, Version 2.0. +// SPDX: Apache-2.0 + +// Copyright (c) 2012 Leonhard Gruenschloss (leonhard@gruenschloss.org) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to +// do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// These matrices are based on the following publication: +// +// S. Joe and F. Y. Kuo: "Constructing Sobol sequences with better +// two-dimensional projections", SIAM J. Sci. Comput. 30, 2635-2654 (2008). +// +// The tabulated direction numbers are available here: +// http://web.maths.unsw.edu.au/~fkuo/sobol/new-joe-kuo-6.21201 + + +VisRTX modification: extract rows 0..15 and columns 0..31 from stride 52; +adapt FastOwenScrambler naming/annotations, retaining integer operations. diff --git a/devices/rtx/apps/tests/unit/sobol/cudaResources.h b/devices/rtx/apps/tests/unit/sobol/cudaResources.h new file mode 100644 index 000000000..05c7b66a8 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/cudaResources.h @@ -0,0 +1,85 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#pragma once + +#include + +#include + +// Standalone tests need explicit CUDA error returns (including allocation +// failures), unlike DeviceBuffer's unchecked copies. Keep ownership local +// without linking the device library or its allocation/logging infrastructure. +struct CudaFree +{ + void operator()(void *pointer) const; +}; + +template +struct CudaBuffer +{ + CudaBuffer() = default; + CudaBuffer(const CudaBuffer &) = delete; + CudaBuffer &operator=(const CudaBuffer &) = delete; + CudaBuffer(CudaBuffer &&) = default; + CudaBuffer &operator=(CudaBuffer &&) = default; + + cudaError_t allocate(size_t count); + T *get() const; + void abandon(); + + private: + std::unique_ptr m_pointer; +}; + +struct CudaTexture +{ + ~CudaTexture(); + CudaTexture() = default; + CudaTexture(const CudaTexture &) = delete; + CudaTexture &operator=(const CudaTexture &) = delete; + CudaTexture(CudaTexture &&) = delete; + CudaTexture &operator=(CudaTexture &&) = delete; + + cudaArray_t array = nullptr; + cudaTextureObject_t texture = 0; +}; + +// Inlined definitions //////////////////////////////////////////////////////// + +inline void CudaFree::operator()(void *pointer) const +{ + cudaFree(pointer); +} + +template +inline cudaError_t CudaBuffer::allocate(size_t count) +{ + T *pointer = nullptr; + const auto error = cudaMalloc(&pointer, count * sizeof(T)); + if (error == cudaSuccess) + m_pointer.reset(pointer); + return error; +} + +template +inline T *CudaBuffer::get() const +{ + return m_pointer.get(); +} + +template +inline void CudaBuffer::abandon() +{ + // A negative-test child must not call CUDA again after trapping. Its process + // owns the disposable context; process exit reclaims the allocation. + (void)m_pointer.release(); +} + +inline CudaTexture::~CudaTexture() +{ + if (texture) + cudaDestroyTextureObject(texture); + if (array) + cudaFreeArray(array); +} diff --git a/devices/rtx/apps/tests/unit/sobol/joe-kuo.txt b/devices/rtx/apps/tests/unit/sobol/joe-kuo.txt new file mode 100644 index 000000000..70af5f89a --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/joe-kuo.txt @@ -0,0 +1,19 @@ +# S. Joe and F. Y. Kuo, new-joe-kuo-6.21201 +# joe-kuo/sobol_data 835a7d7b1ee3bc83e575e302a985c66ec4b65249 +# Extract: header and dimensions 2..16. See LICENSE.joe-kuo. +d s a m_i +2 1 0 1 +3 2 1 1 3 +4 3 1 1 3 1 +5 3 2 1 1 1 +6 4 1 1 1 3 3 +7 4 4 1 3 5 13 +8 5 2 1 1 5 5 17 +9 5 4 1 1 5 5 5 +10 5 7 1 1 7 11 19 +11 5 11 1 1 5 1 1 +12 5 13 1 1 1 3 11 +13 5 14 1 3 5 5 31 +14 6 1 1 3 3 9 7 49 +15 6 13 1 1 1 15 21 21 +16 6 16 1 3 1 13 27 49 diff --git a/devices/rtx/apps/tests/unit/sobol/reference.py b/devices/rtx/apps/tests/unit/sobol/reference.py new file mode 100644 index 000000000..281358dfe --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/reference.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python3 +"""Reproduce pinned fixtures; validate everything before publishing outputs.""" +import argparse +import hashlib +import os +from pathlib import Path +import re +import stat +import struct +import tempfile + +from table_header import table_header + +HERE = Path(__file__).resolve().parent + + +def check_source(path, digest): + if hashlib.sha256(path.read_bytes()).hexdigest() != digest: + raise ValueError(f"{path}: does not match the pinned source bytes") + + +def publish_outputs(outputs): + # Stage every output before replacing any destination. Each replacement is + # atomic, but filesystem failure during replacement is not a multi-file + # transaction. Validation/read/staging failures leave destinations untouched. + staged = [] + try: + for path, data in outputs.items(): + mode = stat.S_IMODE(path.stat().st_mode) if path.exists() else 0o644 + fd, name = tempfile.mkstemp(prefix="." + path.name + ".", dir=path.parent) + temporary = Path(name) + staged.append((temporary, path)) + with os.fdopen(fd, "wb") as output: + output.write(data) + temporary.chmod(mode) + for temporary, path in staged: + os.replace(temporary, path) + finally: + for temporary, _ in staged: + temporary.unlink(missing_ok=True) + + +def main(argv=None): + p = argparse.ArgumentParser() + p.add_argument("pbrt", type=Path) + p.add_argument("joe_kuo", type=Path) + p.add_argument("--table", type=Path, help="write production table after oracle agreement") + p.add_argument("--pbrt-license", type=Path) + p.add_argument("--joe-license", type=Path) + p.add_argument("--fast-owen-source", type=Path) + args = p.parse_args(argv) + for path, digest in [ + (args.pbrt, "98be104d68f0a90b4043e457b4288d7fb5b3650aae4ec60d72edc07a8435fef6"), + (args.joe_kuo, "68eedd2a4e3b659b9695e7aff0f8ac68718bcf620730fc3d3a8c65df2a067441"), + (args.fast_owen_source, "9b4084174a078713fc756ee14fd303d55a7950cc25543c0194144079e140f16d"), + ]: + if path: + try: + check_source(path, digest) + except ValueError as error: + p.error(str(error)) + here = HERE + outputs = {} + source = args.pbrt.read_text() + outputs[here / "NOTICE"] = ( + source.split("#include", 1)[0] + + "\nVisRTX modification: extract rows 0..15 and columns 0..31 from stride 52;\n" + + "adapt FastOwenScrambler naming/annotations, retaining integer operations.\n").encode("utf-8") + body = source.split("SobolMatrices32[", 1)[1].split("{", 1)[1].split("}", 1)[0] + words = [int(x, 16) for x in re.findall(r"0x[0-9a-fA-F]+", body)] + columns = [words[d * 52:d * 52 + 32] for d in range(16)] + # Source parameters, not production columns. Retain original header/spacing. + fixture = ("# S. Joe and F. Y. Kuo, new-joe-kuo-6.21201\n" + "# joe-kuo/sobol_data 835a7d7b1ee3bc83e575e302a985c66ec4b65249\n" + "# Extract: header and dimensions 2..16. See LICENSE.joe-kuo.\n").encode() + fixture += b"".join(args.joe_kuo.read_bytes().splitlines(keepends=True)[:16]) + assert b"\r" not in fixture + outputs[here / "joe-kuo.txt"] = fixture + oracle = [[1 << (31 - i) for i in range(32)]] + for line in fixture.decode().splitlines()[4:]: + d, s, a, *m = map(int, line.split()) + assert d == len(oracle) + 1 and len(m) == s + v = [m[i] << (31 - i) for i in range(s)] + for i in range(s, 32): + x = v[i-s] ^ (v[i-s] >> s) + for k in range(1, s): + if a & (1 << (s-1-k)): + x ^= v[i-k] + v.append(x) + oracle.append(v) + mismatches = [(d, i, columns[d][i], oracle[d][i]) + for d in range(16) for i in range(32) + if columns[d][i] != oracle[d][i]] + for d, i, actual, expected in mismatches: + print(f"dimension {d}, column {i}: pbrt={actual:#010x}, Joe-Kuo={expected:#010x}") + if mismatches: + raise SystemExit("STOP: pinned references disagree; investigate before changing references") + print("512 independently regenerated columns agree") + print("table SHA-256:", hashlib.sha256(b"".join(struct.pack("> 16) | 1)) & mask + v ^= (v * 0x05526c56) & mask + v ^= (v * 0x53a22864) & mask + return reverse(v) + indices = [0, 1, 2, 3, 15, 16, 31, 32, 0x80000000, 0xffffffff] + vectors = "# pbrt/Joe-Kuo binary-index vectors. See README and LICENSE.pbrt.\n" + vectors += "# index dimension pixelSeed raw reversed scrambled grid24\n" + for index in indices: + for d, row in enumerate(columns): + raw = 0 + for bit in range(32): + if index & (1 << bit): + raw ^= row[bit] + for seed in [0, 0x12345678, 0xffffffff]: + dim_seed = seed ^ ((0x9e3779b9 * (d + 1)) & mask) + value = scramble(raw, dim_seed) + vectors += " ".join(f"{x:08x}" for x in + [index, d, seed, raw, reverse(raw), value, value >> 8]) + "\n" + outputs[here / "vectors.txt"] = vectors.encode("utf-8") + if args.table: + notice = source.split("#include", 1)[0] + outputs[args.table] = table_header(notice, columns).encode("utf-8") + + publish_outputs(outputs) + + +if __name__ == "__main__": + main() diff --git a/devices/rtx/apps/tests/unit/sobol/table_header.py b/devices/rtx/apps/tests/unit/sobol/table_header.py new file mode 100644 index 000000000..c36260de6 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/table_header.py @@ -0,0 +1,20 @@ +# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause +"""Format the complete production header after reference columns agree.""" + + +def table_header(notice, columns): + text = notice + "#pragma once\n\n" + text += "// Included by owenSobol.h inside namespace visrtx after uint32_t is available.\n" + text += "// Storage is immutable host data or CUDA constant memory, per compilation pass.\n" + text += "// Derived: pbrt-v4 b0bdf461ba5dd6504b70ebf0932acc0fe7aa744f\n" + text += "// Rows 0..15, columns 0..31 (source stride 52). See apps/tests/unit/sobol.\n" + text += "// clang-format off\n#ifdef __CUDA_ARCH__\n__device__ __constant__\n#endif\n" + text += "static const uint32_t kSobolDirection[16][32] = {\n" + for row in columns: + text += " {\n" + for i in range(0, 32, 4): + text += " " + ", ".join(f"0x{x:08x}u" for x in row[i:i+4]) + ",\n" + text += " },\n" + text += "};\n// clang-format on\n" + return text diff --git a/devices/rtx/apps/tests/unit/sobol/testSobol.h b/devices/rtx/apps/tests/unit/sobol/testSobol.h new file mode 100644 index 000000000..0a9a877c9 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/testSobol.h @@ -0,0 +1,350 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#pragma once + +#include "../haltonReference.h" +#include "gpu/halton.h" +#include "gpu/owenSobol.h" + +#ifdef SOBOL_CUDA +#include "cudaResources.h" + +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sobol_test { + +// Compile the unmodified pinned FastOwen excerpt as an independent host oracle. +// Reference bit reversal deliberately uses a simple bit-at-a-time construction. +namespace pinned { +static uint32_t ReverseBits32(uint32_t v) +{ + uint32_t result = 0; + for (unsigned bit = 0; bit < 32; ++bit) { + result = (result << 1) | (v & 1u); + v >>= 1; + } + return result; +} +#define PBRT_CPU_GPU +#include "FastOwenScrambler.reference.txt" +#undef PBRT_CPU_GPU +} // namespace pinned + +using Columns = std::array, 16>; + +static void require(bool condition, const std::string &message) +{ + if (!condition) + throw std::runtime_error(message); +} + +static bool sameFloat(float a, float b) +{ + return std::memcmp(&a, &b, sizeof(float)) == 0; +} + +static Columns referenceColumns() +{ + Columns result{}; + for (int i = 0; i < 32; ++i) + result[0][i] = uint32_t(1) << (31 - i); + std::ifstream input(SOBOL_PARAMETER_FILE); + require(bool(input), "cannot open Joe-Kuo parameters"); + std::string line; + // Attribution comments followed by the original column header. + for (int i = 0; i < 4; ++i) + std::getline(input, line); + for (unsigned dimension = 1; dimension < 16; ++dimension) { + unsigned d, s, a; + require(bool(input >> d >> s >> a) && d == dimension + 1 && s <= 6, + "invalid parameter row"); + auto &v = result[dimension]; + for (unsigned i = 0; i < s; ++i) { + uint32_t numerator; + require(bool(input >> numerator), "missing numerator"); + v[i] = numerator << (31 - i); + } + for (unsigned i = s; i < 32; ++i) { + v[i] = v[i - s] ^ (v[i - s] >> s); + for (unsigned k = 1; k < s; ++k) + if (a & (1u << (s - 1 - k))) + v[i] ^= v[i - k]; + } + } + return result; +} + +struct Input +{ + uint32_t index, dimension, seed; + uint32_t x = 0, y = 0; + int bounce = 0, transparency = 0; + bool pixelSeedInput = false; +}; + +struct Output +{ + uint32_t pixelKey, vertexKey, raw, reversed, scrambled; + float sample, converted; + ::float2 hemi; + uint32_t haltonKey; + ::float4 camera, rawCamera; +}; + +// Both executables call exactly these production seams. The independent +// expectations below come from pinned parameters and offline reference vectors. +VISRTX_HOST_DEVICE Output evaluate(Input in) +{ + const auto pixelKey = in.pixelSeedInput + ? visrtx::owenPixelSeed(in.x, in.y) + : in.seed; + const auto vertexKey = + visrtx::owenBounceSeed(pixelKey, in.bounce, in.transparency); + const auto raw = visrtx::sobolUInt(in.index, in.dimension); + const auto dimSeed = vertexKey ^ (0x9e3779b9u * (in.dimension + 1u)); + return {pixelKey, + vertexKey, + raw, + visrtx::reverseBits32(raw), + visrtx::owenScramble(raw, dimSeed), + visrtx::owenSobol(in.index, in.dimension, vertexKey), + visrtx::sobolFloat(in.index), + visrtx::owenSobolHemi(in.index, vertexKey), + visrtx::haltonPixelHash(in.x, in.y), + visrtx::halton4D(in.index + visrtx::haltonPixelHash(in.x, in.y)), + visrtx::halton4D(in.index)}; +} + +// Halton is float arithmetic, not an integer Sobol grid: allow 4 float ulps +// at unit scale for accumulated reciprocal rounding (including CUDA FMA). +static void checkCamera(Input in, const Output &out) +{ + const ::float4 points[] = {out.rawCamera, out.camera}; + const uint32_t indices[] = {in.index, in.index + out.haltonKey}; + for (unsigned p = 0; p < 2; ++p) { + const auto expected = halton_reference::point(indices[p]); + const float actual[] = {points[p].x, points[p].y, points[p].z, points[p].w}; + for (unsigned c = 0; c < 4; ++c) + require(std::isfinite(actual[c]) && actual[c] >= 0.f && actual[c] < 1.f + && std::abs(actual[c] - expected[c]) <= 0x1p-21, + "Halton rational oracle component " + std::to_string(c) + " index " + + std::to_string(indices[p])); + } +} + +static void checkHalton(std::vector &inputs) +{ + // Hand-worked base fractions: index 1 and index 8 (1000b, 22_3, 13_5, 11_7). + const double answers[][4] = {{0, 0, 0, 0}, + {1. / 2, 1. / 3, 1. / 5, 1. / 7}, + {1. / 16, 8. / 9, 16. / 25, 8. / 49}}; + unsigned row = 0; + for (uint32_t index : {0u, 1u, 8u}) { + const auto p = visrtx::halton4D(index); + const float a[] = {p.x, p.y, p.z, p.w}; + for (unsigned c = 0; c < 4; ++c) + require(std::abs(a[c] - answers[row][c]) < 0x1p-21, + "Halton known-answer component " + std::to_string(c)); + ++row; + } + struct Pixel + { + uint32_t x, y, hash; + }; + const Pixel pixels[] = {{0, 0, 0xf1a85082u}, + {1, 2, 0x339b28e2u}, + {1920, 1080, 0xeebd993au}, + {0xffffffffu, 0xffffffffu, 0x4ab06c79u}}; + for (const auto &p : pixels) { + require( + visrtx::haltonPixelHash(p.x, p.y) == p.hash, "Halton fixed pixel hash"); + for (uint32_t index : {0u, + 1u, + 8u, + 0x7fffffffu, + 0x80000000u, + 0xfffffffeu, + 0xffffffffu, + uint32_t(-p.hash - 1u), + uint32_t(-p.hash), + uint32_t(1u - p.hash)}) { + Input in{index, 0, 0}; + in.x = p.x; + in.y = p.y; + const auto out = evaluate(in); + checkCamera(in, out); + // Boundary vectors force the effective index to UINT_MAX, zero, one. + if (index == uint32_t(-p.hash)) + require(out.camera.x == 0.f && out.camera.y == 0.f + && out.camera.z == 0.f && out.camera.w == 0.f, + "Halton additive offset wraps to zero"); + inputs.push_back(in); + } + } + std::cout + << "Halton 4D known answers, large indices and hash wrapping pass\n"; +} + +#ifdef SOBOL_CUDA +static void cudaCheck(cudaError_t error) +{ + require(error == cudaSuccess, cudaGetErrorString(error)); +} + +VISRTX_GLOBAL void sampleKernel(const Input *inputs, Output *outputs, size_t n) +{ + const size_t i = blockIdx.x * blockDim.x + threadIdx.x; + if (i < n) + outputs[i] = evaluate(inputs[i]); +} + +static void checkDevice(const std::vector &inputs) +{ + int count = 0; + cudaCheck(cudaGetDeviceCount(&count)); + require(count > 0, "CUDA device required; missing device is not a pass"); + cudaDeviceProp properties{}; + cudaCheck(cudaGetDeviceProperties(&properties, 0)); + int driver, runtime; + cudaCheck(cudaDriverGetVersion(&driver)); + cudaCheck(cudaRuntimeGetVersion(&runtime)); + std::cout << "CUDA " << properties.name << ", driver " << driver + << ", runtime " << runtime << '\n'; + CudaBuffer deviceInputs; + CudaBuffer deviceOutputs; + cudaCheck(deviceInputs.allocate(inputs.size())); + cudaCheck(deviceOutputs.allocate(inputs.size())); + cudaCheck(cudaMemcpy(deviceInputs.get(), + inputs.data(), + inputs.size() * sizeof(Input), + cudaMemcpyHostToDevice)); + sampleKernel<<<(inputs.size() + 127) / 128, 128>>>( + deviceInputs.get(), deviceOutputs.get(), inputs.size()); + cudaCheck(cudaGetLastError()); + cudaCheck(cudaDeviceSynchronize()); + std::vector outputs(inputs.size()); + cudaCheck(cudaMemcpy(outputs.data(), + deviceOutputs.get(), + outputs.size() * sizeof(Output), + cudaMemcpyDeviceToHost)); + for (size_t i = 0; i < inputs.size(); ++i) { + const auto a = evaluate(inputs[i]); + const auto b = outputs[i]; + require(a.haltonKey == b.haltonKey, "Halton host/CUDA hash mismatch"); + checkCamera(inputs[i], b); + require(a.pixelKey == b.pixelKey && a.vertexKey == b.vertexKey + && a.raw == b.raw && a.reversed == b.reversed + && a.scrambled == b.scrambled && sameFloat(a.sample, b.sample) + && sameFloat(a.converted, b.converted) + && sameFloat(a.hemi.x, b.hemi.x) && sameFloat(a.hemi.y, b.hemi.y), + "host/device mismatch at vector " + std::to_string(i)); + } + std::cout << inputs.size() << " exact host/CUDA vector comparisons\n"; +} +#endif + +inline int run() +try { + // Direct endpoints exercise production conversion, not accidental samples. + require(visrtx::sobolFloat(0) == 0.f && visrtx::sobolFloat(0xffu) == 0.f + && visrtx::sobolFloat(0x100u) == 0x1p-24f + && visrtx::sobolFloat(0xffffffffu) == 0x1.fffffep-1f, + "24-bit conversion endpoints"); + require(visrtx::reverseBits32(0) == 0 + && visrtx::reverseBits32(1) == 0x80000000u + && visrtx::reverseBits32(0x01234567) == 0xe6a2c480u + && visrtx::reverseBits32(0xffffffff) == 0xffffffff, + "known-answer bit reversal"); + const auto reference = referenceColumns(); + std::vector inputs; + checkHalton(inputs); + unsigned failures = 0; + for (unsigned d = 0; d < 16; ++d) { + for (unsigned bit = 0; bit < 32; ++bit) { + const uint32_t index = uint32_t(1) << bit; + const auto actual = visrtx::sobolUInt(index, d); + if (actual != reference[d][bit]) { + std::cerr << "dimension " << d << ", column " << bit << ": actual " + << std::hex << actual << ", expected " << reference[d][bit] + << std::dec << '\n'; + ++failures; + } + inputs.push_back({index, d, 0}); + } + } + require(failures == 0, "direction columns disagree with independent oracle"); + require(visrtx::sobolUInt(16, 7) == 0x88000000u, + "dimension 7 column 4 regression"); + + std::ifstream vectors(SOBOL_VECTOR_FILE); + require(bool(vectors), "cannot open known-answer vectors"); + std::string line; + std::getline(vectors, line); + std::getline(vectors, line); + Input in{}; + uint32_t raw, reversed, scrambled, grid; + unsigned vectorCount = 0; + while (vectors >> std::hex >> in.index >> in.dimension >> in.seed >> raw + >> reversed >> scrambled >> grid) { + const auto actual = evaluate(in); + require(actual.raw == raw, "binary-index integer vector"); + require(actual.reversed == reversed, "bit reversal vector"); + require(pinned::FastOwenScrambler( + in.seed ^ (0x9e3779b9u * (in.dimension + 1u)))(raw) + == scrambled, + "offline fixture disagrees with pinned FastOwen operations"); + require(actual.scrambled == scrambled, "FastOwen integer vector"); + // All integers <= 2^24-1 are exactly representable as float; scaling by + // a power of two is exact. Float expectations are separate from scramble. + require(sameFloat(actual.sample, std::ldexp(float(grid), -24)), + "float grid vector"); + require(actual.sample >= 0 && actual.sample < 1 + && std::ldexp(actual.sample, 24) + == std::floor(std::ldexp(actual.sample, 24)), + "sample outside exact half-open grid"); + require(actual.hemi.x == visrtx::owenSobol(in.index, 0, in.seed) + && actual.hemi.y == visrtx::owenSobol(in.index, 1, in.seed), + "transport hemisphere component mapping"); + inputs.push_back(in); + ++vectorCount; + } + require( + vectors.eof() && vectorCount == 480, "incomplete known-answer fixture"); + for (uint32_t seed : {0u, 0x12345678u, 0xffffffffu}) { + for (unsigned d = 0; d < 16; ++d) { + for (unsigned m = 1; m <= 10; ++m) { + const unsigned n = 1u << m; + std::vector occupied(n, false); + for (unsigned i = 0; i < n; ++i) { + const auto sample = visrtx::owenSobol(i, d, seed); + const unsigned bin = unsigned(sample * n); + require(bin < n && !occupied[bin], "dyadic 1D stratum repeated"); + occupied[bin] = true; + } + } + } + } + for (uint32_t endpoint : {0u, 0xffu, 0x100u, 0xffffffffu}) + inputs.push_back({endpoint, 0, 0}); +#ifdef SOBOL_CUDA + checkDevice(inputs); +#endif + std::cout << "512 columns, 480 vectors, endpoints and all 1D strata pass\n"; + return 0; +} catch (const std::exception &e) { + std::cerr << e.what() << '\n'; + return 1; +} + +} // namespace sobol_test diff --git a/devices/rtx/apps/tests/unit/sobol/test_reference.py b/devices/rtx/apps/tests/unit/sobol/test_reference.py new file mode 100644 index 000000000..0a8e05fdb --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/test_reference.py @@ -0,0 +1,100 @@ +# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause +"""Offline failure-preservation tests for reference fixture publication.""" + +from contextlib import redirect_stderr, redirect_stdout +import io +from pathlib import Path +import re +import tempfile +import unittest +from unittest.mock import patch + +import reference + + +class ReferencePublicationTest(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory() + self.addCleanup(self.temporary.cleanup) + self.root = Path(self.temporary.name) + self.outputs = self.root / "output" + self.outputs.mkdir() + for name in ("NOTICE", "joe-kuo.txt", "vectors.txt", "sobolDirections.h"): + (self.outputs / name).write_bytes(b"unchanged " + name.encode()) + self.original = {p.name: p.read_bytes() for p in self.outputs.iterdir()} + here = Path(__file__).resolve().parent + # Synthetic inputs exercise publication, not numeric correctness (which + # has independent tests). Only the source trust gate is stubbed in tests + # explicitly using accepted_inputs; production validation stays intact. + header = (here.parents[3] / "device/gpu/sobolDirections.h").read_text() + words = re.findall(r"0x[0-9a-f]+u", header) + self.assertEqual(len(words), 512) + padded = [] + for i in range(16): + padded += words[i * 32:(i + 1) * 32] + ["0x00000000u"] * 20 + self.source = self.root / "pbrt.cpp" + self.source.write_text("// synthetic notice\n#include \n" + "uint32_t SobolMatrices32[] = {" + ",".join(padded) + "};\n") + self.parameters = self.root / "joe-kuo.txt" + self.parameters.write_bytes(b"".join( + (here / "joe-kuo.txt").read_bytes().splitlines(keepends=True)[3:])) + self.args = [str(self.source), str(self.parameters), "--table", + str(self.outputs / "sobolDirections.h")] + + def unchanged(self): + self.assertEqual({p.name: p.read_bytes() for p in self.outputs.iterdir()}, + self.original) + + def invoke(self, extra=()): + with patch.object(reference, "HERE", self.outputs), \ + redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()): + reference.main(self.args + list(extra)) + + def test_untrusted_input_leaves_outputs_unchanged(self): + with self.assertRaises(SystemExit) as error: + self.invoke() + self.assertEqual(error.exception.code, 2) + self.unchanged() + + def test_oracle_disagreement_leaves_outputs_unchanged(self): + self.source.write_text(self.source.read_text().replace("0x80000000u", "0x80000001u", 1)) + with patch.object(reference, "check_source"), self.assertRaisesRegex(SystemExit, "STOP"): + self.invoke() + self.unchanged() + + def test_late_input_read_failure_leaves_outputs_unchanged(self): + with patch.object(reference, "check_source"), self.assertRaises(FileNotFoundError): + self.invoke(["--pbrt-license", str(self.root / "missing-license")]) + self.unchanged() + + def test_staging_failure_removes_temporary_files(self): + create = tempfile.mkstemp + calls = 0 + + def fail_second(*args, **kwargs): + nonlocal calls + calls += 1 + if calls == 2: + raise OSError("simulated staging failure") + return create(*args, **kwargs) + + with patch.object(reference, "check_source"), \ + patch.object(reference.tempfile, "mkstemp", side_effect=fail_second), \ + self.assertRaisesRegex(OSError, "staging failure"): + self.invoke() + self.unchanged() + + def test_success_publishes_complete_header(self): + with patch.object(reference, "check_source"): + self.invoke() + self.assertEqual(set(p.name for p in self.outputs.iterdir()), set(self.original)) + self.assertIn(b"#pragma once", (self.outputs / "sobolDirections.h").read_bytes()) + self.assertIn(b"synthetic notice", (self.outputs / "NOTICE").read_bytes()) + self.assertNotEqual((self.outputs / "joe-kuo.txt").read_bytes(), self.original["joe-kuo.txt"]) + # Vectors were not requested: leave them byte-for-byte alone. + self.assertEqual((self.outputs / "vectors.txt").read_bytes(), self.original["vectors.txt"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/devices/rtx/apps/tests/unit/sobol/test_table_header.py b/devices/rtx/apps/tests/unit/sobol/test_table_header.py new file mode 100644 index 000000000..e250acc59 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/test_table_header.py @@ -0,0 +1,42 @@ +# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause +"""Offline byte-for-byte regeneration gate for the production table header.""" + +from pathlib import Path +import unittest + +from table_header import table_header + + +class TableHeaderTest(unittest.TestCase): + def test_complete_header_matches(self): + here = Path(__file__).resolve().parent + # Retain the upstream notice independently of the production header. + notice, separator, _ = (here / "NOTICE").read_text(encoding="utf-8").partition( + "\nVisRTX modification:") + self.assertTrue(separator) + # Regenerate columns from the independent parameter fixture, not from + # the header being compared. Dimension zero is the standard special case. + columns = [[1 << (31 - i) for i in range(32)]] + for line in (here / "joe-kuo.txt").read_text(encoding="utf-8").splitlines(): + if not line.strip() or not line.lstrip()[0].isdigit(): + continue + dimension, degree, coefficients, *initial = map(int, line.split()) + self.assertEqual(dimension, len(columns) + 1) + self.assertEqual(len(initial), degree) + row = [initial[i] << (31 - i) for i in range(degree)] + for i in range(degree, 32): + value = row[i - degree] ^ (row[i - degree] >> degree) + for k in range(1, degree): + if coefficients & (1 << (degree - 1 - k)): + value ^= row[i - k] + row.append(value) + columns.append(row) + self.assertEqual(len(columns), 16) + expected = here.parents[3] / "device/gpu/sobolDirections.h" + self.assertEqual(table_header(notice, columns).encode("utf-8"), + expected.read_bytes()) + + +if __name__ == "__main__": + unittest.main() diff --git a/devices/rtx/apps/tests/unit/sobol/vectors.txt b/devices/rtx/apps/tests/unit/sobol/vectors.txt new file mode 100644 index 000000000..3cdff397c --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/vectors.txt @@ -0,0 +1,482 @@ +# pbrt/Joe-Kuo binary-index vectors. See README and LICENSE.pbrt. +# index dimension pixelSeed raw reversed scrambled grid24 +00000000 00000000 00000000 00000000 00000000 855db73c 00855db7 +00000000 00000000 12345678 00000000 00000000 a51900df 00a51900 +00000000 00000000 ffffffff 00000000 00000000 5a2a09a6 005a2a09 +00000000 00000001 00000000 00000000 00000000 4d4d83e7 004d4d83 +00000000 00000001 12345678 00000000 00000000 49ef6b62 0049ef6b +00000000 00000001 ffffffff 00000000 00000000 f204213e 00f20421 +00000000 00000002 00000000 00000000 00000000 fcfe45a5 00fcfe45 +00000000 00000002 12345678 00000000 00000000 ccf7f0aa 00ccf7f0 +00000000 00000002 ffffffff 00000000 00000000 3e553742 003e5537 +00000000 00000003 00000000 00000000 00000000 3b8b8c8b 003b8b8c +00000000 00000003 12345678 00000000 00000000 21d83ac6 0021d83a +00000000 00000003 ffffffff 00000000 00000000 def8c6b6 00def8c6 +00000000 00000004 00000000 00000000 00000000 d013b88f 00d013b8 +00000000 00000004 12345678 00000000 00000000 e7269ffb 00e7269f +00000000 00000004 ffffffff 00000000 00000000 5a015a0f 005a015a +00000000 00000005 00000000 00000000 00000000 458eb72f 00458eb7 +00000000 00000005 12345678 00000000 00000000 40d1b9ff 0040d1b9 +00000000 00000005 ffffffff 00000000 00000000 b9a5ec6c 00b9a5ec +00000000 00000006 00000000 00000000 00000000 bd995566 00bd9955 +00000000 00000006 12345678 00000000 00000000 93d2536e 0093d253 +00000000 00000006 ffffffff 00000000 00000000 0e4610e4 000e4610 +00000000 00000007 00000000 00000000 00000000 1414e999 001414e9 +00000000 00000007 12345678 00000000 00000000 0ec10910 000ec109 +00000000 00000007 ffffffff 00000000 00000000 a8e3d93f 00a8e3d9 +00000000 00000008 00000000 00000000 00000000 ae93cbe2 00ae93cb +00000000 00000008 12345678 00000000 00000000 8e1b0a7c 008e1b0a +00000000 00000008 ffffffff 00000000 00000000 56ba0ba5 0056ba0b +00000000 00000009 00000000 00000000 00000000 404c8e77 00404c8e +00000000 00000009 12345678 00000000 00000000 43c497e8 0043c497 +00000000 00000009 ffffffff 00000000 00000000 cf3bccce 00cf3bcc +00000000 0000000a 00000000 00000000 00000000 c2c9391c 00c2c939 +00000000 0000000a 12345678 00000000 00000000 f6bd3913 00f6bd39 +00000000 0000000a ffffffff 00000000 00000000 27275f08 0027275f +00000000 0000000b 00000000 00000000 00000000 2b0b67e0 002b0b67 +00000000 0000000b 12345678 00000000 00000000 36acb309 0036acb3 +00000000 0000000b ffffffff 00000000 00000000 e304ad63 00e304ad +00000000 0000000c 00000000 00000000 00000000 ec067be7 00ec067b +00000000 0000000c 12345678 00000000 00000000 ddccd8ec 00ddccd8 +00000000 0000000c ffffffff 00000000 00000000 50f67f9f 0050f67f +00000000 0000000d 00000000 00000000 00000000 48901508 00489015 +00000000 0000000d 12345678 00000000 00000000 4b82f814 004b82f8 +00000000 0000000d ffffffff 00000000 00000000 9c5c8caa 009c5c8c +00000000 0000000e 00000000 00000000 00000000 9d8f5569 009d8f55 +00000000 0000000e 12345678 00000000 00000000 b5f110bb 00b5f110 +00000000 0000000e ffffffff 00000000 00000000 16b07df0 0016b07d +00000000 0000000f 00000000 00000000 00000000 086ab1bc 00086ab1 +00000000 0000000f 12345678 00000000 00000000 133debc5 00133deb +00000000 0000000f ffffffff 00000000 00000000 94b3729f 0094b372 +00000001 00000000 00000000 80000000 00000001 23eb314f 0023eb31 +00000001 00000000 12345678 80000000 00000001 35a711c5 0035a711 +00000001 00000000 ffffffff 80000000 00000001 c3751228 00c37512 +00000001 00000001 00000000 80000000 00000001 a9ea5ef0 00a9ea5e +00000001 00000001 12345678 80000000 00000001 9cbd2152 009cbd21 +00000001 00000001 ffffffff 80000000 00000001 10ac1576 0010ac15 +00000001 00000002 00000000 80000000 00000001 7d23b46b 007d23b4 +00000001 00000002 12345678 80000000 00000001 7fc08d73 007fc08d +00000001 00000002 ffffffff 80000000 00000001 94e49979 0094e499 +00000001 00000003 00000000 80000000 00000001 ac44fbd7 00ac44fb +00000001 00000003 12345678 80000000 00000001 810e59ea 00810e59 +00000001 00000003 ffffffff 80000000 00000001 67e2461d 0067e246 +00000001 00000004 00000000 80000000 00000001 1c0a758e 001c0a75 +00000001 00000004 12345678 80000000 00000001 0f9c3237 000f9c32 +00000001 00000004 ffffffff 80000000 00000001 88449c41 0088449c +00000001 00000005 00000000 80000000 00000001 fdb7cd5c 00fdb7cd +00000001 00000005 12345678 80000000 00000001 db26de2f 00db26de +00000001 00000005 ffffffff 80000000 00000001 20e67929 0020e679 +00000001 00000006 00000000 80000000 00000001 6e7aa02b 006e7aa0 +00000001 00000006 12345678 80000000 00000001 6866b1a9 006866b1 +00000001 00000006 ffffffff 80000000 00000001 c0f785d5 00c0f785 +00000001 00000007 00000000 80000000 00000001 d7637f39 00d7637f +00000001 00000007 12345678 80000000 00000001 e816d458 00e816d4 +00000001 00000007 ffffffff 80000000 00000001 7418f2ca 007418f2 +00000001 00000008 00000000 80000000 00000001 34553533 00345535 +00000001 00000008 12345678 80000000 00000001 239c3689 00239c36 +00000001 00000008 ffffffff 80000000 00000001 ea139782 00ea1397 +00000001 00000009 00000000 80000000 00000001 9ae9f401 009ae9f4 +00000001 00000009 12345678 80000000 00000001 aef57261 00aef572 +00000001 00000009 ffffffff 80000000 00000001 09572e8d 0009572e +00000001 0000000a 00000000 80000000 00000001 7cd195e2 007cd195 +00000001 0000000a 12345678 80000000 00000001 7e6c4e3d 007e6c4e +00000001 0000000a ffffffff 80000000 00000001 b4cdfd21 00b4cdfd +00000001 0000000b 00000000 80000000 00000001 84d1847a 0084d184 +00000001 0000000b 12345678 80000000 00000001 aa8e840b 00aa8e84 +00000001 0000000b ffffffff 80000000 00000001 611adfa5 00611adf +00000001 0000000c 00000000 80000000 00000001 0ebf7ada 000ebf7a +00000001 0000000c 12345678 80000000 00000001 1c2e82c8 001c2e82 +00000001 0000000c ffffffff 80000000 00000001 ba3a8373 00ba3a83 +00000001 0000000d 00000000 80000000 00000001 da0ace98 00da0ace +00000001 0000000d 12345678 80000000 00000001 ff36d6aa 00ff36d6 +00000001 0000000d ffffffff 80000000 00000001 3b48e8e3 003b48e8 +00000001 0000000e 00000000 80000000 00000001 6958a51e 006958a5 +00000001 0000000e 12345678 80000000 00000001 6f0dc24c 006f0dc2 +00000001 0000000e ffffffff 80000000 00000001 fb356029 00fb3560 +00000001 0000000f 00000000 80000000 00000001 fbc4c5c8 00fbc4c5 +00000001 0000000f 12345678 80000000 00000001 c06bf823 00c06bf8 +00000001 0000000f ffffffff 80000000 00000001 74b75dfd 0074b75d +00000002 00000000 00000000 40000000 00000002 c1bab68b 00c1bab6 +00000002 00000000 12345678 40000000 00000002 e4eb6c27 00e4eb6c +00000002 00000000 ffffffff 40000000 00000002 218eebe8 00218eeb +00000002 00000001 00000000 c0000000 00000003 d19ae9da 00d19ae9 +00000002 00000001 12345678 c0000000 00000003 f7bd34d4 00f7bd34 +00000002 00000001 ffffffff c0000000 00000003 76d82250 0076d822 +00000002 00000002 00000000 c0000000 00000003 17268edd 0017268e +00000002 00000002 12345678 c0000000 00000003 0a73120f 000a7312 +00000002 00000002 ffffffff c0000000 00000003 ce05758c 00ce0575 +00000002 00000003 00000000 c0000000 00000003 f4f902cd 00f4f902 +00000002 00000003 12345678 c0000000 00000003 d55a54c6 00d55a54 +00000002 00000003 ffffffff c0000000 00000003 1b8fe641 001b8fe6 +00000002 00000004 00000000 40000000 00000002 8ab76bfe 008ab76b +00000002 00000004 12345678 40000000 00000002 b18206a7 00b18206 +00000002 00000004 ffffffff 40000000 00000002 1fa5c627 001fa5c6 +00000002 00000005 00000000 40000000 00000002 234e3534 00234e35 +00000002 00000005 12345678 40000000 00000002 30c01ba8 0030c01b +00000002 00000005 ffffffff 40000000 00000002 fe34bcf8 00fe34bc +00000002 00000006 00000000 c0000000 00000003 217fe08e 00217fe0 +00000002 00000006 12345678 c0000000 00000003 3d23d052 003d23d0 +00000002 00000006 ffffffff c0000000 00000003 83846244 00838462 +00000002 00000007 00000000 40000000 00000002 77d8e080 0077d8e0 +00000002 00000007 12345678 40000000 00000002 7cd46256 007cd462 +00000002 00000007 ffffffff 40000000 00000002 d4b98960 00d4b989 +00000002 00000008 00000000 40000000 00000002 e87db09f 00e87db0 +00000002 00000008 12345678 40000000 00000002 cf387d30 00cf387d +00000002 00000008 ffffffff 40000000 00000002 36574574 00365745 +00000002 00000009 00000000 40000000 00000002 0b164894 000b1648 +00000002 00000009 12345678 40000000 00000002 1e896dfa 001e896d +00000002 00000009 ffffffff 40000000 00000002 9818a7e3 009818a7 +00000002 0000000a 00000000 40000000 00000002 b646c530 00b646c5 +00000002 0000000a 12345678 40000000 00000002 9886d784 009886d7 +00000002 0000000a ffffffff 40000000 00000002 7f8ee4fa 007f8ee4 +00000002 0000000b 00000000 40000000 00000002 629d79d1 00629d79 +00000002 0000000b 12345678 40000000 00000002 6e592ca3 006e592c +00000002 0000000b ffffffff 40000000 00000002 87e1d872 0087e1d8 +00000002 0000000c 00000000 c0000000 00000003 682b0ff4 00682b0f +00000002 0000000c 12345678 c0000000 00000003 6af1d332 006af1d3 +00000002 0000000c ffffffff c0000000 00000003 c2a213be 00c2a213 +00000002 0000000d 00000000 c0000000 00000003 acf76503 00acf765 +00000002 0000000d 12345678 c0000000 00000003 9f6dbda8 009f6dbd +00000002 0000000d ffffffff c0000000 00000003 60cad8b9 0060cad8 +00000002 0000000e 00000000 40000000 00000002 f93a201c 00f93a20 +00000002 0000000e 12345678 40000000 00000002 c9ecc397 00c9ecc3 +00000002 0000000e ffffffff 40000000 00000002 6b78dba1 006b78db +00000002 0000000f 00000000 c0000000 00000003 bd777fd2 00bd777f +00000002 0000000f 12345678 c0000000 00000003 89a4ce5a 0089a4ce +00000002 0000000f ffffffff c0000000 00000003 28db0c04 0028db0c +00000003 00000000 00000000 c0000000 00000003 7de72079 007de720 +00000003 00000000 12345678 c0000000 00000003 7b18b92f 007b18b9 +00000003 00000000 ffffffff c0000000 00000003 b2f2e655 00b2f2e6 +00000003 00000001 00000000 40000000 00000002 120a8321 00120a83 +00000003 00000001 12345678 40000000 00000002 07ab7d32 0007ab7d +00000003 00000001 ffffffff 40000000 00000002 aa80fa7a 00aa80fa +00000003 00000002 00000000 40000000 00000002 966c3649 00966c36 +00000003 00000002 12345678 40000000 00000002 be160ca1 00be160c +00000003 00000002 ffffffff 40000000 00000002 7eb238d9 007eb238 +00000003 00000003 00000000 40000000 00000002 64642d1a 0064642d +00000003 00000003 12345678 40000000 00000002 68140e5b 0068140e +00000003 00000003 ffffffff 40000000 00000002 afcfcb31 00afcfcb +00000003 00000004 00000000 c0000000 00000003 6f6d7222 006f6d72 +00000003 00000004 12345678 c0000000 00000003 6e0c08e7 006e0c08 +00000003 00000004 ffffffff c0000000 00000003 ecbac081 00ecbac0 +00000003 00000005 00000000 c0000000 00000003 9bae0a63 009bae0a +00000003 00000005 12345678 c0000000 00000003 aa87aa61 00aa87aa +00000003 00000005 ffffffff c0000000 00000003 668505ed 00668505 +00000003 00000006 00000000 40000000 00000002 c264e649 00c264e6 +00000003 00000006 12345678 40000000 00000002 f6429225 00f64292 +00000003 00000006 ffffffff 40000000 00000002 6ca856f7 006ca856 +00000003 00000007 00000000 c0000000 00000003 97ff65c8 0097ff65 +00000003 00000007 12345678 c0000000 00000003 a2219474 00a22194 +00000003 00000007 ffffffff c0000000 00000003 37ff75ee 0037ff75 +00000003 00000008 00000000 c0000000 00000003 7cb3049a 007cb304 +00000003 00000008 12345678 c0000000 00000003 7b3cc777 007b3cc7 +00000003 00000008 ffffffff c0000000 00000003 86055e45 0086055e +00000003 00000009 00000000 c0000000 00000003 f5832e2d 00f5832e +00000003 00000009 12345678 c0000000 00000003 d0d1d390 00d0d1d3 +00000003 00000009 ffffffff c0000000 00000003 7496b8ea 007496b8 +00000003 0000000a 00000000 c0000000 00000003 0d54ac23 000d54ac +00000003 0000000a 12345678 c0000000 00000003 118ec00c 00118ec0 +00000003 0000000a ffffffff c0000000 00000003 e55a30b1 00e55a30 +00000003 0000000b 00000000 c0000000 00000003 d773376b 00d77337 +00000003 0000000b 12345678 c0000000 00000003 f47199fc 00f47199 +00000003 0000000b ffffffff c0000000 00000003 09df0958 0009df09 +00000003 0000000c 00000000 40000000 00000002 b96f7030 00b96f70 +00000003 0000000c 12345678 40000000 00000002 80c2dea4 0080c2de +00000003 0000000c ffffffff 40000000 00000002 0c3904c5 000c3904 +00000003 0000000d 00000000 40000000 00000002 38a6a277 0038a6a2 +00000003 0000000d 12345678 40000000 00000002 2abb4936 002abb49 +00000003 0000000d ffffffff 40000000 00000002 d82bf1d0 00d82bf1 +00000003 0000000e 00000000 c0000000 00000003 3817209f 00381720 +00000003 0000000e 12345678 c0000000 00000003 276b767e 00276b76 +00000003 0000000e ffffffff c0000000 00000003 b34211fd 00b34211 +00000003 0000000f 00000000 40000000 00000002 778a864b 00778a86 +00000003 0000000f 12345678 40000000 00000002 79a31dc0 0079a31d +00000003 0000000f ffffffff 40000000 00000002 f9d46cfa 00f9d46c +0000000f 00000000 00000000 f0000000 0000000f 42227062 00422270 +0000000f 00000000 12345678 f0000000 0000000f 4dcd5cc5 004dcd5c +0000000f 00000000 ffffffff f0000000 0000000f 9ac20bb9 009ac20b +0000000f 00000001 00000000 10000000 00000008 5eea3b8a 005eea3b +0000000f 00000001 12345678 10000000 00000008 5d6981a6 005d6981 +0000000f 00000001 ffffffff 10000000 00000008 eebdd8e7 00eebdd8 +0000000f 00000002 00000000 b0000000 0000000d 5a215c96 005a215c +0000000f 00000002 12345678 b0000000 0000000d 5783df09 005783df +0000000f 00000002 ffffffff b0000000 0000000d bd5849e3 00bd5849 +0000000f 00000003 00000000 30000000 0000000c 1153b099 001153b0 +0000000f 00000003 12345678 30000000 0000000c 0d2af8f7 000d2af8 +0000000f 00000003 ffffffff 30000000 0000000c fca1da96 00fca1da +0000000f 00000004 00000000 50000000 0000000a 9685fb36 009685fb +0000000f 00000004 12345678 50000000 0000000a ae581912 00ae5819 +0000000f 00000004 ffffffff 50000000 0000000a 0a0efbe9 000a0efb +0000000f 00000005 00000000 90000000 00000009 ef0bec69 00ef0bec +0000000f 00000005 12345678 90000000 00000009 c5dafa76 00c5dafa +0000000f 00000005 ffffffff 90000000 00000009 3b4df7e2 003b4df7 +0000000f 00000006 00000000 30000000 0000000c 8e3f0fec 008e3f0f +0000000f 00000006 12345678 30000000 0000000c b5b7e5c6 00b5b7e5 +0000000f 00000006 ffffffff 30000000 0000000c 289a5c92 00289a5c +0000000f 00000007 00000000 30000000 0000000c 3aa80323 003aa803 +0000000f 00000007 12345678 30000000 0000000c 25348700 00253487 +0000000f 00000007 ffffffff 30000000 0000000c 9d96e880 009d96e8 +0000000f 00000008 00000000 30000000 0000000c 8f1b507d 008f1b50 +0000000f 00000008 12345678 30000000 0000000c b7e9fb2e 00b7e9fb +0000000f 00000008 ffffffff 30000000 0000000c 71e8c622 0071e8c6 +0000000f 00000009 00000000 90000000 00000009 8c3e9cde 008c3e9c +0000000f 00000009 12345678 90000000 00000009 b95cae96 00b95cae +0000000f 00000009 ffffffff 90000000 00000009 170456b4 00170456 +0000000f 0000000a 00000000 70000000 0000000e 8634dde3 008634dd +0000000f 0000000a 12345678 70000000 0000000e b9f7ec73 00b9f7ec +0000000f 0000000a ffffffff 70000000 0000000e 5c39478d 005c3947 +0000000f 0000000b 00000000 d0000000 0000000b c9ad13ad 00c9ad13 +0000000f 0000000b 12345678 d0000000 0000000b e1eb8de6 00e1eb8d +0000000f 0000000b ffffffff d0000000 0000000b 1f301216 001f3012 +0000000f 0000000c 00000000 b0000000 0000000d 38b4d007 0038b4d0 +0000000f 0000000c 12345678 b0000000 0000000d 22c95850 0022c958 +0000000f 0000000c ffffffff b0000000 0000000d 97296fa6 0097296f +0000000f 0000000d 00000000 b0000000 0000000d ec1b5d26 00ec1b5d +0000000f 0000000d 12345678 b0000000 0000000d d6d7381f 00d6d738 +0000000f 0000000d ffffffff b0000000 0000000d 0bd387ca 000bd387 +0000000f 0000000e 00000000 10000000 00000008 8bad3696 008bad36 +0000000f 0000000e 12345678 10000000 00000008 ad6f6dda 00ad6f6d +0000000f 0000000e ffffffff 10000000 00000008 01c345ac 0001c345 +0000000f 0000000f 00000000 b0000000 0000000d cb709399 00cb7093 +0000000f 0000000f 12345678 b0000000 0000000d e5a870f7 00e5a870 +0000000f 0000000f ffffffff b0000000 0000000d 4b2cab9a 004b2cab +00000010 00000000 00000000 08000000 00000010 8edcba9d 008edcba +00000010 00000000 12345678 08000000 00000010 a9d0db35 00a9d0db +00000010 00000000 ffffffff 08000000 00000010 5587585c 00558758 +00000010 00000001 00000000 88000000 00000011 a108aede 00a108ae +00000010 00000001 12345678 88000000 00000011 96097fef 0096097f +00000010 00000001 ffffffff 88000000 00000011 1db4e65d 001db4e6 +00000010 00000002 00000000 e8000000 00000017 32bc48fa 0032bc48 +00000010 00000002 12345678 e8000000 00000017 2c3e2c1e 002c3e2c +00000010 00000002 ffffffff e8000000 00000017 f1da0c13 00f1da0c +00000010 00000003 00000000 f8000000 0000001f c50ba063 00c50ba0 +00000010 00000003 12345678 f8000000 0000001f f8b290a8 00f8b290 +00000010 00000003 ffffffff f8000000 0000001f 2e858120 002e8581 +00000010 00000004 00000000 f8000000 0000001f 45c2fee3 0045c2fe +00000010 00000004 12345678 f8000000 0000001f 4c6a4f6a 004c6a4f +00000010 00000004 ffffffff f8000000 0000001f c2314af3 00c2314a +00000010 00000005 00000000 c8000000 00000013 902850dc 00902850 +00000010 00000005 12345678 c8000000 00000013 a0b417f2 00a0b417 +00000010 00000005 ffffffff c8000000 00000013 6a5bc5bb 006a5bc5 +00000010 00000006 00000000 58000000 0000001a d2f76069 00d2f760 +00000010 00000006 12345678 58000000 0000001a e42b5aa6 00e42b5a +00000010 00000006 ffffffff 58000000 0000001a 7a4d257d 007a4d25 +00000010 00000007 00000000 88000000 00000011 da22464e 00da2246 +00000010 00000007 12345678 88000000 00000011 e243e89b 00e243e8 +00000010 00000007 ffffffff 88000000 00000011 7ffdf021 007ffdf0 +00000010 00000008 00000000 28000000 00000014 923b961b 00923b96 +00000010 00000008 12345678 28000000 00000014 aaedae91 00aaedae +00000010 00000008 ffffffff 28000000 00000014 655d66ee 00655d66 +00000010 00000009 00000000 98000000 00000019 8786fac2 008786fa +00000010 00000009 12345678 98000000 00000019 b079cbc5 00b079cb +00000010 00000009 ffffffff 98000000 00000019 1c6eb21a 001c6eb2 +00000010 0000000a 00000000 08000000 00000010 cb3da5b3 00cb3da5 +00000010 0000000a 12345678 08000000 00000010 fcafeab2 00fcafea +00000010 0000000a ffffffff 08000000 00000010 2adf9dd0 002adf9d +00000010 0000000b 00000000 58000000 0000001a 7b105a37 007b105a +00000010 0000000b 12345678 58000000 0000001a 706f36fb 00706f36 +00000010 0000000b ffffffff 58000000 0000001a 9b0d578f 009b0d57 +00000010 0000000c 00000000 f8000000 0000001f 489ab981 00489ab9 +00000010 0000000c 12345678 f8000000 0000001f 418f1fcb 00418f1f +00000010 0000000c ffffffff f8000000 0000001f fa964293 00fa9642 +00000010 0000000d 00000000 38000000 0000001c 62662ec6 0062662e +00000010 0000000d 12345678 38000000 0000001c 68974824 00689748 +00000010 0000000d ffffffff 38000000 0000001c aee4ee6f 00aee4ee +00000010 0000000e 00000000 a8000000 00000015 42c191c3 0042c191 +00000010 0000000e 12345678 a8000000 00000015 4a69b43a 004a69b4 +00000010 0000000e ffffffff a8000000 00000015 dd3d51a3 00dd3d51 +00000010 0000000f 00000000 d8000000 0000001b aa504019 00aa5040 +00000010 0000000f 12345678 d8000000 0000001b 9cee0049 009cee00 +00000010 0000000f ffffffff d8000000 0000001b 36ea2afe 0036ea2a +0000001f 00000000 00000000 f8000000 0000001f 4dab69af 004dab69 +0000001f 00000000 12345678 f8000000 0000001f 474f200c 00474f20 +0000001f 00000000 ffffffff f8000000 0000001f 9373fe14 009373fe +0000001f 00000001 00000000 98000000 00000019 b5edae2b 00b5edae +0000001f 00000001 12345678 98000000 00000019 8102e875 008102e8 +0000001f 00000001 ffffffff 98000000 00000019 0ead3100 000ead31 +0000001f 00000002 00000000 58000000 0000001a 8158a833 008158a8 +0000001f 00000002 12345678 58000000 0000001a a0afda37 00a0afda +0000001f 00000002 ffffffff 58000000 0000001a 6ed94fcb 006ed94f +0000001f 00000003 00000000 c8000000 00000013 fffd5cef 00fffd5c +0000001f 00000003 12345678 c8000000 00000013 d969cb4e 00d969cb +0000001f 00000003 ffffffff c8000000 00000013 12f072a9 0012f072 +0000001f 00000004 00000000 a8000000 00000015 39b54874 0039b548 +0000001f 00000004 12345678 a8000000 00000015 2819c3ca 002819c3 +0000001f 00000004 ffffffff a8000000 00000015 a449b585 00a449b5 +0000001f 00000005 00000000 58000000 0000001a 33e2a608 0033e2a6 +0000001f 00000005 12345678 58000000 0000001a 2ed81f26 002ed81f +0000001f 00000005 ffffffff 58000000 0000001a e321c480 00e321c4 +0000001f 00000006 00000000 68000000 00000016 f47dd36d 00f47dd3 +0000001f 00000006 12345678 68000000 00000016 dfaae440 00dfaae4 +0000001f 00000006 ffffffff 68000000 00000016 473ffc12 00473ffc +0000001f 00000007 00000000 b8000000 0000001d f6b32362 00f6b323 +0000001f 00000007 12345678 b8000000 0000001d d21bbea1 00d21bbe +0000001f 00000007 ffffffff b8000000 0000001d 4fa5796b 004fa579 +0000001f 00000008 00000000 18000000 00000018 b8791b94 00b8791b +0000001f 00000008 12345678 18000000 00000018 9589ee41 009589ee +0000001f 00000008 ffffffff 18000000 00000018 4e8ec8de 004e8ec8 +0000001f 00000009 00000000 08000000 00000010 4bbe0617 004bbe06 +0000001f 00000009 12345678 08000000 00000010 4ba0e9ca 004ba0e9 +0000001f 00000009 ffffffff 08000000 00000010 c46d17b0 00c46d17 +0000001f 0000000a 00000000 78000000 0000001e 8fbefcd9 008fbefc +0000001f 0000000a 12345678 78000000 0000001e b513f7ce 00b513f7 +0000001f 0000000a ffffffff 78000000 0000001e 50c4107d 0050c410 +0000001f 0000000b 00000000 88000000 00000011 8a1c025b 008a1c02 +0000001f 0000000b 12345678 88000000 00000011 a6ddc3b1 00a6ddc3 +0000001f 0000000b ffffffff 88000000 00000011 68c5be21 0068c5be +0000001f 0000000c 00000000 48000000 00000012 b60d2160 00b60d21 +0000001f 0000000c 12345678 48000000 00000012 89b01ec5 0089b01e +0000001f 0000000c ffffffff 48000000 00000012 003fa04b 00003fa0 +0000001f 0000000d 00000000 88000000 00000011 d4f5c4fc 00d4f5c4 +0000001f 0000000d 12345678 88000000 00000011 f67a9c15 00f67a9c +0000001f 0000000d ffffffff 88000000 00000011 33d054a9 0033d054 +0000001f 0000000e 00000000 b8000000 0000001d 5a408657 005a4086 +0000001f 0000000e 12345678 b8000000 0000001d 5492e852 005492e8 +0000001f 0000000e ffffffff b8000000 0000001d c318354d 00c31835 +0000001f 0000000f 00000000 68000000 00000016 5e3185a2 005e3185 +0000001f 0000000f 12345678 68000000 00000016 5cdd3d4a 005cdd3d +0000001f 0000000f ffffffff 68000000 00000016 d748d93d 00d748d9 +00000020 00000000 00000000 04000000 00000020 80a42435 0080a424 +00000020 00000000 12345678 04000000 00000020 a308aadb 00a308aa +00000020 00000000 ffffffff 04000000 00000020 5c378228 005c3782 +00000020 00000001 00000000 cc000000 00000033 dc9d1602 00dc9d16 +00000020 00000001 12345678 cc000000 00000033 fccb577a 00fccb57 +00000020 00000001 ffffffff cc000000 00000033 7c302028 007c3020 +00000020 00000002 00000000 5c000000 0000003a 87dbb4f4 0087dbb4 +00000020 00000002 12345678 5c000000 0000003a a563a5c0 00a563a5 +00000020 00000002 ffffffff 5c000000 0000003a 6959e679 006959e6 +00000020 00000003 00000000 74000000 0000002e 4e1acbe0 004e1acb +00000020 00000003 12345678 74000000 0000002e 4c9a57d6 004c9a57 +00000020 00000003 ffffffff 74000000 0000002e 9fa05eec 009fa05e +00000020 00000004 00000000 dc000000 0000003b 7d99dd8e 007d99dd +00000020 00000004 12345678 dc000000 0000003b 7a95e1cf 007a95e1 +00000020 00000004 ffffffff dc000000 0000003b f5141386 00f51413 +00000020 00000005 00000000 24000000 00000024 7880c4da 007880c4 +00000020 00000005 12345678 24000000 00000024 74f07c5c 0074f07c +00000020 00000005 ffffffff 24000000 00000024 8d21a9df 008d21a9 +00000020 00000006 00000000 94000000 00000029 7656f100 007656f1 +00000020 00000006 12345678 94000000 00000029 759af81b 00759af8 +00000020 00000006 ffffffff 94000000 00000029 dfb3bf0b 00dfb3bf +00000020 00000007 00000000 24000000 00000024 2448820b 00244882 +00000020 00000007 12345678 24000000 00000024 36ad43ab 0036ad43 +00000020 00000007 ffffffff 24000000 00000024 8d0939a3 008d0939 +00000020 00000008 00000000 d4000000 0000002b 6603ea58 006603ea +00000020 00000008 12345678 d4000000 0000002b 6510919c 00651091 +00000020 00000008 ffffffff d4000000 0000002b 910bb52c 00910bb5 +00000020 00000009 00000000 94000000 00000029 88dd042a 0088dd04 +00000020 00000009 12345678 94000000 00000029 bf1d8865 00bf1d88 +00000020 00000009 ffffffff 94000000 00000029 106d6b16 00106d6b +00000020 0000000a 00000000 6c000000 00000036 9817285a 00981728 +00000020 0000000a 12345678 6c000000 00000036 a5d9cf5b 00a5d9cf +00000020 0000000a ffffffff 6c000000 00000036 44e27a34 0044e27a +00000020 0000000b 00000000 ac000000 00000035 b736093a 00b73609 +00000020 0000000b 12345678 ac000000 00000035 84f51286 0084f512 +00000020 0000000b ffffffff ac000000 00000035 5ac099bf 005ac099 +00000020 0000000c 00000000 8c000000 00000031 056c5f95 00056c5f +00000020 0000000c 12345678 8c000000 00000031 117eb5ac 00117eb5 +00000020 0000000c ffffffff 8c000000 00000031 b2a1b9ce 00b2a1b9 +00000020 0000000d 00000000 c4000000 00000023 a81dcd4f 00a81dcd +00000020 0000000d 12345678 c4000000 00000023 9862a0e5 009862a0 +00000020 0000000d ffffffff c4000000 00000023 66647e81 0066647e +00000020 0000000e 00000000 54000000 0000002a e3dad22a 00e3dad2 +00000020 0000000e 12345678 54000000 0000002a d34c421d 00d34c42 +00000020 0000000e ffffffff 54000000 0000002a 732e75da 00732e75 +00000020 0000000f 00000000 c4000000 00000023 b837e1f7 00b837e1 +00000020 0000000f 12345678 c4000000 00000023 8ec56609 008ec566 +00000020 0000000f ffffffff c4000000 00000023 2ee45491 002ee454 +80000000 00000000 00000000 00000001 80000000 855db73d 00855db7 +80000000 00000000 12345678 00000001 80000000 a51900de 00a51900 +80000000 00000000 ffffffff 00000001 80000000 5a2a09a7 005a2a09 +80000000 00000001 00000000 ffffffff ffffffff ec69d630 00ec69d6 +80000000 00000001 12345678 ffffffff ffffffff d1672077 00d16720 +80000000 00000001 ffffffff ffffffff ffffffff 5d55fc17 005d55fc +80000000 00000002 00000000 c5005555 aaaa00a3 13858663 00138586 +80000000 00000002 12345678 c5005555 aaaa00a3 0dce44bc 000dce44 +80000000 00000002 ffffffff c5005555 aaaa00a3 cb57d9f2 00cb57d9 +80000000 00000003 00000000 50050093 c900a00a 724b20ba 00724b20 +80000000 00000003 12345678 50050093 c900a00a 7c72e87d 007c72e8 +80000000 00000003 ffffffff 50050093 c900a00a b57935dd 00b57935 +80000000 00000004 00000000 b00ddb9d b9dbb00d 20eaae3e 0020eaae +80000000 00000004 12345678 b00ddb9d b9dbb00d 3a00bc46 003a00bc +80000000 00000004 ffffffff b00ddb9d b9dbb00d b27c848b 00b27c84 +80000000 00000005 00000000 40bbbbbb dddddd02 23d12389 0023d123 +80000000 00000005 12345678 40bbbbbb dddddd02 30491a11 0030491a +80000000 00000005 ffffffff 40bbbbbb dddddd02 fefba66c 00fefba6 +80000000 00000006 00000000 c0104477 ee220803 216a108b 00216a10 +80000000 00000006 12345678 c0104477 ee220803 3d388240 003d3882 +80000000 00000006 ffffffff c0104477 ee220803 839137a2 00839137 +80000000 00000007 00000000 87639641 8269c6e1 d0c4ea92 00d0c4ea +80000000 00000007 12345678 87639641 8269c6e1 efbbff96 00efbbff +80000000 00000007 ffffffff 87639641 8269c6e1 739fa9c6 00739fa9 +80000000 00000008 00000000 84350611 8860ac21 305ca2aa 00305ca2 +80000000 00000008 12345678 84350611 8860ac21 2453a676 002453a6 +80000000 00000008 ffffffff 84350611 8860ac21 ed02b269 00ed02b2 +80000000 00000009 00000000 82ff78f1 8f1eff41 98eabc1b 0098eabc +80000000 00000009 12345678 82ff78f1 8f1eff41 ad3c8b1e 00ad3c8b +80000000 00000009 ffffffff 82ff78f1 8f1eff41 0b945e4b 000b945e +80000000 0000000a 00000000 81d00a2d b4500b81 7dc19824 007dc198 +80000000 0000000a 12345678 81d00a2d b4500b81 7f98332a 007f9833 +80000000 0000000a ffffffff 81d00a2d b4500b81 b5bddb2e 00b5bddb +80000000 0000000b 00000000 87239795 a9e9c4e1 82f3a9c4 0082f3a9 +80000000 0000000b 12345678 87239795 a9e9c4e1 afacd0b3 00afacd0 +80000000 0000000b ffffffff 87239795 a9e9c4e1 64391c42 0064391c +80000000 0000000c 00000000 824706d7 eb60e241 0c780c89 000c780c +80000000 0000000c 12345678 824706d7 eb60e241 1fcca3d7 001fcca3 +80000000 0000000c ffffffff 824706d7 eb60e241 b91473a4 00b91473 +80000000 0000000d 00000000 261000a3 c5000864 7b62c93e 007b62c9 +80000000 0000000d 12345678 261000a3 c5000864 74907f73 0074907f +80000000 0000000d ffffffff 261000a3 c5000864 b8ec43e4 00b8ec43 +80000000 0000000e 00000000 d91d919d b989b89b 295f07e1 00295f07 +80000000 0000000e 12345678 d91d919d b989b89b 3faae401 003faae4 +80000000 0000000e ffffffff d91d919d b989b89b a351d9c3 00a351d9 +80000000 0000000f 00000000 72c4d755 aaeb234e 45212ba2 0045212b +80000000 0000000f 12345678 72c4d755 aaeb234e 41aa803a 0041aa80 +80000000 0000000f ffffffff 72c4d755 aaeb234e c3e977eb 00c3e977 +ffffffff 00000000 00000000 ffffffff ffffffff 4a9d5f28 004a9d5f +ffffffff 00000000 12345678 ffffffff ffffffff 43d5d37e 0043d5d3 +ffffffff 00000000 ffffffff ffffffff ffffffff 952f491d 00952f49 +ffffffff 00000001 00000000 00000001 80000000 4d4d83e6 004d4d83 +ffffffff 00000001 12345678 00000001 80000000 49ef6b63 0049ef6b +ffffffff 00000001 ffffffff 00000001 80000000 f204213f 00f20421 +ffffffff 00000002 00000000 4f00ffff ffff00f2 9a9b12a1 009a9b12 +ffffffff 00000002 12345678 4f00ffff ffff00f2 b2804679 00b28046 +ffffffff 00000002 ffffffff 4f00ffff ffff00f2 725141d9 00725141 +ffffffff 00000003 00000000 300cff8d b1ff300c 1158a981 001158a9 +ffffffff 00000003 12345678 300cff8d b1ff300c 0d239cd7 000d239c +ffffffff 00000003 ffffffff 300cff8d b1ff300c fcaa9126 00fcaa91 +ffffffff 00000004 00000000 50050093 c900a00a 9680998d 00968099 +ffffffff 00000004 12345678 50050093 c900a00a ae5e31bc 00ae5e31 +ffffffff 00000004 ffffffff 50050093 c900a00a 0a08441c 000a0844 +ffffffff 00000005 00000000 c0111111 88888803 9bb94b14 009bb94b +ffffffff 00000005 12345678 c0111111 88888803 aa937131 00aa9371 +ffffffff 00000005 ffffffff c0111111 88888803 6696b013 006696b0 +ffffffff 00000006 00000000 4070ccdd bb330e02 c22e6090 00c22e60 +ffffffff 00000006 12345678 4070ccdd bb330e02 f609dd3a 00f609dd +ffffffff 00000006 ffffffff 4070ccdd bb330e02 6cda636b 006cda63 +ffffffff 00000007 00000000 84f0027f fe400f21 d230871f 00d23087 +ffffffff 00000007 12345678 84f0027f fe400f21 ec1ee8f4 00ec1ee8 +ffffffff 00000007 ffffffff 84f0027f fe400f21 71381001 00713810 +ffffffff 00000008 00000000 87f305cf f3a0cfe1 33e1e453 0033e1e4 +ffffffff 00000008 12345678 87f305cf f3a0cfe1 261b19a7 00261b19 +ffffffff 00000008 ffffffff 87f305cf f3a0cfe1 ef354b47 00ef354b +ffffffff 00000009 00000000 812ad7a7 e5eb5481 9be32bf4 009be32b +ffffffff 00000009 12345678 812ad7a7 e5eb5481 afda0d5d 00afda0d +ffffffff 00000009 ffffffff 812ad7a7 e5eb5481 08e072d2 0008e072 +ffffffff 0000000a 00000000 87629643 c26946e1 7aaf47b1 007aaf47 +ffffffff 0000000a 12345678 87629643 c26946e1 79c69211 0079c692 +ffffffff 0000000a ffffffff 87629643 c26946e1 b2b14994 00b2b149 +ffffffff 0000000b 00000000 84fe76d3 cb6e7f21 80511496 00805114 +ffffffff 0000000b 12345678 84fe76d3 cb6e7f21 ac44a2bc 00ac44a2 +ffffffff 0000000b ffffffff 84fe76d3 cb6e7f21 672cb061 00672cb0 +ffffffff 0000000c 00000000 840d0e51 8a70b021 093941cb 00093941 +ffffffff 0000000c 12345678 840d0e51 8a70b021 1892315f 00189231 +ffffffff 0000000c ffffffff 840d0e51 8a70b021 bc84635b 00bc8463 +ffffffff 0000000d 00000000 ed0cf3ad b5cf30b7 91ec19a7 0091ec19 +ffffffff 0000000d 12345678 ed0cf3ad b5cf30b7 b6e17805 00b6e178 +ffffffff 0000000d ffffffff ed0cf3ad b5cf30b7 462c9195 00462c91 +ffffffff 0000000e 00000000 2b02b0eb d70d40d4 ac6a4e0f 00ac6a4e +ffffffff 0000000e 12345678 2b02b0eb d70d40d4 926bcac9 00926bca +ffffffff 0000000e ffffffff 2b02b0eb d70d40d4 22f59ea2 0022f59e +ffffffff 0000000f 00000000 504f41df fb82f20a 66fb558a 0066fb55 +ffffffff 0000000f 12345678 504f41df fb82f20a 68b00487 0068b004 +ffffffff 0000000f ffffffff 504f41df fb82f20a e6193a7c 00e6193a diff --git a/devices/rtx/apps/tests/unit/test_Sobol.cpp b/devices/rtx/apps/tests/unit/test_Sobol.cpp new file mode 100644 index 000000000..2aa4f804b --- /dev/null +++ b/devices/rtx/apps/tests/unit/test_Sobol.cpp @@ -0,0 +1,9 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#include "sobol/testSobol.h" + +int main() +{ + return sobol_test::run(); +} diff --git a/devices/rtx/apps/tests/unit/test_SobolCUDA.cu b/devices/rtx/apps/tests/unit/test_SobolCUDA.cu new file mode 100644 index 000000000..bf00eb518 --- /dev/null +++ b/devices/rtx/apps/tests/unit/test_SobolCUDA.cu @@ -0,0 +1,10 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#define SOBOL_CUDA +#include "sobol/testSobol.h" + +int main() +{ + return sobol_test::run(); +} diff --git a/devices/rtx/device/CMakeLists.txt b/devices/rtx/device/CMakeLists.txt index 86b401223..6a490ddb8 100644 --- a/devices/rtx/device/CMakeLists.txt +++ b/devices/rtx/device/CMakeLists.txt @@ -457,6 +457,14 @@ if (VISRTX_USE_SOVERSION) PROPERTIES VERSION "${CMAKE_PROJECT_VERSION}" SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") endif() +# The derived Sobol table and FastOwen operations retain upstream notices in +# source and binary distributions, including builds with tests disabled. +install(FILES + ${CMAKE_CURRENT_LIST_DIR}/../apps/tests/unit/sobol/LICENSE.pbrt + ${CMAKE_CURRENT_LIST_DIR}/../apps/tests/unit/sobol/LICENSE.joe-kuo + ${CMAKE_CURRENT_LIST_DIR}/../apps/tests/unit/sobol/NOTICE + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/VisRTX/licenses/sobol) + install(TARGETS ${PROJECT_NAME} EXPORT VisRTX_Exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/devices/rtx/device/gpu/owenSobol.h b/devices/rtx/device/gpu/owenSobol.h new file mode 100644 index 000000000..3a2dbf291 --- /dev/null +++ b/devices/rtx/device/gpu/owenSobol.h @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause AND Apache-2.0 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "gpu/gpu_decl.h" +#include "gpu/samplerContracts.h" + +#include // ::float2, ::float4 +#include + +// Sobol with pbrt-style FastOwenScrambler: a hash-based fast Owen +// approximation, not pbrt's separate OwenScrambler or a guarantee of +// independent random permutations/dimensions. See +// apps/tests/unit/sobol/README.md. Pattern: QMC sample points and sequential +// material draws, PCG fallback. +// +// Transport dimension map (camera jitter and lens use separate Halton): +// 0..1 ambient hemisphere / HDRI cosine strategy (intentionally shared) +// 2..3 analytic-light coordinates OR HDRI CDF row/column +// 4..5 HDRI within-texel jitter +// 6..7 light category / instance selection +// 8..11 first four sequential material draws (then PCG) +// The raw table supports 16 dimensions; none are reserved for the camera. +// Surface dimensions are reused with bounce/transparency reseeding. +// Material consumption includes categorical lobe decisions and remains +// branch-dependent, not fixed semantic roles. Draws on each chosen branch are +// sequenced explicitly; they are not eagerly consumed across early returns. +// +// sampleIndex is a uint32 binary ordinal (period 2^32), not a Gray-code +// index. Renderer addressing and the first-camera-sample center override +// are separate from this pure sampler. + +namespace visrtx { + +inline constexpr uint32_t kSobolDimHemiU = 0; +inline constexpr uint32_t kSobolDimHemiV = 1; +inline constexpr uint32_t kSobolDimCdfY = 2; +inline constexpr uint32_t kSobolDimCdfX = 3; +inline constexpr uint32_t kSobolDimCdfJitterU = 4; +inline constexpr uint32_t kSobolDimCdfJitterV = 5; +inline constexpr uint32_t kSobolDimLightPick0 = 6; +inline constexpr uint32_t kSobolDimLightPick1 = 7; +inline constexpr uint32_t kSobolDimNextRay0 = 8; +inline constexpr uint32_t kSobolNumDimensions = 16; + +// Attributed, immutable pbrt/Joe-Kuo table; intentionally included in +// namespace. +#include "gpu/sobolDirections.h" + +VISRTX_HOST_DEVICE uint32_t reverseBits32(uint32_t x) +{ +#ifdef __CUDA_ARCH__ + return __brev(x); +#else + x = (x << 16) | (x >> 16); + x = ((x & 0x00ff00ffu) << 8) | ((x & 0xff00ff00u) >> 8); + x = ((x & 0x0f0f0f0fu) << 4) | ((x & 0xf0f0f0f0u) >> 4); + x = ((x & 0x33333333u) << 2) | ((x & 0xccccccccu) >> 2); + x = ((x & 0x55555555u) << 1) | ((x & 0xaaaaaaaau) >> 1); + return x; +#endif +} + +// pbrt-v4 FastOwenScrambler operations, unchanged (not OwenScrambler). +// pbrt is Copyright(c) 1998-2020 Matt Pharr, Wenzel Jakob, and Greg Humphreys. +// Licensed under Apache-2.0; see apps/tests/unit/sobol/LICENSE.pbrt and the +// pinned excerpt there. Modified here only for VisRTX naming/annotations. +VISRTX_HOST_DEVICE uint32_t owenScramble(uint32_t v, uint32_t seed) +{ + v = reverseBits32(v); + v ^= v * 0x3d20adeau; + v += seed; + v *= (seed >> 16) | 1u; + v ^= v * 0x05526c56u; + v ^= v * 0x53a22864u; + return reverseBits32(v); +} + +VISRTX_HOST_DEVICE uint32_t sobolUInt(uint32_t index, uint32_t dimension) +{ + if (dimension >= kSobolNumDimensions) + detail::samplerContractFailure(); + uint32_t x = 0; + for (uint32_t bit = 0; index; ++bit, index >>= 1u) { + if (index & 1u) + x ^= kSobolDirection[dimension][bit]; + } + return x; +} + +VISRTX_HOST_DEVICE uint32_t owenPixelSeed(uint32_t x, uint32_t y) +{ + // Preserve the legacy Halton pixel hash, now seeding Owen rather than index. + uint32_t v = x + y * 0x9E3779B9u + 0xB5297A4Du; + v ^= v >> 16; + v *= 0x7feb352du; + v ^= v >> 15; + v *= 0x846ca68bu; + v ^= v >> 16; + return v; +} + +// Bounce 0 / no alpha pass-through keeps the transport pixel seed (XOR 0). +// Later bounces and coverage-continue vertices reseed so dims 0–11 can be +// reused without repeating an earlier vertex's sequence. +VISRTX_HOST_DEVICE uint32_t owenBounceSeed( + uint32_t pixelSeed, int bounce, int transparency = 0) +{ + return pixelSeed ^ (0x9e3779b9u * uint32_t(bounce)) + ^ (0x85ebca6bu * uint32_t(transparency)); +} + +// Exact 24-bit half-open grid; zero is a legal sample, not an error. +VISRTX_HOST_DEVICE float sobolFloat(uint32_t scrambled) +{ + return float(scrambled >> 8) * 0x1p-24f; +} + +// Uniform on the 24-bit grid in [0, 1). Dimension mixing does not prove +// independence. Zero is legal and the maximum is 1 - 2^-24; no clamp. +VISRTX_HOST_DEVICE float owenSobol( + uint32_t sampleIndex, uint32_t dimension, uint32_t pixelSeed) +{ + const uint32_t dimSeed = pixelSeed ^ (0x9e3779b9u * (dimension + 1u)); + const uint32_t scrambled = + owenScramble(sobolUInt(sampleIndex, dimension), dimSeed); + return sobolFloat(scrambled); +} + +VISRTX_HOST_DEVICE ::float2 owenSobolHemi( + uint32_t sampleIndex, uint32_t pixelSeed) +{ + return ::float2{owenSobol(sampleIndex, kSobolDimHemiU, pixelSeed), + owenSobol(sampleIndex, kSobolDimHemiV, pixelSeed)}; +} + +} // namespace visrtx diff --git a/devices/rtx/device/gpu/samplerContracts.h b/devices/rtx/device/gpu/samplerContracts.h new file mode 100644 index 000000000..bb8889f9b --- /dev/null +++ b/devices/rtx/device/gpu/samplerContracts.h @@ -0,0 +1,26 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#pragma once + +#include "gpu/gpu_decl.h" + +#include + +namespace visrtx { +namespace detail { + +// Sampler programmer errors must fail even with NDEBUG. Kept internal to the +// sampler contracts; this is not a renderer/frame failure mechanism. +[[noreturn]] VISRTX_HOST_DEVICE void samplerContractFailure() +{ +#ifdef __CUDA_ARCH__ + asm volatile("trap;"); + __builtin_unreachable(); +#else + std::abort(); +#endif +} + +} // namespace detail +} // namespace visrtx diff --git a/devices/rtx/device/gpu/sobolDirections.h b/devices/rtx/device/gpu/sobolDirections.h new file mode 100644 index 000000000..75a663ea5 --- /dev/null +++ b/devices/rtx/device/gpu/sobolDirections.h @@ -0,0 +1,207 @@ +// pbrt is Copyright(c) 1998-2020 Matt Pharr, Wenzel Jakob, and Greg Humphreys. +// The pbrt source code is licensed under the Apache License, Version 2.0. +// SPDX: Apache-2.0 + +// Copyright (c) 2012 Leonhard Gruenschloss (leonhard@gruenschloss.org) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to +// do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// These matrices are based on the following publication: +// +// S. Joe and F. Y. Kuo: "Constructing Sobol sequences with better +// two-dimensional projections", SIAM J. Sci. Comput. 30, 2635-2654 (2008). +// +// The tabulated direction numbers are available here: +// http://web.maths.unsw.edu.au/~fkuo/sobol/new-joe-kuo-6.21201 + +#pragma once + +// Included by owenSobol.h inside namespace visrtx after uint32_t is available. +// Storage is immutable host data or CUDA constant memory, per compilation pass. +// Derived: pbrt-v4 b0bdf461ba5dd6504b70ebf0932acc0fe7aa744f +// Rows 0..15, columns 0..31 (source stride 52). See apps/tests/unit/sobol. +// clang-format off +#ifdef __CUDA_ARCH__ +__device__ __constant__ +#endif +static const uint32_t kSobolDirection[16][32] = { + { + 0x80000000u, 0x40000000u, 0x20000000u, 0x10000000u, + 0x08000000u, 0x04000000u, 0x02000000u, 0x01000000u, + 0x00800000u, 0x00400000u, 0x00200000u, 0x00100000u, + 0x00080000u, 0x00040000u, 0x00020000u, 0x00010000u, + 0x00008000u, 0x00004000u, 0x00002000u, 0x00001000u, + 0x00000800u, 0x00000400u, 0x00000200u, 0x00000100u, + 0x00000080u, 0x00000040u, 0x00000020u, 0x00000010u, + 0x00000008u, 0x00000004u, 0x00000002u, 0x00000001u, + }, + { + 0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u, + 0x88000000u, 0xcc000000u, 0xaa000000u, 0xff000000u, + 0x80800000u, 0xc0c00000u, 0xa0a00000u, 0xf0f00000u, + 0x88880000u, 0xcccc0000u, 0xaaaa0000u, 0xffff0000u, + 0x80008000u, 0xc000c000u, 0xa000a000u, 0xf000f000u, + 0x88008800u, 0xcc00cc00u, 0xaa00aa00u, 0xff00ff00u, + 0x80808080u, 0xc0c0c0c0u, 0xa0a0a0a0u, 0xf0f0f0f0u, + 0x88888888u, 0xccccccccu, 0xaaaaaaaau, 0xffffffffu, + }, + { + 0x80000000u, 0xc0000000u, 0x60000000u, 0x90000000u, + 0xe8000000u, 0x5c000000u, 0x8e000000u, 0xc5000000u, + 0x68800000u, 0x9cc00000u, 0xee600000u, 0x55900000u, + 0x80680000u, 0xc09c0000u, 0x60ee0000u, 0x90550000u, + 0xe8808000u, 0x5cc0c000u, 0x8e606000u, 0xc5909000u, + 0x6868e800u, 0x9c9c5c00u, 0xeeee8e00u, 0x5555c500u, + 0x8000e880u, 0xc0005cc0u, 0x60008e60u, 0x9000c590u, + 0xe8006868u, 0x5c009c9cu, 0x8e00eeeeu, 0xc5005555u, + }, + { + 0x80000000u, 0xc0000000u, 0x20000000u, 0x50000000u, + 0xf8000000u, 0x74000000u, 0xa2000000u, 0x93000000u, + 0xd8800000u, 0x25400000u, 0x59e00000u, 0xe6d00000u, + 0x78080000u, 0xb40c0000u, 0x82020000u, 0xc3050000u, + 0x208f8000u, 0x51474000u, 0xfbea2000u, 0x75d93000u, + 0xa0858800u, 0x914e5400u, 0xdbe79e00u, 0x25db6d00u, + 0x58800080u, 0xe54000c0u, 0x79e00020u, 0xb6d00050u, + 0x800800f8u, 0xc00c0074u, 0x200200a2u, 0x50050093u, + }, + { + 0x80000000u, 0x40000000u, 0x20000000u, 0xb0000000u, + 0xf8000000u, 0xdc000000u, 0x7a000000u, 0x9d000000u, + 0x5a800000u, 0x2fc00000u, 0xa1600000u, 0xf0b00000u, + 0xda880000u, 0x6fc40000u, 0x81620000u, 0x40bb0000u, + 0x22878000u, 0xb3c9c000u, 0xfb65a000u, 0xddb2d000u, + 0x78022800u, 0x9c0b3c00u, 0x5a0fb600u, 0x2d0ddb00u, + 0xa2878080u, 0xf3c9c040u, 0xdb65a020u, 0x6db2d0b0u, + 0x800228f8u, 0x400b3cdcu, 0x200fb67au, 0xb00ddb9du, + }, + { + 0x80000000u, 0x40000000u, 0x60000000u, 0x30000000u, + 0xc8000000u, 0x24000000u, 0x56000000u, 0xfb000000u, + 0xe0800000u, 0x70400000u, 0xa8600000u, 0x14300000u, + 0x9ec80000u, 0xdf240000u, 0xb6d60000u, 0x8bbb0000u, + 0x48008000u, 0x64004000u, 0x36006000u, 0xcb003000u, + 0x2880c800u, 0x54402400u, 0xfe605600u, 0xef30fb00u, + 0x7e48e080u, 0xaf647040u, 0x1eb6a860u, 0x9f8b1430u, + 0xd6c81ec8u, 0xbb249f24u, 0x80d6d6d6u, 0x40bbbbbbu, + }, + { + 0x80000000u, 0xc0000000u, 0xa0000000u, 0xd0000000u, + 0x58000000u, 0x94000000u, 0x3e000000u, 0xe3000000u, + 0xbe800000u, 0x23c00000u, 0x1e200000u, 0xf3100000u, + 0x46780000u, 0x67840000u, 0x78460000u, 0x84670000u, + 0xc6788000u, 0xa784c000u, 0xd846a000u, 0x5467d000u, + 0x9e78d800u, 0x33845400u, 0xe6469e00u, 0xb7673300u, + 0x20f86680u, 0x104477c0u, 0xf8668020u, 0x4477c010u, + 0x668020f8u, 0x77c01044u, 0x8020f866u, 0xc0104477u, + }, + { + 0x80000000u, 0x40000000u, 0xa0000000u, 0x50000000u, + 0x88000000u, 0x24000000u, 0x12000000u, 0x2d000000u, + 0x76800000u, 0x9e400000u, 0x08200000u, 0x64100000u, + 0xb2280000u, 0x7d140000u, 0xfea20000u, 0xba490000u, + 0x1a248000u, 0x491b4000u, 0xc4b5a000u, 0xe3739000u, + 0xf6800800u, 0xde400400u, 0xa8200a00u, 0x34100500u, + 0x3a280880u, 0x59140240u, 0xeca20120u, 0x974902d0u, + 0x6ca48768u, 0xd75b49e4u, 0xcc95a082u, 0x87639641u, + }, + { + 0x80000000u, 0x40000000u, 0xa0000000u, 0x50000000u, + 0x28000000u, 0xd4000000u, 0x6a000000u, 0x71000000u, + 0x38800000u, 0x58400000u, 0xea200000u, 0x31100000u, + 0x98a80000u, 0x08540000u, 0xc22a0000u, 0xe5250000u, + 0xf2b28000u, 0x79484000u, 0xfaa42000u, 0xbd731000u, + 0x18a80800u, 0x48540400u, 0x622a0a00u, 0xb5250500u, + 0xdab28280u, 0xad484d40u, 0x90a426a0u, 0xcc731710u, + 0x20280b88u, 0x10140184u, 0x880a04a2u, 0x84350611u, + }, + { + 0x80000000u, 0x40000000u, 0xe0000000u, 0xb0000000u, + 0x98000000u, 0x94000000u, 0x8a000000u, 0x5b000000u, + 0x33800000u, 0xd9c00000u, 0x72200000u, 0x3f100000u, + 0xc1b80000u, 0xa6ec0000u, 0x53860000u, 0x29f50000u, + 0x0a3a8000u, 0x1b2ac000u, 0xd392e000u, 0x69ff7000u, + 0xea380800u, 0xab2c0400u, 0x4ba60e00u, 0xfde50b00u, + 0x60028980u, 0xf006c940u, 0x7834e8a0u, 0x241a75b0u, + 0x123a8b38u, 0xcf2ac99cu, 0xb992e922u, 0x82ff78f1u, + }, + { + 0x80000000u, 0x40000000u, 0xa0000000u, 0x10000000u, + 0x08000000u, 0x6c000000u, 0x9e000000u, 0x23000000u, + 0x57800000u, 0xadc00000u, 0x7fa00000u, 0x91d00000u, + 0x49880000u, 0xced40000u, 0x880a0000u, 0x2c0f0000u, + 0x3e0d8000u, 0x3317c000u, 0x5fb06000u, 0xc1f8b000u, + 0xe18d8800u, 0xb2d7c400u, 0x1e106a00u, 0x6328b100u, + 0xf7858880u, 0xbdc3c2c0u, 0x77ba63e0u, 0xfdf7b330u, + 0xd7800df8u, 0xedc0081cu, 0xdfa0041au, 0x81d00a2du, + }, + { + 0x80000000u, 0x40000000u, 0x20000000u, 0x30000000u, + 0x58000000u, 0xac000000u, 0x96000000u, 0x2b000000u, + 0xd4800000u, 0x09400000u, 0xe2a00000u, 0x52500000u, + 0x4e280000u, 0xc71c0000u, 0x629e0000u, 0x12670000u, + 0x6e138000u, 0xf731c000u, 0x3a98a000u, 0xbe449000u, + 0xf83b8800u, 0xdc2dc400u, 0xee06a200u, 0xb7239300u, + 0x1aa80d80u, 0x8e5c0ec0u, 0xa03e0b60u, 0x703701b0u, + 0x783b88c8u, 0x9c2dca54u, 0xce06a74au, 0x87239795u, + }, + { + 0x80000000u, 0xc0000000u, 0xa0000000u, 0x50000000u, + 0xf8000000u, 0x8c000000u, 0xe2000000u, 0x33000000u, + 0x0f800000u, 0x21400000u, 0x95a00000u, 0x5e700000u, + 0xd8080000u, 0x1c240000u, 0xba160000u, 0xef370000u, + 0x15868000u, 0x9e6fc000u, 0x781b6000u, 0x4c349000u, + 0x420e8800u, 0x630bcc00u, 0xf7ad6a00u, 0xad739500u, + 0x77800780u, 0x6d4004c0u, 0xd7a00420u, 0x3d700630u, + 0x2f880f78u, 0xb1640ad4u, 0xcdb6077au, 0x824706d7u, + }, + { + 0x80000000u, 0xc0000000u, 0x60000000u, 0x90000000u, + 0x38000000u, 0xc4000000u, 0x42000000u, 0xa3000000u, + 0xf1800000u, 0xaa400000u, 0xfce00000u, 0x85100000u, + 0xe0080000u, 0x500c0000u, 0x58060000u, 0x54090000u, + 0x7a038000u, 0x670c4000u, 0xb3842000u, 0x094a3000u, + 0x0d6f1800u, 0x2f5aa400u, 0x1ce7ce00u, 0xd5145100u, + 0xb8000080u, 0x040000c0u, 0x22000060u, 0x33000090u, + 0xc9800038u, 0x6e4000c4u, 0xbee00042u, 0x261000a3u, + }, + { + 0x80000000u, 0x40000000u, 0x20000000u, 0xf0000000u, + 0xa8000000u, 0x54000000u, 0x9a000000u, 0x9d000000u, + 0x1e800000u, 0x5cc00000u, 0x7d200000u, 0x8d100000u, + 0x24880000u, 0x71c40000u, 0xeba20000u, 0x75df0000u, + 0x6ba28000u, 0x35d14000u, 0x4ba3a000u, 0xc5d2d000u, + 0xe3a16800u, 0x91db8c00u, 0x79aef200u, 0x0cdf4100u, + 0x672a8080u, 0x50154040u, 0x1a01a020u, 0xdd0dd0f0u, + 0x3e83e8a8u, 0xaccacc54u, 0xd52d529au, 0xd91d919du, + }, + { + 0x80000000u, 0xc0000000u, 0x20000000u, 0xd0000000u, + 0xd8000000u, 0xc4000000u, 0x46000000u, 0x85000000u, + 0xa5800000u, 0x76c00000u, 0xada00000u, 0x6ab00000u, + 0x2da80000u, 0xaabc0000u, 0x0daa0000u, 0x7ab10000u, + 0xd5a78000u, 0xbebd4000u, 0x93a3e000u, 0x3bb51000u, + 0x3629b800u, 0x4d727c00u, 0x9b836200u, 0x27c4d700u, + 0xb629b880u, 0x8d727cc0u, 0xbb836220u, 0xf7c4d7d0u, + 0x6e29b858u, 0x49727c04u, 0xfd836266u, 0x72c4d755u, + }, +}; +// clang-format on From c3e86d7e0cd54744869f8bd1e6c572ffeb3d320e Mon Sep 17 00:00:00 2001 From: Thomas Arcila <134677+tarcila@users.noreply.github.com> Date: Tue, 10 Nov 2026 02:09:51 +0000 Subject: [PATCH 3/6] feat(rtx): use Sobol for surface lighting Keep surface transport at the contiguous camera ordinal while retaining PCG for unsupported paths and explicitly sequencing fallback draws. --- devices/rtx/apps/tests/unit/CMakeLists.txt | 15 ++ .../apps/tests/unit/test_LightDrawOrder.cu | 144 ++++++++++++++++++ devices/rtx/device/gpu/gpu_util.h | 32 ++-- devices/rtx/device/gpu/sampleLight.h | 96 ++++++++---- devices/rtx/device/renderer/Quality_ptx.cu | 73 +++++++-- 5 files changed, 308 insertions(+), 52 deletions(-) create mode 100644 devices/rtx/apps/tests/unit/test_LightDrawOrder.cu diff --git a/devices/rtx/apps/tests/unit/CMakeLists.txt b/devices/rtx/apps/tests/unit/CMakeLists.txt index 438cced96..405c613f8 100644 --- a/devices/rtx/apps/tests/unit/CMakeLists.txt +++ b/devices/rtx/apps/tests/unit/CMakeLists.txt @@ -113,6 +113,21 @@ add_test(NAME rtx::SobolReferencePublication set_tests_properties(rtx::SobolTableHeader rtx::SobolReferencePublication PROPERTIES TIMEOUT 30) +add_executable(rtx_test_LightDrawOrder test_LightDrawOrder.cu) +target_include_directories(rtx_test_LightDrawOrder PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/../../../device + ${CMAKE_CURRENT_LIST_DIR}/../../../external/nanovdb/include + ${OptiX_ROOT_DIR}/include) +target_link_libraries(rtx_test_LightDrawOrder PRIVATE + CUDA::cudart visrtx::glm anari::anari_headers) +target_compile_definitions(rtx_test_LightDrawOrder PRIVATE GLM_ENABLE_EXPERIMENTAL) +set_target_properties(rtx_test_LightDrawOrder PROPERTIES + CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON) +target_compile_options(rtx_test_LightDrawOrder PRIVATE + --use_fast_math --expt-relaxed-constexpr) +add_test(NAME rtx::LightDrawOrder COMMAND rtx_test_LightDrawOrder) +set_tests_properties(rtx::LightDrawOrder PROPERTIES TIMEOUT 60) + # Production Sobol sampler against independently sourced Joe-Kuo parameters. add_executable(rtx_test_Sobol test_Sobol.cpp) add_executable(rtx_test_SobolCUDA test_SobolCUDA.cu) diff --git a/devices/rtx/apps/tests/unit/test_LightDrawOrder.cu b/devices/rtx/apps/tests/unit/test_LightDrawOrder.cu new file mode 100644 index 000000000..91656fbb2 --- /dev/null +++ b/devices/rtx/apps/tests/unit/test_LightDrawOrder.cu @@ -0,0 +1,144 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +#include "gpu/sampleLight.h" +#include "sobol/cudaResources.h" + +#include +#include +#include +#include + +using namespace visrtx; + +VISRTX_DEVICE bool different(const vec3 &actual, const vec3 &expected) +{ + return !(glm::length(actual - expected) < 1e-6f); +} + +VISRTX_GLOBAL void checkLightDraws( + int *failures, cudaTextureObject_t texture, const float *cdf) +{ + int f = 0; + RandState rs; + pcg_init(&rs, 42, 7); + auto expected = rs; + const float u = pcg_uniform(&expected); + const float v = pcg_uniform(&expected); + LightGPUData ld{}; + ld.color = vec3(1.f); + ld.rect.position = vec3(0, 0, 1); + ld.rect.edge1 = vec3(2, 0, 0); + ld.rect.edge2 = vec3(0, 3, 0); + const auto rect = detail::sampleRectLight(ld, mat4(1), vec3(0), rs); + const vec3 point = rect.dir * rect.dist; + f += different(point, vec3(2.f * u, 3.f * v, 1.f)); + f += rs.state != expected.state; + const auto qmcBefore = rs; + const auto qmcRect = + detail::sampleRectLight(ld, mat4(1), vec3(0), rs, true, 17, 123); + const vec3 qmcPoint = qmcRect.dir * qmcRect.dist; + f += different(qmcPoint, + vec3(2.f * owenSobol(17, 2, 123), 3.f * owenSobol(17, 3, 123), 1.f)); + f += rs.state != qmcBefore.state; + + pcg_init(&rs, 42, 7); + expected = rs; + const float row = pcg_uniform(&expected); + const float col = pcg_uniform(&expected); + const float jitterU = pcg_uniform(&expected); + const float jitterV = pcg_uniform(&expected); + ld = {}; + ld.color = vec3(1.f); + ld.hdri.size = uvec2(2, 2); + ld.hdri.marginalCDF = cdf; + ld.hdri.conditionalCDF = cdf + 2; + ld.hdri.radiance = texture; + ld.hdri.xfm = mat3(1); + ld.hdri.scale = ld.hdri.pdfWeight = 1.f; + const auto hdri = detail::sampleHDRILight(ld, mat4(1), rs); + const float x = (col > .5f ? 1.f : 0.f) + jitterU; + const float y = (row > .5f ? 1.f : 0.f) + jitterV; + const auto expectedDir = + sphericalCoordsToDirection(vec2(kPi * y / 2.f, kPi * x)); + f += different(hdri.dir, expectedDir); + f += rs.state != expected.state; + const auto beforeHdriQmc = rs; + const auto qmcHdri = detail::sampleHDRILight(ld, mat4(1), rs, true, 17, 123); + const float qmcX = + (owenSobol(17, 3, 123) > .5f ? 1.f : 0.f) + owenSobol(17, 4, 123); + const float qmcY = + (owenSobol(17, 2, 123) > .5f ? 1.f : 0.f) + owenSobol(17, 5, 123); + f += different(qmcHdri.dir, + sphericalCoordsToDirection(vec2(kPi * qmcY / 2.f, kPi * qmcX))); + f += rs.state != beforeHdriQmc.state; + + pcg_init(&rs, 42, 7); + expected = rs; + const float hemiU = pcg_uniform(&expected); + const float hemiV = pcg_uniform(&expected); + const auto hemisphere = sampleHemisphere(rs, vec3(0, 0, 1)); + const float radius = sqrtf(hemiU); + const vec3 expectedHemi(radius * cosf(kTwoPi * hemiV), + radius * sinf(kTwoPi * hemiV), + sqrtf(1.f - hemiU)); + f += different(hemisphere, expectedHemi); + f += rs.state != expected.state; + *failures = f; +} + +void cudaCheck(cudaError_t error, const char *operation) +{ + if (error != cudaSuccess) { + throw std::runtime_error( + std::string(operation) + ": " + cudaGetErrorString(error)); + } +} +int main() +try { + CudaTexture image; + const auto channel = cudaCreateChannelDesc(); + cudaCheck( + cudaMallocArray(&image.array, &channel, 2, 2), "texture allocation"); + const float4 pixels[4] = { + {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}; + cudaCheck(cudaMemcpy2DToArray(image.array, + 0, + 0, + pixels, + 2 * sizeof(float4), + 2 * sizeof(float4), + 2, + cudaMemcpyHostToDevice), + "texture upload"); + cudaResourceDesc resource{}; + resource.resType = cudaResourceTypeArray; + resource.res.array.array = image.array; + cudaTextureDesc description{}; + description.normalizedCoords = 1; + description.readMode = cudaReadModeElementType; + cudaCheck( + cudaCreateTextureObject(&image.texture, &resource, &description, nullptr), + "texture creation"); + CudaBuffer cdf; + const float cdfHost[] = {.5f, 1.f, .5f, 1.f, .5f, 1.f}; + cudaCheck(cdf.allocate(6), "CDF allocation"); + cudaCheck( + cudaMemcpy(cdf.get(), cdfHost, sizeof(cdfHost), cudaMemcpyHostToDevice), + "CDF upload"); + CudaBuffer deviceFailures; + cudaCheck(deviceFailures.allocate(1), "result allocation"); + checkLightDraws<<<1, 1>>>(deviceFailures.get(), image.texture, cdf.get()); + cudaCheck(cudaGetLastError(), "launch"); + cudaCheck(cudaDeviceSynchronize(), "synchronize"); + int failures; + cudaCheck( + cudaMemcpy( + &failures, deviceFailures.get(), sizeof(int), cudaMemcpyDeviceToHost), + "result download"); + if (failures) + std::fprintf(stderr, "%d light draw-order failures\n", failures); + return failures ? EXIT_FAILURE : EXIT_SUCCESS; +} catch (const std::exception &e) { + std::fprintf(stderr, "%s\n", e.what()); + return EXIT_FAILURE; +} diff --git a/devices/rtx/device/gpu/gpu_util.h b/devices/rtx/device/gpu/gpu_util.h index 0fd5ce4d5..f2aec0098 100644 --- a/devices/rtx/device/gpu/gpu_util.h +++ b/devices/rtx/device/gpu/gpu_util.h @@ -33,6 +33,7 @@ #include "cameraCreateRay.h" #include "gpu/gpu_debug.h" +#include "gpu/owenSobol.h" #include "gpu_objects.h" #include "gpu_tonemap.h" #include "shadingState.h" @@ -231,10 +232,11 @@ VISRTX_DEVICE mat3 computeOrthonormalBasis(const vec3 &normal) } // Cosine-weighted hemisphere sample (Malley's method); pdf = cos(theta)/pi. -VISRTX_DEVICE vec3 sampleHemisphere(RandState &rs, const vec3 &normal) +// u1/u2 in [0, 1). The RandState overload draws them from PCG in that order. +// Quality env/ambient NEE intentionally shares Owen-scrambled Sobol dims 0–1, +// with per-surface-bounce/transparency reseeding. +VISRTX_DEVICE vec3 sampleHemisphere(float u1, float u2, const vec3 &normal) { - const float u1 = pcg_uniform(&rs); - const float u2 = pcg_uniform(&rs); const float r = sqrtf(u1); const float z = sqrtf(fmaxf(0.f, 1.f - r * r)); const float phi = kTwoPi * u2; @@ -242,6 +244,13 @@ VISRTX_DEVICE vec3 sampleHemisphere(RandState &rs, const vec3 &normal) return computeOrthonormalBasis(normal) * sample; } +VISRTX_DEVICE vec3 sampleHemisphere(RandState &rs, const vec3 &normal) +{ + const float u = pcg_uniform(&rs); + const float v = pcg_uniform(&rs); + return sampleHemisphere(u, v, normal); +} + VISRTX_DEVICE vec3 sampleUnitSphere(RandState &rs, const vec3 &normal) { // sample unit sphere @@ -600,17 +609,20 @@ VISRTX_DEVICE void setPixelIds(const FramebufferGPUData &fb, // bulk), but a sample above the cap contributes only the capped value. This is // the base-excluding threshold — letting raw outliers into the stats lets one // firefly inflate σ enough to raise its own future cap, so a moderate k never -// fires (the σ-inflation trap). Feeding the clamped value bounds that inflation, -// which is what lets k drop to a value that actually bites. The cost is that a -// genuinely legitimate >kσ excursion on a high-variance pixel is clipped and -// cannot grow the cap — unavoidable for a per-pixel online clamp, which is why -// CLAMP is the deliberately-aggressive, biased mode. +// fires (the σ-inflation trap). Feeding the clamped value bounds that +// inflation, which is what lets k drop to a value that actually bites. The cost +// is that a genuinely legitimate >kσ excursion on a high-variance pixel is +// clipped and cannot grow the cap — unavoidable for a per-pixel online clamp, +// which is why CLAMP is the deliberately-aggressive, biased mode. // // Each channel is clamped independently to its own cap, so a chromatic // (single-channel) outlier is caught even when its luminance is unremarkable, // without a near-zero channel dragging the whole (saturated-color) pixel dark. -VISRTX_DEVICE vec4 fireflyClamp( - PixelLumStats *lumStatsBuf, uint32_t idx, vec4 color, float kSigma, int warmupSamples) +VISRTX_DEVICE vec4 fireflyClamp(PixelLumStats *lumStatsBuf, + uint32_t idx, + vec4 color, + float kSigma, + int warmupSamples) { constexpr float kWarmupCapFactor = 8.0f; // warmup cap = factor * running mean diff --git a/devices/rtx/device/gpu/sampleLight.h b/devices/rtx/device/gpu/sampleLight.h index be8875f96..e737a1d36 100644 --- a/devices/rtx/device/gpu/sampleLight.h +++ b/devices/rtx/device/gpu/sampleLight.h @@ -36,8 +36,8 @@ #include "gpu/gpu_objects.h" #include "gpu/gpu_util.h" #include "gpu/intersectPrimitives.h" // CapBit (cylinder/cone cap enablement) -#include "gpu/quadLightTexture.h" #include "gpu/lightGeometry.h" // rect/ring leaves shared with the hit-side deposit +#include "gpu/quadLightTexture.h" // glm #include @@ -120,12 +120,20 @@ VISRTX_DEVICE LightSample samplePointLight( return ls; } -VISRTX_DEVICE LightSample sampleSphereLight( - const LightGPUData &ld, const mat4 &xfm, const vec3 &origin, RandState &rs) +VISRTX_DEVICE LightSample sampleSphereLight(const LightGPUData &ld, + const mat4 &xfm, + const vec3 &origin, + RandState &rs, + bool useQmc = false, + uint32_t sampleIndex = 0, + uint32_t pixelSeed = 0) { LightSample ls; - auto u1 = pcg_uniform(&rs); - auto u2 = pcg_uniform(&rs); + auto u = [&](uint32_t dim) { + return useQmc ? owenSobol(sampleIndex, dim, pixelSeed) : pcg_uniform(&rs); + }; + auto u1 = u(kSobolDimCdfY); + auto u2 = u(kSobolDimCdfX); // Uniform sampling on unit sphere using Marsaglia's method // u1 maps to z-coordinate: z ∈ [-1, 1] @@ -166,11 +174,21 @@ VISRTX_DEVICE LightSample sampleSphereLight( return ls; } -VISRTX_DEVICE LightSample sampleRectLight( - const LightGPUData &ld, const mat4 &xfm, const vec3 &origin, RandState &rs) +VISRTX_DEVICE LightSample sampleRectLight(const LightGPUData &ld, + const mat4 &xfm, + const vec3 &origin, + RandState &rs, + bool useQmc = false, + uint32_t sampleIndex = 0, + uint32_t pixelSeed = 0) { LightSample ls; - auto uv = vec2(pcg_uniform(&rs), pcg_uniform(&rs)); + auto u = [&](uint32_t dim) { + return useQmc ? owenSobol(sampleIndex, dim, pixelSeed) : pcg_uniform(&rs); + }; + const float rectU = u(kSobolDimCdfY); + const float rectV = u(kSobolDimCdfX); + auto uv = vec2(rectU, rectV); // Uniform sampling on rectangle: uv ∈ [0,1]² maps to rectangle auto rectangleSample = ld.rect.edge1 * uv.x + ld.rect.edge2 * uv.y; @@ -200,12 +218,20 @@ VISRTX_DEVICE LightSample sampleRectLight( return ls; } -VISRTX_DEVICE LightSample sampleRingLight( - const LightGPUData &ld, const mat4 &xfm, const vec3 &origin, RandState &rs) +VISRTX_DEVICE LightSample sampleRingLight(const LightGPUData &ld, + const mat4 &xfm, + const vec3 &origin, + RandState &rs, + bool useQmc = false, + uint32_t sampleIndex = 0, + uint32_t pixelSeed = 0) { LightSample ls; - auto u1 = pcg_uniform(&rs); - auto u2 = pcg_uniform(&rs); + auto u = [&](uint32_t dim) { + return useQmc ? owenSobol(sampleIndex, dim, pixelSeed) : pcg_uniform(&rs); + }; + auto u1 = u(kSobolDimCdfY); + auto u2 = u(kSobolDimCdfX); // Sample angle uniformly around the ring: φ ∈ [0, 2π] auto phi = kTwoPi * u1; @@ -782,17 +808,26 @@ VISRTX_DEVICE LightSample sampleHDRILight( return ls; } -VISRTX_DEVICE LightSample sampleHDRILight( - const LightGPUData &ld, const mat4 &xfm, RandState &rs) +VISRTX_DEVICE LightSample sampleHDRILight(const LightGPUData &ld, + const mat4 &xfm, + RandState &rs, + bool useQmc = false, + uint32_t sampleIndex = 0, + uint32_t pixelSeed = 0) { // Importance sampling using hierarchical (marginal/conditional) CDF approach // First sample row (y) using marginal CDF, then column (x) using conditional - // CDF - auto y = - inverseSampleCDF(ld.hdri.marginalCDF, ld.hdri.size.y, pcg_uniform(&rs)); - auto x = inverseSampleCDF(ld.hdri.conditionalCDF + y * ld.hdri.size.x, - ld.hdri.size.x, - pcg_uniform(&rs)); + // CDF. Quality NEE feeds Owen-scrambled Sobol dims 6–9, reseeded per + // surface bounce/transparency layer. The PCG fallback has the same draw + // order. + auto u = [&](uint32_t dim) { + return useQmc ? owenSobol(sampleIndex, dim, pixelSeed) : pcg_uniform(&rs); + }; + const float rowU = u(kSobolDimCdfY); + auto y = inverseSampleCDF(ld.hdri.marginalCDF, ld.hdri.size.y, rowU); + const float columnU = u(kSobolDimCdfX); + auto x = inverseSampleCDF( + ld.hdri.conditionalCDF + y * ld.hdri.size.x, ld.hdri.size.x, columnU); auto xy = glm::uvec2(x, y); @@ -802,7 +837,9 @@ VISRTX_DEVICE LightSample sampleHDRILight( } #endif // Add sub-pixel jitter to avoid aliasing - auto jitter = glm::vec2(pcg_uniform(&rs), pcg_uniform(&rs)); + const float jitterU = u(kSobolDimCdfJitterU); + const float jitterV = u(kSobolDimCdfJitterV); + auto jitter = glm::vec2(jitterU, jitterV); auto uv = glm::clamp((glm::vec2(xy) + jitter) / glm::vec2(ld.hdri.size), 0.f, 1.f); @@ -835,7 +872,10 @@ VISRTX_DEVICE LightSample sampleLight(ScreenSample &ss, const vec3 &origin, DeviceObjectIndex idx, const mat4 &xfm, - DeviceObjectIndex surfaceInstanceIndex) + DeviceObjectIndex surfaceInstanceIndex, + bool useQmc = false, + uint32_t sampleIndex = 0, + uint32_t pixelSeed = 0) { auto &ld = ss.frameData->registry.lights[idx]; @@ -845,15 +885,19 @@ VISRTX_DEVICE LightSample sampleLight(ScreenSample &ss, case LightType::POINT: return detail::samplePointLight(ld, xfm, origin); case LightType::SPHERE: - return detail::sampleSphereLight(ld, xfm, origin, ss.rs); + return detail::sampleSphereLight( + ld, xfm, origin, ss.rs, useQmc, sampleIndex, pixelSeed); case LightType::RECT: - return detail::sampleRectLight(ld, xfm, origin, ss.rs); + return detail::sampleRectLight( + ld, xfm, origin, ss.rs, useQmc, sampleIndex, pixelSeed); case LightType::SPOT: return detail::sampleSpotLight(ld, xfm, origin); case LightType::RING: - return detail::sampleRingLight(ld, xfm, origin, ss.rs); + return detail::sampleRingLight( + ld, xfm, origin, ss.rs, useQmc, sampleIndex, pixelSeed); case LightType::HDRI: - return detail::sampleHDRILight(ld, xfm, ss.rs); + return detail::sampleHDRILight( + ld, xfm, ss.rs, useQmc, sampleIndex, pixelSeed); case LightType::GEOMETRY: return detail::sampleGeometryLight( ld, xfm, origin, ss, surfaceInstanceIndex); diff --git a/devices/rtx/device/renderer/Quality_ptx.cu b/devices/rtx/device/renderer/Quality_ptx.cu index c241d3860..665b02d93 100644 --- a/devices/rtx/device/renderer/Quality_ptx.cu +++ b/devices/rtx/device/renderer/Quality_ptx.cu @@ -411,13 +411,21 @@ struct PickedCandidate float pickPdf; // probability of this pick, ∝ Pick Power }; -VISRTX_DEVICE PickedCandidate pickCandidate( - ScreenSample &ss, const FrameGPUData &frameData) +VISRTX_DEVICE PickedCandidate pickCandidate(ScreenSample &ss, + const FrameGPUData &frameData, + bool useQmc = false, + uint32_t sampleIndex = 0, + uint32_t pixelSeed = 0) { const auto &world = frameData.world; const float ambientPower = ambientPickPower(frameData); const bool hasAmbient = ambientPower > 0.0f; + auto uPick = [&](uint32_t dim) { + return useQmc ? owenSobol(sampleIndex, dim, pixelSeed) + : pcg_uniform(&ss.rs); + }; + if (world.numLightInstances == 0 && !hasAmbient) return {false, false, 0, 0.0f}; @@ -427,18 +435,18 @@ VISRTX_DEVICE PickedCandidate pickCandidate( // keeps the estimator unbiased and avoids a divide-by-zero. if (!(totalPower > 0.0f)) { const size_t numStrata = world.numLightInstances + (hasAmbient ? 1 : 0); - const size_t selected = - glm::min(size_t(pcg_uniform(&ss.rs) * float(numStrata)), numStrata - 1); + const size_t selected = glm::min( + size_t(uPick(kSobolDimLightPick0) * float(numStrata)), numStrata - 1); const float pickPdf = 1.0f / float(numStrata); if (hasAmbient && selected == world.numLightInstances) return {true, true, 0, pickPdf}; return {true, false, selected, pickPdf}; } - if (hasAmbient && pcg_uniform(&ss.rs) * totalPower < ambientPower) + if (hasAmbient && uPick(kSobolDimLightPick0) * totalPower < ambientPower) return {true, true, 0, ambientPower / totalPower}; - const size_t selected = pickLightInstance(world, pcg_uniform(&ss.rs)); + const size_t selected = pickLightInstance(world, uPick(kSobolDimLightPick1)); return {true, false, selected, @@ -448,17 +456,28 @@ VISRTX_DEVICE PickedCandidate pickCandidate( VISRTX_DEVICE SurfaceLightSample sampleLights(ScreenSample &ss, const FrameGPUData &frameData, const vec3 &origin, - const vec3 &normal) + const vec3 &normal, + bool useQmc, + uint32_t sampleIndex, + uint32_t pixelSeed) { - const PickedCandidate pick = pickCandidate(ss, frameData); + const PickedCandidate pick = + pickCandidate(ss, frameData, useQmc, sampleIndex, pixelSeed); if (!pick.valid) return {}; if (pick.isAmbient) { // Cosine-weighted hemisphere sample; pdf cos(theta)/pi folded with the pick - // probability so MIS weights see the full joint pdf. + // probability so MIS weights see the full joint pdf. Surface NEE uses + // FastOwen-scrambled Sobol dims 0–1 at the camera's ordinal, reseeded per + // bounce/transparency layer and intentionally shared with HDRI cosine + // sampling. The non-QMC fallback uses PCG. const auto &rp = frameData.renderer; - const vec3 dir = sampleHemisphere(ss.rs, normal); + const vec3 dir = useQmc + ? sampleHemisphere(owenSobol(sampleIndex, kSobolDimHemiU, pixelSeed), + owenSobol(sampleIndex, kSobolDimHemiV, pixelSeed), + normal) + : sampleHemisphere(ss.rs, normal); const float cosNs = fmaxf(0.f, dot(dir, normal)); return {LightSample{rp.ambientColor * rp.ambientIntensity, dir, @@ -469,8 +488,14 @@ VISRTX_DEVICE SurfaceLightSample sampleLights(ScreenSample &ss, } const auto &li = frameData.world.lightInstances[pick.instance]; - auto ls = - sampleLight(ss, origin, li.lightIndex, li.xfm, li.surfaceInstanceIndex); + auto ls = sampleLight(ss, + origin, + li.lightIndex, + li.xfm, + li.surfaceInstanceIndex, + useQmc, + sampleIndex, + pixelSeed); ls.pdf *= pick.pickPdf; const LightType type = frameData.registry.lights[li.lightIndex].type; // Ask the instance, not the type. An analytic area light only reaches the @@ -614,7 +639,9 @@ VISRTX_GLOBAL void __raygen__() for (int i = 0; i < rendererParams.numIterations; ++i) { bool isVeryFirstRay = i == 0 && ss.frameData->fb.frameID == 0; - // frameID already counts accumulated samples, not launches. + // The frame counter already counts completed samples. Camera and all + // surface Sobol draws below share this ordinal, including ordinal zero + // whose pixel jitter (but not aperture) is overridden by the center ray. const uint32_t sampleIdx = sampleOrdinal(ss.frameData->fb.frameID, i); auto ray = makePrimaryRay(ss, sampleIdx, isVeryFirstRay); const vec3 cameraOrigin = ray.org; @@ -623,6 +650,10 @@ VISRTX_GLOBAL void __raygen__() // into transport throughput: sampling, shadow work, RR and AOVs must still // run when the shaded RGB is completely replaced by fog. double appearanceWeight = 1.0; + // Surface Sobol dimensions 0–11 use this default-zero-scramble pixel + // key, reseeded per bounce/transparency layer below. Camera Halton uses + // its own additive index hash; no joint independence guarantee is implied. + const uint32_t pixelSeed = owenPixelSeed(ss.pixel.x, ss.pixel.y); // A Miss reports the camera's Far Limit, not where a cutting plane ends // the ray (ADR 0011). @@ -662,6 +693,8 @@ VISRTX_GLOBAL void __raygen__() // backdrop does at the miss -- spending isFirstBounce here revealed a // hidden light through any partially transparent surface. const bool isCameraRay = bounceDepth == 0; + const uint32_t qmcSeed = + owenBounceSeed(pixelSeed, bounceDepth, transparencyDepth); SurfaceHit surfaceHit = {}; // Camera rays see proxies of lights whose `visible` is true; continuation @@ -874,8 +907,13 @@ VISRTX_GLOBAL void __raygen__() // bump-mapped surfaces. const vec3 shadowOrigin = shadingHitpoint(surfaceHit) + surfaceHit.Ng * surfaceHit.epsilon; - const SurfaceLightSample lightPick = - sampleLights(ss, frameData, shadowOrigin, surfaceHit.Ns); + const SurfaceLightSample lightPick = sampleLights(ss, + frameData, + shadowOrigin, + surfaceHit.Ns, + true, + sampleIdx, + qmcSeed); LightSample lightSample = lightPick.ls; if (lightPick.isEnv) { if (!(dot(lightSample.dir, surfaceHit.Ns) > 0.0f)) @@ -961,7 +999,10 @@ VISRTX_GLOBAL void __raygen__() // carries each instance's pick probability because CDF NEE is // pick-gated. if (frameData.world.numHdriLightInstances > 0) { - const vec3 dirC = sampleHemisphere(ss.rs, surfaceHit.Ns); + const vec3 dirC = + sampleHemisphere(owenSobol(sampleIdx, kSobolDimHemiU, qmcSeed), + owenSobol(sampleIdx, kSobolDimHemiV, qmcSeed), + surfaceHit.Ns); const float cosC = fmaxf(0.0f, dot(dirC, surfaceHit.Ns)); vec3 envRadiance; if (cosC > 0.0f From e152b8d3874833e90fc0e356af4c7a3091c1134c Mon Sep 17 00:00:00 2001 From: Thomas Arcila <134677+tarcila@users.noreply.github.com> Date: Tue, 10 Nov 2026 02:11:04 +0000 Subject: [PATCH 4/6] feat(rtx): add bounded QMC material sampling Bound the ordered material overlay to four draws while preserving branch consumption and PCG fallback across native and MDL callables. Share the native continuation and fixed MDL draw implementation with host tests; keep light sampling coverage on the real CUDA path. --- devices/rtx/apps/tests/api/CMakeLists.txt | 4 + .../apps/tests/api/TestMaterialSampling.cpp | 147 +++++ devices/rtx/apps/tests/unit/CMakeLists.txt | 48 +- .../apps/tests/unit/sobol/contractProcess.h | 108 ++++ devices/rtx/apps/tests/unit/sobol/contracts.h | 49 ++ .../rtx/apps/tests/unit/test_DrawOrder.cpp | 197 +++++++ .../apps/tests/unit/test_SamplerContracts.cpp | 33 ++ .../tests/unit/test_SamplerContractsCUDA.cu | 117 ++++ devices/rtx/device/gpu/evalShading.h | 19 +- devices/rtx/device/gpu/gpu_util.h | 40 +- devices/rtx/device/gpu/samplingMath.h | 80 +++ devices/rtx/device/gpu/shadingState.h | 42 ++ .../device/material/shaders/MDLShader_ptx.cu | 18 +- .../material/shaders/MatteShader_ptx.cu | 2 +- .../shaders/PhysicallyBasedShader_ptx.cu | 454 +--------------- .../shaders/physicallyBasedSampling.h | 512 ++++++++++++++++++ devices/rtx/device/renderer/Quality_ptx.cu | 7 +- 17 files changed, 1370 insertions(+), 507 deletions(-) create mode 100644 devices/rtx/apps/tests/api/TestMaterialSampling.cpp create mode 100644 devices/rtx/apps/tests/unit/sobol/contractProcess.h create mode 100644 devices/rtx/apps/tests/unit/sobol/contracts.h create mode 100644 devices/rtx/apps/tests/unit/test_DrawOrder.cpp create mode 100644 devices/rtx/apps/tests/unit/test_SamplerContracts.cpp create mode 100644 devices/rtx/apps/tests/unit/test_SamplerContractsCUDA.cu create mode 100644 devices/rtx/device/gpu/samplingMath.h create mode 100644 devices/rtx/device/material/shaders/physicallyBasedSampling.h diff --git a/devices/rtx/apps/tests/api/CMakeLists.txt b/devices/rtx/apps/tests/api/CMakeLists.txt index 5f5dc14d3..8ad7d8e43 100644 --- a/devices/rtx/apps/tests/api/CMakeLists.txt +++ b/devices/rtx/apps/tests/api/CMakeLists.txt @@ -68,6 +68,8 @@ make_test(TestGroundSphereShadows) make_test(TestPowerLightPick) make_test(TestRayBufferCamera) make_test(TestCameraNearFar) +make_test(TestMaterialSampling) +set_tests_properties(TestMaterialSampling PROPERTIES TIMEOUT 120) make_test(TestSampleAddressing) target_include_directories(TestSampleAddressing PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../../device) @@ -112,6 +114,8 @@ make_test(TestEmissiveRecommit) # The raw `mdl` material type and the `physicallyBasedMDL` subtype only exist # with MDL support compiled in. if (VISRTX_ENABLE_MDL_SUPPORT) + target_compile_definitions( + TestMaterialSampling PRIVATE VISRTX_TEST_MDL_WRAPPER) target_compile_definitions( TestEmissiveRecommit PRIVATE VISRTX_TEST_MDL_WRAPPER) # Adds the physicallyBasedMDL leg, so the module's specular default is diff --git a/devices/rtx/apps/tests/api/TestMaterialSampling.cpp b/devices/rtx/apps/tests/api/TestMaterialSampling.cpp new file mode 100644 index 000000000..fbace61aa --- /dev/null +++ b/devices/rtx/apps/tests/api/TestMaterialSampling.cpp @@ -0,0 +1,147 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +// Runtime callable-layout gate: all materials must sample a lit, front-facing +// surface through both renderer pipelines, not just compile matching +// signatures. +#include +#include +#include +#include +#include +#include +#include +#include + +using Vec3 = std::array; +using Vec4 = std::array; +using UVec2 = std::array; + +static void status(const void *, + ANARIDevice, + ANARIObject, + ANARIDataType, + ANARIStatusSeverity severity, + ANARIStatusCode, + const char *message) +{ + if (severity <= ANARI_SEVERITY_ERROR) { + std::fprintf(stderr, "%s\n", message); + std::exit(1); + } +} + +static bool run( + anari::Device d, const char *rendererType, const char *materialType) +{ + const std::array positions = { + Vec3{-2, -2, 0}, Vec3{2, -2, 0}, Vec3{2, 2, 0}, Vec3{-2, 2, 0}}; + auto geometry = anari::newObject(d, "quad"); + anari::setParameterArray1D( + d, geometry, "vertex.position", positions.data(), 4); + anari::commitParameters(d, geometry); + auto material = anari::newObject(d, materialType); + const std::string type(materialType); + if (type == "mdl") { + anari::setParameter(d, material, "sourceType", "code"); + anari::setParameter(d, material, "source", R"mdl(mdl 1.6; +import ::df::*; +export material sampling_diffuse() = material( + surface: material_surface(scattering: df::diffuse_reflection_bsdf( + tint: color(0.5)))); +)mdl"); + anari::setParameter(d, material, "materialName", "sampling_diffuse"); + } else if (type == "matte") + anari::setParameter(d, material, "color", Vec3{.5f, .5f, .5f}); + else { + anari::setParameter(d, material, "baseColor", Vec3{.5f, .5f, .5f}); + anari::setParameter(d, material, "specular", 0.f); + anari::setParameter(d, material, "metallic", 0.f); + } + anari::commitParameters(d, material); + auto surface = anari::newObject(d); + anari::setAndReleaseParameter(d, surface, "geometry", geometry); + anari::setAndReleaseParameter(d, surface, "material", material); + anari::commitParameters(d, surface); + + const std::array texels = { + Vec3{1, 1, 1}, Vec3{1, 1, 1}, Vec3{1, 1, 1}, Vec3{1, 1, 1}}; + auto light = anari::newObject(d, "hdri"); + anari::setAndReleaseParameter( + d, light, "radiance", anari::newArray2D(d, texels.data(), 2, 2)); + anari::setParameter(d, light, "visible", false); + anari::commitParameters(d, light); + auto world = anari::newObject(d); + anari::setParameterArray1D(d, world, "surface", &surface, 1); + anari::setParameterArray1D(d, world, "light", &light, 1); + anari::release(d, surface); + anari::release(d, light); + anari::commitParameters(d, world); + auto camera = anari::newObject(d, "orthographic"); + anari::setParameter(d, camera, "position", Vec3{0, 0, 1}); + anari::setParameter(d, camera, "direction", Vec3{0, 0, -1}); + anari::setParameter(d, camera, "up", Vec3{0, 1, 0}); + anari::setParameter(d, camera, "height", 2.f); + anari::setParameter(d, camera, "aspect", 1.f); + anari::commitParameters(d, camera); + auto renderer = anari::newObject(d, rendererType); + anari::setParameter(d, renderer, "pixelSamples", 64); + anari::setParameter(d, renderer, "ambientRadiance", 0.f); + anari::setParameter(d, renderer, "denoise", false); + anari::setParameter(d, renderer, "fireflyFilterMode", "none"); + anari::setParameter(d, renderer, "sampleLimit", 0); + anari::commitParameters(d, renderer); + auto frame = anari::newObject(d); + anari::setParameter(d, frame, "size", UVec2{32, 32}); + anari::setParameter(d, frame, "channel.color", ANARI_FLOAT32_VEC4); + anari::setAndReleaseParameter(d, frame, "world", world); + anari::setAndReleaseParameter(d, frame, "camera", camera); + anari::setAndReleaseParameter(d, frame, "renderer", renderer); + anari::commitParameters(d, frame); + bool ok = true; + // Uniform Lambertian rho=.5 under L=1 has outgoing radiance .5. A missing + // continuation breaks the three-way MIS partition for PBR/raw MDL. Matte + // intentionally returns a dead ray and has its own matching zero BSDF pdf. + for (int launch = 0; launch < 2; ++launch) { + anari::render(d, frame); + anari::wait(d, frame); + auto image = anari::map(d, frame, "channel.color"); + double mean = 0; + if (!image.data || image.width != 32 || image.height != 32) + ok = false; + else { + for (unsigned i = 0; i < 32 * 32; ++i) { + const float value = image.data[i][0]; + ok &= std::isfinite(value); + mean += value; + } + mean /= 32 * 32; + ok &= std::abs(mean - .5) < .04; + } + anari::unmap(d, frame, "channel.color"); + std::printf("%s/%s launch %d mean %.9g: %s\n", + rendererType, + materialType, + launch, + mean, + ok ? "ok" : "FAIL"); + } + anari::release(d, frame); + return ok; +} + +int main() +{ + auto d = makeVisRTXDevice(status); + bool ok = true; + for (const char *renderer : {"quality", "interactive"}) { + ok &= run(d, renderer, "matte"); + ok &= run(d, renderer, "physicallyBased"); +#ifdef VISRTX_TEST_MDL_WRAPPER + ok &= run(d, renderer, "physicallyBasedMDL"); + ok &= run(d, renderer, "mdl"); +#endif + } + anari::release(d, d); + return ok ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/devices/rtx/apps/tests/unit/CMakeLists.txt b/devices/rtx/apps/tests/unit/CMakeLists.txt index 405c613f8..7a99fdf28 100644 --- a/devices/rtx/apps/tests/unit/CMakeLists.txt +++ b/devices/rtx/apps/tests/unit/CMakeLists.txt @@ -103,6 +103,7 @@ target_compile_definitions(rtx_test_SampleOrdinal PRIVATE GLM_ENABLE_EXPERIMENTA target_compile_features(rtx_test_SampleOrdinal PRIVATE cxx_std_17) add_test(NAME rtx::SampleOrdinal COMMAND rtx_test_SampleOrdinal) +# Offline header regeneration uses Python; draw tests include shared C++. find_package(Python3 REQUIRED COMPONENTS Interpreter) add_test(NAME rtx::SobolTableHeader COMMAND Python3::Interpreter -B @@ -112,6 +113,16 @@ add_test(NAME rtx::SobolReferencePublication ${CMAKE_CURRENT_LIST_DIR}/sobol/test_reference.py) set_tests_properties(rtx::SobolTableHeader rtx::SobolReferencePublication PROPERTIES TIMEOUT 30) +add_executable(rtx_test_DrawOrder test_DrawOrder.cpp) +target_include_directories(rtx_test_DrawOrder PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/../../../device + ${CMAKE_CURRENT_LIST_DIR}/../../../external/nanovdb/include + ${OptiX_ROOT_DIR}/include) +target_link_libraries(rtx_test_DrawOrder PRIVATE + CUDA::cudart visrtx::glm anari::anari_headers) +target_compile_definitions(rtx_test_DrawOrder PRIVATE GLM_ENABLE_EXPERIMENTAL) +target_compile_features(rtx_test_DrawOrder PRIVATE cxx_std_17) +add_test(NAME rtx::DrawOrder COMMAND rtx_test_DrawOrder) add_executable(rtx_test_LightDrawOrder test_LightDrawOrder.cu) target_include_directories(rtx_test_LightDrawOrder PRIVATE @@ -126,7 +137,7 @@ set_target_properties(rtx_test_LightDrawOrder PROPERTIES target_compile_options(rtx_test_LightDrawOrder PRIVATE --use_fast_math --expt-relaxed-constexpr) add_test(NAME rtx::LightDrawOrder COMMAND rtx_test_LightDrawOrder) -set_tests_properties(rtx::LightDrawOrder PROPERTIES TIMEOUT 60) +set_tests_properties(rtx::DrawOrder rtx::LightDrawOrder PROPERTIES TIMEOUT 60) # Production Sobol sampler against independently sourced Joe-Kuo parameters. add_executable(rtx_test_Sobol test_Sobol.cpp) @@ -149,6 +160,41 @@ add_test(NAME rtx::Sobol COMMAND rtx_test_Sobol) add_test(NAME rtx::SobolCUDA COMMAND rtx_test_SobolCUDA) set_tests_properties(rtx::Sobol rtx::SobolCUDA PROPERTIES TIMEOUT 60) +# Production sampler contracts, compiled separately so Release cannot mask the +# assertion-enabled gate (and assertions cannot mask the NDEBUG gate). +if(UNIX) + function(configure_sampler_contract_test target mode timeout) + target_include_directories(${target} PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/../../../device + ${CMAKE_CURRENT_LIST_DIR}/../../../external/nanovdb/include + ${OptiX_ROOT_DIR}/include) + target_link_libraries(${target} PRIVATE + CUDA::cudart visrtx::glm anari::anari_headers) + target_compile_definitions(${target} PRIVATE GLM_ENABLE_EXPERIMENTAL) + target_compile_features(${target} PRIVATE cxx_std_17) + if(mode STREQUAL "Assert") + target_compile_options(${target} PRIVATE -UNDEBUG) + else() + target_compile_definitions(${target} PRIVATE NDEBUG) + endif() + string(REPLACE "rtx_test_" "rtx::" test_name ${target}) + add_test(NAME ${test_name} COMMAND ${target}) + set_tests_properties(${test_name} PROPERTIES TIMEOUT ${timeout}) + endfunction() + + foreach(mode Assert NDEBUG) + add_executable(rtx_test_SamplerContracts${mode} test_SamplerContracts.cpp) + configure_sampler_contract_test(rtx_test_SamplerContracts${mode} ${mode} 120) + + add_executable(rtx_test_SamplerContractsCUDA${mode} test_SamplerContractsCUDA.cu) + configure_sampler_contract_test(rtx_test_SamplerContractsCUDA${mode} ${mode} 240) + set_target_properties(rtx_test_SamplerContractsCUDA${mode} PROPERTIES + CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON) + target_compile_options(rtx_test_SamplerContractsCUDA${mode} PRIVATE + --use_fast_math --expt-relaxed-constexpr) + endforeach() +endif() + # Standard-library-only executor tests. find_package(Threads REQUIRED) add_executable(rtx_test_TaskExecutor diff --git a/devices/rtx/apps/tests/unit/sobol/contractProcess.h b/devices/rtx/apps/tests/unit/sobol/contractProcess.h new file mode 100644 index 000000000..ae696470f --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/contractProcess.h @@ -0,0 +1,108 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace contract_test { + +struct Misuse +{ + int kind = 0; // raw, Owen, overlay, null overlay + uint32_t dimension = 16u; + uint32_t index = 1u; + int n = 0; + int cursor = 0; +}; + +inline Misuse parse(const char *mode) +{ + Misuse result; + if (std::sscanf(mode, "qmc:%d:%d", &result.n, &result.cursor) == 2) + result.kind = 2; + else if (std::sscanf(mode, "null:%d", &result.cursor) == 1) + result.kind = 3; + else if (std::strstr(mode, "owen")) + result.kind = 1; + result.dimension = std::strstr(mode, "max") ? UINT32_MAX : 16u; + result.index = std::strstr(mode, "zero") ? 0u : 1u; + return result; +} + +template +inline bool eachMisuse(Check check) +{ + for (const char *mode : {"raw16", + "rawmax", + "raw16zero", + "rawmaxzero", + "owen16", + "owenmax", + "owen16zero", + "owenmaxzero", + "null:-1", + "null:1", + "null:4", + "null:5"}) { + if (!check(mode)) + return false; + } + for (int n = -1; n <= 5; ++n) { + for (int cursor = -1; cursor <= 5; ++cursor) { + if (n >= 0 && n <= 4 && cursor >= 0 && cursor <= n) + continue; + char mode[40]; + std::snprintf(mode, sizeof(mode), "qmc:%d:%d", n, cursor); + if (!check(mode)) + return false; + } + } + return true; +} + +// Transport only: callers retain distinct SIGABRT vs normal expected-error +// exit predicates. Timeout, exec failure and unrelated crashes never pass. +template +inline bool run( + const char *executable, const char *mode, int seconds, Accept accept) +{ + const pid_t child = fork(); + if (child == 0) { + const rlimit noCore{0, 0}; + setrlimit(RLIMIT_CORE, &noCore); + execl(executable, executable, mode, nullptr); + _exit(127); + } + if (child < 0) + return false; + const auto deadline = + std::chrono::steady_clock::now() + std::chrono::seconds(seconds); + int status = 0; + while (std::chrono::steady_clock::now() < deadline) { + const auto waited = waitpid(child, &status, WNOHANG); + if (waited == child) { + if (accept(status)) + return true; + std::fprintf(stderr, "%s: unexpected child status %d\n", mode, status); + return false; + } + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + kill(child, SIGKILL); + waitpid(child, &status, 0); + std::fprintf(stderr, "%s: child timed out\n", mode); + return false; +} + +} // namespace contract_test diff --git a/devices/rtx/apps/tests/unit/sobol/contracts.h b/devices/rtx/apps/tests/unit/sobol/contracts.h new file mode 100644 index 000000000..51fa30693 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/contracts.h @@ -0,0 +1,49 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +#pragma once + +#include "gpu/owenSobol.h" +#include "gpu/shadingState.h" + +// Shared behavioral checks call the production overlay and PCG seams on both +// host and device. A cloned real PCG stream is the oracle for exactly one draw. +VISRTX_DEVICE bool validSamplerContracts() +{ + using namespace visrtx; + for (int n = 0; n <= 4; ++n) { + const NextRayQmc qmc{{0.125f, 0.25f, 0.5f, 0.75f}, n}; + for (int start = 0; start <= n; ++start) { + RandState actual{0x123456789abcdef0ull, 55ull}; + RandState expected = actual; + int cursor = start; + for (int draw = 0; draw < 8; ++draw) { + const bool supplied = start + draw < n; + const float want = + supplied ? qmc.u[start + draw] : pcg_uniform(&expected); + const float got = nextRayUniform(&actual, &qmc, cursor); + const int wantCursor = supplied ? start + draw + 1 : n; + if (got != want || cursor != wantCursor + || actual.state != expected.state || actual.inc != expected.inc) + return false; + } + // A PCG pointer is not required on the supplied-value path. + for (int i = start; i < n;) { + const float want = qmc.u[i]; + const int old = i; + if (nextRayUniform(nullptr, &qmc, i) != want || i != old + 1) + return false; + } + } + } + RandState actual{0x123456789abcdef0ull, 55ull}; + RandState expected = actual; + int cursor = 0; + for (int i = 0; i < 8; ++i) { + const float want = pcg_uniform(&expected); + if (nextRayUniform(&actual, nullptr, cursor) != want || cursor != 0 + || actual.state != expected.state || actual.inc != expected.inc) + return false; + } + // Ordinary dimension execution, including both table boundaries. + return sobolUInt(1u, 0u) == 0x80000000u && sobolUInt(1u, 15u) == 0x80000000u; +} diff --git a/devices/rtx/apps/tests/unit/test_DrawOrder.cpp b/devices/rtx/apps/tests/unit/test_DrawOrder.cpp new file mode 100644 index 000000000..23789269e --- /dev/null +++ b/devices/rtx/apps/tests/unit/test_DrawOrder.cpp @@ -0,0 +1,197 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#include "material/shaders/physicallyBasedSampling.h" + +#include +#include + +using namespace visrtx; + +namespace { +PhysicallyBasedShadingState material() +{ + PhysicallyBasedShadingState s{}; + s.baseColor = vec3(1.f); + s.viewAdjustedNormal = s.viewAdjustedClearcoatNormal = vec3(0, 0, 1); + s.roughness = s.clearcoatRoughness = .3f; + s.eta = 1.f / 1.5f; + s.occlusion = s.specular = 1.f; + s.specularColor = s.attenuationColor = vec3(1.f); + return s; +} + +struct SampleCase +{ + const char *name; + PhysicallyBasedShadingState state; + vec3 outgoing; + NextRayQmc qmc; + vec3 direction; + int fallbackDraws; + uint32_t flags = NEXT_RAY_NONE; + bool dead = false; +}; + +bool check(const SampleCase &test, const RandState &initial) +{ + auto random = initial; + auto expectedRandom = initial; + for (int i = 0; i < test.fallbackDraws; ++i) + (void)pcg_uniform(&expectedRandom); + const auto ray = + samplePhysicallyBased(&test.state, test.outgoing, &random, &test.qmc); + const bool output = test.dead + ? ray.pdf == 0.f && glm::length(ray.contributionWeight) == 0.f + : glm::length(ray.direction - test.direction) < 1e-6f + && ray.flags == test.flags; + const bool ok = output && random.state == expectedRandom.state + && random.inc == expectedRandom.inc; + if (!ok) + std::fprintf(stderr, "FAIL: %s\n", test.name); + return ok; +} + +// Only component ordering belongs here. The exhaustive n/cursor/fallback matrix +// is tested separately by SamplerContracts on both host and CUDA. +bool checkMdlComponents(const RandState &initial, int supplied) +{ + NextRayQmc qmc{{.125f, .25f, .5f, .75f}, supplied}; + auto random = initial; + auto expectedRandom = initial; + float expected[4]; + for (int i = 0; i < 4; ++i) + expected[i] = i < supplied ? qmc.u[i] : pcg_uniform(&expectedRandom); + const auto xi = materialUniform4(random, &qmc); + const bool ok = xi.x == expected[0] && xi.y == expected[1] + && xi.z == expected[2] && xi.w == expected[3] + && random.state == expectedRandom.state + && random.inc == expectedRandom.inc; + if (!ok) + std::fprintf(stderr, "FAIL: MDL component order (%d supplied)\n", supplied); + return ok; +} +} // namespace + +int main() +{ + RandState initial; + pcg_init(&initial, 42, 7); + const vec3 outgoing(0, 0, 1); + // Independent analytic fixtures at normal incidence. Asymmetric u/v makes + // swapping the radius and azimuth observable without duplicating the BSDF. + const vec3 diffuse( + .5f * std::cos(kPi / 4), .5f * std::sin(kPi / 4), std::sqrt(.75f)); + const vec3 h = glm::normalize(vec3(.09f * .5f * std::cos(kPi / 4), + .09f * .5f * std::sin(kPi / 4), + std::sqrt(.75f))); + const vec3 reflected(2.f * h.z * h.x, 2.f * h.z * h.y, 2.f * h.z * h.z - 1.f); + auto coat = material(); + coat.clearcoat = 1.f; + auto transmission = coat; + transmission.transmission = 1.f; + const float eta = transmission.eta; + const float cosT = std::sqrt(1.f - eta * eta * (1.f - h.z * h.z)); + const vec3 refracted = glm::normalize(vec3((eta * h.z - cosT) * h.x, + (eta * h.z - cosT) * h.y, + -eta + (eta * h.z - cosT) * h.z)); + + std::vector cases = {{"no-coat diffuse", + material(), + outgoing, + {{.9f, .25f, .125f, 0.f}, 3}, + diffuse, + 0}, + {"selected coat", + coat, + outgoing, + {{.01f, .25f, .125f, 0.f}, 3}, + reflected, + 0}, + {"rejected coat diffuse", + coat, + outgoing, + {{.99f, .9f, .25f, .125f}, 4}, + diffuse, + 0}, + {"rejected coat specular fifth draw", + coat, + outgoing, + {{.99f, 0.f, .25f, .125f}, 4}, + reflected, + 1}, + {"no-coat specular", + material(), + outgoing, + {{0.f, .25f, .125f, .5f}, 4}, + reflected, + 0}, + {"transmission fifth draw", + transmission, + outgoing, + {{.99f, 0.f, .25f, .125f}, 4}, + refracted, + 1, + NEXT_RAY_CONTINUES_THROUGH_SURFACE}}; + + // Set n to the allowed prefix: an eager request past any early exit would + // advance PCG, so the same checks catch it without observing a private + // cursor. + auto zero = material(); + zero.baseColor = vec3(0.f); + zero.specular = 0.f; + auto zeroCoat = zero; + zeroCoat.clearcoat = 1.f; + auto roughCoat = coat; + roughCoat.clearcoatRoughness = 1.f; + auto rough = material(); + rough.roughness = 1.f; + const SampleCase dead[] = {{"invalid base view", + material(), + -outgoing, + {{}, 0}, + {}, + 0, + NEXT_RAY_NONE, + true}, + {"invalid coat view", + coat, + -outgoing, + {{0.f}, 1}, + {}, + 0, + NEXT_RAY_NONE, + true}, + {"zero base energy", zero, outgoing, {{}, 0}, {}, 0, NEXT_RAY_NONE, true}, + {"rejected coat zero energy", + zeroCoat, + outgoing, + {{.99f}, 1}, + {}, + 0, + NEXT_RAY_NONE, + true}, + {"coat below-surface reflection", + roughCoat, + outgoing, + {{0.f, .9f, .125f, .5f}, 3}, + {}, + 0, + NEXT_RAY_NONE, + true}, + {"base below-surface reflection", + rough, + outgoing, + {{0.f, .9f, .125f, .5f}, 4}, + {}, + 0, + NEXT_RAY_NONE, + true}}; + cases.insert(cases.end(), std::begin(dead), std::end(dead)); + bool ok = true; + for (const auto &test : cases) + ok = check(test, initial) && ok; + ok = checkMdlComponents(initial, 4) && ok; + ok = checkMdlComponents(initial, 2) && ok; + return ok ? 0 : 1; +} diff --git a/devices/rtx/apps/tests/unit/test_SamplerContracts.cpp b/devices/rtx/apps/tests/unit/test_SamplerContracts.cpp new file mode 100644 index 000000000..f62011e4e --- /dev/null +++ b/devices/rtx/apps/tests/unit/test_SamplerContracts.cpp @@ -0,0 +1,33 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#include "sobol/contractProcess.h" +#include "sobol/contracts.h" + +int main(int argc, char **argv) +{ + if (argc == 2) { + const auto in = contract_test::parse(argv[1]); + int cursor = in.cursor; + visrtx::NextRayQmc qmc{{0.125f, 0.25f, 0.5f, 0.75f}, in.n}; + visrtx::RandState rs{42u, 55u}; + volatile float sample = in.kind >= 2 + ? visrtx::nextRayUniform(&rs, in.kind == 2 ? &qmc : nullptr, cursor) + : in.kind == 1 ? visrtx::owenSobol(in.index, in.dimension, 123u) + : float(visrtx::sobolUInt(in.index, in.dimension)); + (void)sample; + return 0; + } + if (!validSamplerContracts()) { + std::fprintf(stderr, "valid sampler/PCG contract failed\n"); + return 1; + } + // Only SIGABRT is an expected host failure, never arbitrary nonzero exit. + return contract_test::eachMisuse([&](const char *mode) { + return contract_test::run(argv[0], mode, 10, [](int status) { + return WIFSIGNALED(status) && WTERMSIG(status) == SIGABRT; + }); + }) + ? 0 + : 1; +} diff --git a/devices/rtx/apps/tests/unit/test_SamplerContractsCUDA.cu b/devices/rtx/apps/tests/unit/test_SamplerContractsCUDA.cu new file mode 100644 index 000000000..1b2908a17 --- /dev/null +++ b/devices/rtx/apps/tests/unit/test_SamplerContractsCUDA.cu @@ -0,0 +1,117 @@ +// Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +#include "sobol/contractProcess.h" +#include "sobol/contracts.h" +#include "sobol/cudaResources.h" + +#include + +namespace { +constexpr int expectedErrorExit = 42; + +VISRTX_GLOBAL void baseline(int *result) +{ + *result = validSamplerContracts() ? 1 : 0; +} + +VISRTX_GLOBAL void misuse(contract_test::Misuse in, float *result) +{ + using namespace visrtx; + if (in.kind == 0) + *result = float(sobolUInt(in.index, in.dimension)); + else if (in.kind == 1) + *result = owenSobol(in.index, in.dimension, 123u); + else { + NextRayQmc qmc{{0.125f, 0.25f, 0.5f, 0.75f}, in.n}; + RandState rs{42u, 55u}; + *result = nextRayUniform(&rs, in.kind == 2 ? &qmc : nullptr, in.cursor); + } +} + +bool check(cudaError_t error, const char *operation) +{ + if (error == cudaSuccess) + return true; + std::fprintf( + stderr, "%s: %s (%d)\n", operation, cudaGetErrorName(error), int(error)); + return false; +} + +int child(const char *mode) +{ + int count = 0; + if (!check(cudaGetDeviceCount(&count), "availability") || count == 0) + return 1; + CudaBuffer result; + if (!check(result.allocate(1), "allocation")) + return 1; + baseline<<<1, 1>>>(result.get()); + if (!check(cudaGetLastError(), "baseline launch") + || !check(cudaDeviceSynchronize(), "baseline sync")) + return 1; + int value = 0; + if (!check( + cudaMemcpy(&value, result.get(), sizeof(int), cudaMemcpyDeviceToHost), + "baseline copy") + || value != 1) + return 1; + if (std::strcmp(mode, "baseline") == 0) { + int runtime = 0, driver = 0; + cudaRuntimeGetVersion(&runtime); + cudaDriverGetVersion(&driver); + std::printf( + "CUDA baseline passed; runtime=%d driver=%d\n", runtime, driver); + return 0; + } + + const auto in = contract_test::parse(mode); + auto *output = reinterpret_cast(result.get()); + // Relinquish cleanup before the trap: even failure returns below must not + // make destructor CUDA calls into the disposable, poisoned context. + result.abandon(); + misuse<<<1, 1>>>(in, output); + if (!check(cudaGetLastError(), "negative launch")) + return 1; // Prelaunch errors are never expected failures. + const cudaError_t error = cudaDeviceSynchronize(); + // Reviewed Linux/CUDA allowlist: only execution assert/trap outcomes. + // Memory-access, availability, initialization and unknown errors fail closed. + if (error != cudaErrorAssert && error != cudaErrorIllegalInstruction + && error != cudaErrorLaunchFailure) { + std::fprintf(stderr, + "%s: unexpected synchronization %s (%d)\n", + mode, + cudaGetErrorName(error), + int(error)); + return 1; + } + std::printf("%s: expected synchronization %s (%d); child completes\n", + mode, + cudaGetErrorName(error), + int(error)); + // Do not make any further CUDA calls or reuse the poisoned context. + return expectedErrorExit; +} + +bool run(const char *executable, const char *mode, int expected) +{ + return contract_test::run(executable, mode, 20, [=](int status) { + return WIFEXITED(status) && WEXITSTATUS(status) == expected; + }); +} +} // namespace + +int main(int argc, char **argv) +{ + if (argc == 2) + return child(argv[1]); + // Parent never initializes CUDA. Every case execs a fresh process/context, + // establishes successful execution first, and must explicitly exit normally. + if (!run(argv[0], "baseline", 0)) + return 1; + return contract_test::eachMisuse([&](const char *mode) { + return run(argv[0], mode, expectedErrorExit); + }) + ? 0 + : 1; +} diff --git a/devices/rtx/device/gpu/evalShading.h b/devices/rtx/device/gpu/evalShading.h index 192bf832c..bfca860bd 100644 --- a/devices/rtx/device/gpu/evalShading.h +++ b/devices/rtx/device/gpu/evalShading.h @@ -84,8 +84,10 @@ VISRTX_DEVICE vec3 materialEvaluateNormal( &shadingState.data); } -VISRTX_DEVICE NextRay materialNextRay( - const MaterialShadingState &shadingState, const Ray &ray, RandState &rs) +VISRTX_DEVICE NextRay materialNextRay(const MaterialShadingState &shadingState, + const Ray &ray, + RandState &rs, + const NextRayQmc *qmc = nullptr) { if (shadingState.callableBaseIndex == ~DeviceObjectIndex(0)) // No next ray by default @@ -95,16 +97,16 @@ VISRTX_DEVICE NextRay materialNextRay( + int(SurfaceShaderEntryPoints::EvaluateNextRay), &shadingState.data, &ray, - &rs); + &rs, + qmc); } // Solid-angle pdf the material's BSDF sampler would assign to direction `wi` // given outgoing direction `wo` (both world space), for environment MIS. 0 for // no material and for materials whose sampler cannot produce `wi` (e.g. Matte, // which has no continuation ray). -VISRTX_DEVICE float materialEvalPdf(const MaterialShadingState &shadingState, - const vec3 &wo, - const vec3 &wi) +VISRTX_DEVICE float materialEvalPdf( + const MaterialShadingState &shadingState, const vec3 &wo, const vec3 &wi) { if (shadingState.callableBaseIndex == ~DeviceObjectIndex(0)) return 0.0f; @@ -122,9 +124,8 @@ VISRTX_DEVICE float materialEvalPdf(const MaterialShadingState &shadingState, // toward the viewer. Pairs with materialEvalPdf: same lobe mixture, same // conventions, reflection side only (transmission returns 0, as NEE cannot // reach it). -VISRTX_DEVICE vec3 materialEvalBsdf(const MaterialShadingState &shadingState, - const vec3 &wo, - const vec3 &wi) +VISRTX_DEVICE vec3 materialEvalBsdf( + const MaterialShadingState &shadingState, const vec3 &wo, const vec3 &wi) { if (shadingState.callableBaseIndex == ~DeviceObjectIndex(0)) return vec3(0.0f); // No material: no reflected energy diff --git a/devices/rtx/device/gpu/gpu_util.h b/devices/rtx/device/gpu/gpu_util.h index f2aec0098..79f362370 100644 --- a/devices/rtx/device/gpu/gpu_util.h +++ b/devices/rtx/device/gpu/gpu_util.h @@ -36,6 +36,7 @@ #include "gpu/owenSobol.h" #include "gpu_objects.h" #include "gpu_tonemap.h" +#include "samplingMath.h" #include "shadingState.h" // optix #include @@ -142,12 +143,6 @@ VISRTX_DEVICE void accumulateNormal(T &a, const T &b, float interp) accumulateValue(a, b, interp); } -// Rec.709 luminance. -VISRTX_DEVICE float luminance(const vec3 &c) -{ - return glm::dot(c, vec3(0.2126f, 0.7152f, 0.0722f)); -} - namespace detail { VISRTX_DEVICE void packPointer(void *ptr, uint32_t &i0, uint32_t &i1) @@ -218,39 +213,6 @@ VISRTX_DEVICE vec3 randomDir(RandState &rs, const vec3 &normal) return dot(dir, normal) > 0.f ? dir : -dir; } -VISRTX_DEVICE mat3 computeOrthonormalBasis(const vec3 &normal) -{ - // https://graphics.pixar.com/library/OrthonormalB/paper.pdf - auto sign = normal.z >= 0.0f ? 1.0f : -1.0f; - auto a = -1.0f / (sign + normal.z); - auto b = normal.x * normal.y * a; - auto u = - vec3(1.0f + sign * normal.x * normal.x * a, sign * b, -sign * normal.x); - auto v = vec3(b, sign + normal.y * normal.y * a, -normal.y); - - return mat3(u, v, normal); -} - -// Cosine-weighted hemisphere sample (Malley's method); pdf = cos(theta)/pi. -// u1/u2 in [0, 1). The RandState overload draws them from PCG in that order. -// Quality env/ambient NEE intentionally shares Owen-scrambled Sobol dims 0–1, -// with per-surface-bounce/transparency reseeding. -VISRTX_DEVICE vec3 sampleHemisphere(float u1, float u2, const vec3 &normal) -{ - const float r = sqrtf(u1); - const float z = sqrtf(fmaxf(0.f, 1.f - r * r)); - const float phi = kTwoPi * u2; - const vec3 sample(r * cosf(phi), r * sinf(phi), z); - return computeOrthonormalBasis(normal) * sample; -} - -VISRTX_DEVICE vec3 sampleHemisphere(RandState &rs, const vec3 &normal) -{ - const float u = pcg_uniform(&rs); - const float v = pcg_uniform(&rs); - return sampleHemisphere(u, v, normal); -} - VISRTX_DEVICE vec3 sampleUnitSphere(RandState &rs, const vec3 &normal) { // sample unit sphere diff --git a/devices/rtx/device/gpu/samplingMath.h b/devices/rtx/device/gpu/samplingMath.h new file mode 100644 index 000000000..887124a33 --- /dev/null +++ b/devices/rtx/device/gpu/samplingMath.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "gpu_math.h" +#include "pcg.h" + +#include + +namespace visrtx { + +// Rec.709 luminance. +VISRTX_DEVICE float luminance(const vec3 &c) +{ + return glm::dot(c, vec3(0.2126f, 0.7152f, 0.0722f)); +} + +VISRTX_DEVICE mat3 computeOrthonormalBasis(const vec3 &normal) +{ + // https://graphics.pixar.com/library/OrthonormalB/paper.pdf + auto sign = normal.z >= 0.0f ? 1.0f : -1.0f; + auto a = -1.0f / (sign + normal.z); + auto b = normal.x * normal.y * a; + auto u = + vec3(1.0f + sign * normal.x * normal.x * a, sign * b, -sign * normal.x); + auto v = vec3(b, sign + normal.y * normal.y * a, -normal.y); + + return mat3(u, v, normal); +} + +// Cosine-weighted hemisphere sample (Malley's method); pdf = cos(theta)/pi. +// u1/u2 in [0, 1). The RandState overload draws them from PCG in that order. +// Quality env/ambient NEE intentionally shares Owen-scrambled Sobol dims 0–1, +// with per-surface-bounce/transparency reseeding. +VISRTX_DEVICE vec3 sampleHemisphere(float u1, float u2, const vec3 &normal) +{ + const float r = sqrtf(u1); + const float z = sqrtf(fmaxf(0.f, 1.f - r * r)); + const float phi = kTwoPi * u2; + const vec3 sample(r * cosf(phi), r * sinf(phi), z); + return computeOrthonormalBasis(normal) * sample; +} + +VISRTX_DEVICE vec3 sampleHemisphere(PCGState &rs, const vec3 &normal) +{ + const float u = pcg_uniform(&rs); + const float v = pcg_uniform(&rs); + return sampleHemisphere(u, v, normal); +} + +} // namespace visrtx diff --git a/devices/rtx/device/gpu/shadingState.h b/devices/rtx/device/gpu/shadingState.h index 648a8169c..a192c577d 100644 --- a/devices/rtx/device/gpu/shadingState.h +++ b/devices/rtx/device/gpu/shadingState.h @@ -34,6 +34,8 @@ #include "gpu_decl.h" #include "gpu_math.h" #include "gpu_objects.h" +#include "pcg.h" +#include "samplerContracts.h" #ifdef USE_MDL #include @@ -70,6 +72,46 @@ struct NextRay uint32_t flags{NEXT_RAY_NONE}; }; +// Optional Sobol overlay for EvaluateNextRay. First `n` uniforms come from +// u[0..n); the rest fall back to PCG. n==0 means all PCG; Interactive uses +// nullptr by default. Quality fills n=4 from Sobol dims 8–11 per surface +// vertex, with bounce/transparency reseeding. Categorical material decisions +// consume this same branch-dependent sequence, not a separate PCG stream. +// Initialize cursor=0. Non-null overlays require 0<=n<=4, 0<=cursor<=n; +// exhausted cursors saturate at n. Null overlays require cursor=0 and leave it +// unchanged. Invalid states abort/trap even with NDEBUG. PCG must be valid +// whenever a fallback draw is needed; supplied values never touch PCG. +struct NextRayQmc +{ + float u[4]; + int n; +}; + +VISRTX_DEVICE float nextRayUniform( + RandState *rs, const NextRayQmc *qmc, int &cursor) +{ + if (qmc) { + if (qmc->n < 0 || qmc->n > 4 || cursor < 0 || cursor > qmc->n) + detail::samplerContractFailure(); + if (cursor < qmc->n) + return qmc->u[cursor++]; + } else if (cursor != 0) + detail::samplerContractFailure(); + return pcg_uniform(rs); +} + +// MDL requests a fixed four-component sample; native PBR must keep its +// conditional cursor consumption instead of eagerly calling this helper. +VISRTX_DEVICE ::float4 materialUniform4(RandState &rs, const NextRayQmc *qmc) +{ + int cursor = 0; + const float x = nextRayUniform(&rs, qmc, cursor); + const float y = nextRayUniform(&rs, qmc, cursor); + const float z = nextRayUniform(&rs, qmc, cursor); + const float w = nextRayUniform(&rs, qmc, cursor); + return {x, y, z, w}; +} + // Matte struct MatteShadingState { diff --git a/devices/rtx/device/material/shaders/MDLShader_ptx.cu b/devices/rtx/device/material/shaders/MDLShader_ptx.cu index 0b2474e11..40d460541 100644 --- a/devices/rtx/device/material/shaders/MDLShader_ptx.cu +++ b/devices/rtx/device/material/shaders/MDLShader_ptx.cu @@ -216,8 +216,10 @@ vec3 __direct_callable__evalBsdf( // Signature must match the call inside shaderMDLSurface in MDLShader.cuh. VISRTX_CALLABLE -NextRay __direct_callable__nextRay( - const MDLShadingState *shadingState, const Ray *ray, RandState *rs) +NextRay __direct_callable__nextRay(const MDLShadingState *shadingState, + const Ray *ray, + RandState *rs, + const NextRayQmc *qmc) { // Sample BsdfSampleData sample_data = {}; @@ -229,8 +231,7 @@ NextRay __direct_callable__nextRay( sample_data.ior2 = make_float3(1.0f, 1.0f, 1.0f); } sample_data.k1 = make_float3(-ray->dir); - sample_data.xi = make_float4( - pcg_uniform(rs), pcg_uniform(rs), pcg_uniform(rs), pcg_uniform(rs)); + sample_data.xi = materialUniform4(*rs, qmc); mdlBsdf_sample(&sample_data, &shadingState->state, @@ -251,8 +252,7 @@ NextRay __direct_callable__nextRay( // the finite sampling pdf and are MIS-combined with NEE. const bool isSpecular = (sample_data.event_type & mi::neuraylib::BSDF_EVENT_SPECULAR) != 0; - const float pdf = - (isSpecular || (flags & NEXT_RAY_CONTINUES_THROUGH_SURFACE)) + const float pdf = (isSpecular || (flags & NEXT_RAY_CONTINUES_THROUGH_SURFACE)) ? INFINITY : sample_data.pdf; return NextRay{direction, @@ -307,9 +307,9 @@ vec3 __direct_callable__evaluateEmission( &shadingState->state, &shadingState->resData, shadingState->argBlock); // Emitted radiance L(k1) = edf(k1) * intensity. `intensity` is radiant - // exitance (the material pre-multiplies by PI), and df::diffuse_edf's value is - // 1/PI, so this yields the authored radiance. The `cos/pdf` factors are the - // sample-path `edf_over_pdf` quantity, not part of radiance evaluation; + // exitance (the material pre-multiplies by PI), and df::diffuse_edf's value + // is 1/PI, so this yields the authored radiance. The `cos/pdf` factors are + // the sample-path `edf_over_pdf` quantity, not part of radiance evaluation; // including them cancelled to `intensity` and made emission PI x too bright. // Matches NVIDIA's df_cuda reference renderer. NOTE: assumes // intensity_radiant_exitance mode; intensity_power is not yet handled. diff --git a/devices/rtx/device/material/shaders/MatteShader_ptx.cu b/devices/rtx/device/material/shaders/MatteShader_ptx.cu index ea7c51d07..36d56f6a9 100644 --- a/devices/rtx/device/material/shaders/MatteShader_ptx.cu +++ b/devices/rtx/device/material/shaders/MatteShader_ptx.cu @@ -57,7 +57,7 @@ VISRTX_CALLABLE void __direct_callable__init(MatteShadingState *shadingState, } VISRTX_CALLABLE NextRay __direct_callable__nextRay( - const MatteShadingState *, const Ray *, RandState *) + const MatteShadingState *, const Ray *, RandState *, const NextRayQmc *) { return NextRay{vec3(0.0f), vec3(0.0f), 0.0f}; } diff --git a/devices/rtx/device/material/shaders/PhysicallyBasedShader_ptx.cu b/devices/rtx/device/material/shaders/PhysicallyBasedShader_ptx.cu index 5abb4a377..cc1d7ed62 100644 --- a/devices/rtx/device/material/shaders/PhysicallyBasedShader_ptx.cu +++ b/devices/rtx/device/material/shaders/PhysicallyBasedShader_ptx.cu @@ -36,11 +36,11 @@ #include "gpu/sampleLight.h" #include "gpu/shadingState.h" #include "gpu/shading_api.h" +#include "physicallyBasedSampling.h" using namespace visrtx; -// Clearcoat is fixed to IOR 1.5 per glTF KHR_materials_clearcoat (F0 = 0.04). -constexpr float CLEARCOAT_F0 = 0.04f; +using namespace visrtx::detail; //----------------------------------------------------------------------------- // Helpers @@ -76,80 +76,6 @@ VISRTX_DEVICE vec3 sampleNormalMap(const FrameGPUData &fd, return (dot(N, N) > 1e-12f) ? N : hit.Ng; } -VISRTX_DEVICE vec3 computeVolumeTransmission( - const PhysicallyBasedShadingState *state) -{ - if (!(state->thickness > 0.0f && state->attenuationDistance > 0.0f - && isfinite(state->attenuationDistance))) - return vec3(1.0f); - - const float k = state->thickness / state->attenuationDistance; - return vec3(powf(fmaxf(state->attenuationColor.x, 1e-6f), k), - powf(fmaxf(state->attenuationColor.y, 1e-6f), k), - powf(fmaxf(state->attenuationColor.z, 1e-6f), k)); -} - -VISRTX_DEVICE vec3 computeTransmissionFilter( - const PhysicallyBasedShadingState *state) -{ - const float transmission = - fmaxf(0.0f, (1.0f - state->metallic) * state->transmission); - return state->baseColor * transmission * computeVolumeTransmission(state); -} - -// Smith Lambda for GGX (common subterm of G1 / G2). -VISRTX_DEVICE float smithLambdaGGX(float NdotX, float alpha2) -{ - const float NdotX2 = NdotX * NdotX; - const float safe = fmaxf(NdotX2, 1e-8f); - return 0.5f - * (-1.0f + sqrtf(fmaxf(0.0f, 1.0f + alpha2 * (1.0f - safe) / safe))); -} - -VISRTX_DEVICE float smithG2GGX(float NdotV, float NdotL, float alpha2) -{ - return 1.0f - / (1.0f + smithLambdaGGX(NdotV, alpha2) + smithLambdaGGX(NdotL, alpha2)); -} - -VISRTX_DEVICE float smithG1GGX(float NdotV, float alpha2) -{ - return 1.0f / (1.0f + smithLambdaGGX(NdotV, alpha2)); -} - -VISRTX_DEVICE float ggxD(float NdotH, float alpha2) -{ - // The textbook denom `x·(α²−1) + 1` cancels catastrophically in fp32 once - // α² is below eps(1) ≈ 1.19e-7 (our α² floor is 1e-8): `α²−1` rounds to - // exactly −1, and at x=1 the whole denom collapses to 0. The algebraically - // equivalent `α²·x + (1−x)` has no near-1 subtraction so it stays exact. - // The fminf clamp keeps `1−x ≥ 0` against dot-product rounding above 1. - const float NdotH2 = fminf(NdotH * NdotH, 1.0f); - const float denom = alpha2 * NdotH2 + (1.0f - NdotH2); - return alpha2 / (kPi * denom * denom); -} - -// Heitz 2018 (https://jcgt.org/published/0007/04/01/) visible-normal sampling -// for GGX. Ve is the view direction in local tangent space (+z = normal). -VISRTX_DEVICE vec3 sampleGGXVNDF( - const vec3 &Ve, float alpha, float u1, float u2) -{ - const vec3 Vh = normalize(vec3(alpha * Ve.x, alpha * Ve.y, Ve.z)); - const float lensq = Vh.x * Vh.x + Vh.y * Vh.y; - const vec3 T1 = lensq > 0.0f ? vec3(-Vh.y, Vh.x, 0.0f) * (1.0f / sqrtf(lensq)) - : vec3(1.0f, 0.0f, 0.0f); - const vec3 T2 = glm::cross(Vh, T1); - const float r = sqrtf(u1); - const float phi = kTwoPi * u2; - const float t1 = r * cosf(phi); - float t2 = r * sinf(phi); - const float s = 0.5f * (1.0f + Vh.z); - t2 = (1.0f - s) * sqrtf(fmaxf(0.0f, 1.0f - t1 * t1)) + s * t2; - const vec3 Nh = - t1 * T1 + t2 * T2 + sqrtf(fmaxf(0.0f, 1.0f - t1 * t1 - t2 * t2)) * Vh; - return normalize(vec3(alpha * Nh.x, alpha * Nh.y, fmaxf(0.0f, Nh.z))); -} - // Charlie distribution (Estevez-Kulla 2017) for sheen. VISRTX_DEVICE float charlieD(float NdotH, float alpha) { @@ -164,108 +90,6 @@ VISRTX_DEVICE float charlieV(float NdotV, float NdotL) return 1.0f / (4.0f * (NdotV + NdotL - NdotV * NdotL) + 1e-6f); } -// glTF KHR_materials_iridescence thin-film Fresnel (port of the reference -// implementation at github.com/KhronosGroup/glTF-Sample-Renderer). Returns a -// per-channel Fresnel reflectance for a thin film of thickness T sitting on a -// base with Schlick F0. See the spec's Appendix B for the math. -VISRTX_DEVICE vec3 fresnel0ToIor(vec3 F0) -{ - const vec3 s = glm::sqrt(glm::clamp(F0, vec3(0.0f), vec3(0.9999f))); - return (vec3(1.0f) + s) / (vec3(1.0f) - s); -} - -VISRTX_DEVICE vec3 iorToFresnel0(vec3 transmittedIor, float incidentIor) -{ - const vec3 t = (transmittedIor - vec3(incidentIor)) - / (transmittedIor + vec3(incidentIor)); - return t * t; -} - -VISRTX_DEVICE float iorToFresnel0(float transmittedIor, float incidentIor) -{ - const float t = - (transmittedIor - incidentIor) / (transmittedIor + incidentIor); - return t * t; -} - -VISRTX_DEVICE vec3 evalSensitivity(float opd, vec3 shift) -{ - // Approximate spectral sensitivity of the standard observer as three - // Gaussians (Belcour & Barla 2017, simplified) so the result stays in RGB. - const float phase = kTwoPi * opd * 1e-9f; - const vec3 val = vec3(5.4856e-13f, 4.4201e-13f, 5.2481e-13f); - const vec3 pos = vec3(1.6810e+06f, 1.7953e+06f, 2.2084e+06f); - const vec3 var = vec3(4.3278e+09f, 9.3046e+09f, 6.6121e+09f); - - vec3 xyz = val * glm::sqrt(kTwoPi * var) * glm::cos(pos * phase + shift) - * glm::exp(-var * phase * phase); - xyz.x += 9.7470e-14f * sqrtf(kTwoPi * 4.5282e+09f) - * cosf(2.2399e+06f * phase + shift.x) - * expf(-4.5282e+09f * phase * phase); - xyz /= 1.0685e-7f; - - // sRGB conversion (D65). - return vec3(3.2404542f * xyz.x - 1.5371385f * xyz.y - 0.4985314f * xyz.z, - -0.9692660f * xyz.x + 1.8760108f * xyz.y + 0.0415560f * xyz.z, - 0.0556434f * xyz.x - 0.2040259f * xyz.y + 1.0572252f * xyz.z); -} - -VISRTX_DEVICE vec3 evalIridescence(float outsideIor, - float iridescenceIor, - float cosTheta1, - float thickness, - vec3 baseF0) -{ - // Handle the case where thin-film IOR is close to the outside IOR: return - // the base Fresnel to avoid division by zero and phase artifacts. - const float iridescenceIorSafe = fmaxf(iridescenceIor, outsideIor + 1e-4f); - - // Force iridescenceIor > outsideIor (otherwise Snell's law cannot refract). - const float sinTheta2Sq = - pow2(outsideIor / iridescenceIorSafe) * (1.0f - cosTheta1 * cosTheta1); - const float cosTheta2Sq = 1.0f - sinTheta2Sq; - if (cosTheta2Sq < 0.0f) - return vec3(1.0f); // Total internal reflection. - const float cosTheta2 = sqrtf(cosTheta2Sq); - - // First interface: Fresnel between outside and thin film. - const float R0_12 = iorToFresnel0(iridescenceIorSafe, outsideIor); - const float R12 = R0_12 + (1.0f - R0_12) * pow5(1.0f - cosTheta1); - const float T121 = 1.0f - R12; - const float phi12 = iridescenceIorSafe < outsideIor ? kPi : 0.0f; - const float phi21 = kPi - phi12; - - // Second interface: film to base. - const vec3 baseIor = - fresnel0ToIor(glm::clamp(baseF0, vec3(0.f), vec3(0.9999f))); - const vec3 R1 = iorToFresnel0(baseIor, iridescenceIorSafe); - const vec3 R23 = R1 + (vec3(1.0f) - R1) * pow5(1.0f - cosTheta2); - const vec3 phi23 = vec3(baseIor.x < iridescenceIorSafe ? kPi : 0.0f, - baseIor.y < iridescenceIorSafe ? kPi : 0.0f, - baseIor.z < iridescenceIorSafe ? kPi : 0.0f); - - const float opd = 2.0f * iridescenceIorSafe * thickness * cosTheta2; - const vec3 phi = vec3(phi21) + phi23; - - const vec3 R123 = glm::clamp(R12 * R23, vec3(1e-5f), vec3(0.9999f)); - const vec3 r123 = glm::sqrt(R123); - const vec3 Rs = pow2(T121) * R23 / (vec3(1.0f) - R123); - - // DC term. - vec3 C0 = R12 + Rs; - vec3 I = C0; - - // Higher-order terms. - vec3 Cm = Rs - T121; - for (int m = 1; m <= 2; ++m) { - Cm *= r123; - const vec3 Sm = 2.0f * evalSensitivity(float(m) * opd, float(m) * phi); - I += Cm * Sm; - } - - return glm::max(I, vec3(0.0f)); -} - //----------------------------------------------------------------------------- // Initialize shading state from material parameters //----------------------------------------------------------------------------- @@ -364,46 +188,6 @@ VISRTX_CALLABLE vec3 __direct_callable__evaluateNormal( // NEE shading: base (diffuse + GGX specular) + clearcoat + sheen //----------------------------------------------------------------------------- -VISRTX_DEVICE vec3 computeDielectricF0(const PhysicallyBasedShadingState *state) -{ - // KHR_materials_specular: `specular` scales the dielectric reflection, so the - // ANARI default specular = 0 yields a pure-diffuse dielectric (no Fresnel). - const float iorF0 = pow2((1.0f - state->eta) / (1.0f + state->eta)); - return glm::min(vec3(iorF0) * state->specularColor, vec3(1.0f)) - * state->specular; -} - -VISRTX_DEVICE vec3 computeF0(const PhysicallyBasedShadingState *state) -{ - return glm::mix( - computeDielectricF0(state), state->baseColor, state->metallic); -} - -VISRTX_DEVICE vec3 computeF90(const PhysicallyBasedShadingState *state) -{ - return glm::mix(vec3(state->specular), vec3(1.0f), state->metallic); -} - -VISRTX_DEVICE vec3 schlickFresnel(vec3 F0, vec3 F90, float VdotH) -{ - return F0 + (F90 - F0) * pow5(1.0f - fabsf(VdotH)); -} - -VISRTX_DEVICE vec3 evalFresnelWithIridescence( - const PhysicallyBasedShadingState *state, - const vec3 &F0, - const vec3 &F90, - float cosTheta) -{ - vec3 F = schlickFresnel(F0, F90, cosTheta); - if (state->iridescence > 0.0f && state->iridescenceThickness > 0.0f) { - const vec3 iridescent = evalIridescence( - 1.0f, state->iridescenceIor, cosTheta, state->iridescenceThickness, F0); - F = glm::mix(F, iridescent, state->iridescence); - } - return F; -} - VISRTX_CALLABLE vec3 __direct_callable__evalBsdf( const PhysicallyBasedShadingState *state, const vec3 *wo, const vec3 *wi) { @@ -495,93 +279,6 @@ VISRTX_CALLABLE vec3 __direct_callable__evalBsdf( return base * NdotL; } -//----------------------------------------------------------------------------- -// BSDF sampling pdf (solid angle), for environment MIS. This is the closed-form -// density of __direct_callable__nextRay's sampling strategy, evaluated for an -// arbitrary reflection-side direction. The sampler fills NextRay.pdf by calling -// this same function, so the NEE-side weight (materialEvalPdf) and the -// escape-side weight (NextRay.pdf) are identical functions and the balance- -// heuristic weights partition to 1 exactly (unbiased). -// -// Transmission (through-surface) directions return 0: NEE's evalBsdf -// early-outs at NdotL<=0, so they are never combined — the escape estimator -// owns them outright (NextRay.pdf = +inf at sample time). -//----------------------------------------------------------------------------- - -VISRTX_DEVICE float pbrBsdfPdf( - const PhysicallyBasedShadingState *state, const vec3 &V, const vec3 &L) -{ - const vec3 N = state->viewAdjustedNormal; - const float NdotV = dot(N, V); - const float NdotL = dot(N, L); - if (!(NdotV > 0.0f) || !(NdotL > 0.0f)) - return 0.0f; - - const vec3 F0 = computeF0(state); - const vec3 F90 = computeF90(state); - const vec3 Fv = evalFresnelWithIridescence(state, F0, F90, NdotV); - const vec3 transmissionFilter = computeTransmissionFilter(state); - - // V-only base split (diffuse vs specular) — mirrors the sampler exactly. - const float specSelW = fmaxf(luminance(Fv), 0.0f) - + fmaxf(luminance(glm::max(vec3(1.0f) - Fv, vec3(0.0f)) * transmissionFilter), - 0.0f); - const float diffSelW = fmaxf(luminance(glm::max(vec3(1.0f) - Fv, vec3(0.0f)) - * state->baseColor * (1.0f - state->metallic) - * (1.0f - state->transmission) * state->occlusion), - 0.0f); - const float baseSel = specSelW + diffSelW; - - float pdf = 0.0f; - if (baseSel > 0.0f) { - const float pSpec = specSelW / baseSel; - const float pDiff = diffSelW / baseSel; - - // Diffuse lobe: cosine-weighted around N. - pdf += pDiff * NdotL * kInvPi; - - // Specular reflection lobe: VNDF reflection density × reflect-given-spec. - const float alpha = fmaxf(pow2(state->roughness), 1e-4f); - const float alpha2 = alpha * alpha; - const vec3 H = normalize(V + L); - const float NdotH = fmaxf(dot(N, H), 0.0f); - const float VdotH = fmaxf(dot(V, H), 0.0f); - const vec3 Fh = evalFresnelWithIridescence(state, F0, F90, VdotH); - const vec3 Ltrans = glm::refract(-V, H, state->eta); - const bool tir = luminance(transmissionFilter) > 0.0f - && (glm::length(Ltrans) < 1e-6f || dot(Ltrans, N) >= 0.0f); - const float reflW = tir ? 1.0f : fmaxf(luminance(Fh), 0.0f); - const float transW = tir ? 0.0f - : fmaxf(luminance(glm::max(vec3(1.0f) - Fh, vec3(0.0f)) - * transmissionFilter), - 0.0f); - const float reflectGivenSpec = - (reflW + transW) > 0.0f ? reflW / (reflW + transW) : 1.0f; - const float pdfReflVndf = - ggxD(NdotH, alpha2) * smithG1GGX(NdotV, alpha2) / (4.0f * NdotV); - pdf += pSpec * reflectGivenSpec * pdfReflVndf; - } - - // Clearcoat is a top-level pick with probability ccProb; the base mixture - // above is reached with the complementary (1 - ccProb). - const vec3 Nc = state->viewAdjustedClearcoatNormal; - const float NcDotV = fmaxf(dot(Nc, V), 0.0f); - const float FcV = CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - NcDotV); - const float ccProb = glm::clamp(state->clearcoat * FcV, 0.0f, 1.0f); - pdf *= (1.0f - ccProb); - - if (ccProb > 0.0f && NcDotV > 0.0f && dot(Nc, L) > 0.0f) { - const vec3 Hc = normalize(V + L); - const float NcDotH = fmaxf(dot(Nc, Hc), 0.0f); - const float alphaC = fmaxf(pow2(state->clearcoatRoughness), 1e-4f); - const float alphaC2 = alphaC * alphaC; - pdf += ccProb * ggxD(NcDotH, alphaC2) * smithG1GGX(NcDotV, alphaC2) - / (4.0f * NcDotV); - } - - return pdf; -} - //----------------------------------------------------------------------------- // Next-ray importance sampling: stochastic alpha, Fresnel-aware lobe pick, // GGX VNDF reflection/refraction, plus a clearcoat lobe sampled with @@ -594,149 +291,12 @@ VISRTX_DEVICE float pbrBsdfPdf( //----------------------------------------------------------------------------- VISRTX_CALLABLE NextRay __direct_callable__nextRay( - const PhysicallyBasedShadingState *state, const Ray *ray, RandState *rs) + const PhysicallyBasedShadingState *state, + const Ray *ray, + RandState *rs, + const NextRayQmc *qmc) { - const vec3 V = -ray->dir; - - // Clearcoat lobe: pick it with probability `clearcoat·FcV(NcDotV)`. This - // exact weight makes the entry-side attenuation `1 - clearcoat·FcV` cancel - // the `1/(1-pick)` lobe-pick divisor in the base path below, so the base - // returns only need the exit-side `1 - clearcoat·FcL` multiplier. - const vec3 Nc = state->viewAdjustedClearcoatNormal; - const float NcDotV_world = fmaxf(dot(Nc, V), 0.0f); - const float FcV_world = - CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - NcDotV_world); - const float clearcoatPick = - glm::clamp(state->clearcoat * FcV_world, 0.0f, 1.0f); - - if (clearcoatPick > 0.0f && pcg_uniform(rs) < clearcoatPick) { - const mat3 toWorldC = computeOrthonormalBasis(Nc); - const vec3 VlocalC = glm::transpose(toWorldC) * V; - if (VlocalC.z <= 0.0f) - return NextRay{Nc, vec3(0.0f), 0.0f}; - const float alphaC = fmaxf(pow2(state->clearcoatRoughness), 1e-4f); - const float alphaC2 = alphaC * alphaC; - const vec3 HlocalC = - sampleGGXVNDF(VlocalC, alphaC, pcg_uniform(rs), pcg_uniform(rs)); - const vec3 LlocalC = glm::reflect(-VlocalC, HlocalC); - if (LlocalC.z <= 0.0f) - return NextRay{Nc, vec3(0.0f), 0.0f}; - const float VdotHc = fmaxf(dot(VlocalC, HlocalC), 0.0f); - const float Fc = CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - VdotHc); - const float G1c = smithG1GGX(VlocalC.z, alphaC2); - const float G2c = smithG2GGX(VlocalC.z, LlocalC.z, alphaC2); - // VNDF gives BRDF·cos/pdf = clearcoat·Fc·G2/G1; the clearcoat factor - // cancels against the matching factor in clearcoatPick. - const vec3 weight = vec3(state->clearcoat * Fc * G2c / fmaxf(G1c, 1e-8f)) - / fmaxf(clearcoatPick, 1e-8f); - const vec3 Lworld = normalize(toWorldC * LlocalC); - return NextRay{Lworld, weight, pbrBsdfPdf(state, V, Lworld)}; - } - - // Exit-side clearcoat attenuation, applied to every base-path return. - // `fabsf` handles the transmission case where L points through the surface. - auto clearcoatExitAttn = [&](const vec3 &Lworld) -> float { - if (state->clearcoat <= 0.0f) - return 1.0f; - const float NcDotL = fabsf(dot(Nc, Lworld)); - const float FcL = - CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - NcDotL); - return glm::clamp(1.0f - state->clearcoat * FcL, 0.0f, 1.0f); - }; - - const vec3 N = state->viewAdjustedNormal; - const mat3 toWorld = computeOrthonormalBasis(N); - const mat3 toLocal = glm::transpose(toWorld); - const vec3 Vlocal = toLocal * V; - if (Vlocal.z <= 0.0f) - return NextRay{N, vec3(0.0f), 0.0f}; - - const float alpha = fmaxf(pow2(state->roughness), 1e-4f); - const float alpha2 = alpha * alpha; - const float NdotV = Vlocal.z; - - // V-only base split (diffuse vs specular), deterministic in V so the sampling - // density is the closed form pbrBsdfPdf evaluates. Fresnel at NdotV (Fv) sets - // the split; the per-lobe throughput below uses the microfacet Fresnel. - const vec3 F0 = computeF0(state); - const vec3 F90 = computeF90(state); - const vec3 Fv = evalFresnelWithIridescence(state, F0, F90, NdotV); - const vec3 transmissionFilter = computeTransmissionFilter(state); - const bool hasTransmission = luminance(transmissionFilter) > 0.0f; - - const float specSelW = fmaxf(luminance(Fv), 0.0f) - + fmaxf(luminance(glm::max(vec3(1.0f) - Fv, vec3(0.0f)) * transmissionFilter), - 0.0f); - // Lambertian throughput collapses to this energy when sampled cosine-weighted - // (cos / pdf cancels with 1/pi); mirrors evalBsdf's diffuseBRDF factors. - const vec3 diffuseEnergy = glm::max(vec3(1.0f) - Fv, vec3(0.0f)) - * state->baseColor * (1.0f - state->metallic) - * (1.0f - state->transmission) * state->occlusion; - const float diffSelW = fmaxf(luminance(diffuseEnergy), 0.0f); - const float baseSel = specSelW + diffSelW; - if (baseSel <= 0.0f) - return NextRay{N, vec3(0.0f), 0.0f}; - const float pSpec = specSelW / baseSel; - const float pDiff = diffSelW / baseSel; - - // Diffuse lobe: sample around the shading normal so pdf=cos/pi matches the - // BRDF's NdotL (same axis as evalBsdf's diffuse term). - if (pcg_uniform(rs) >= pSpec) { - const vec3 wi = sampleHemisphere(*rs, N); - const vec3 weight = - diffuseEnergy * clearcoatExitAttn(wi) / fmaxf(pDiff, 1e-8f); - return NextRay{wi, weight, pbrBsdfPdf(state, V, wi)}; - } - - // Specular lobe: VNDF-sample the microfacet, then split reflect/transmit by - // the microfacet Fresnel F(VdotH). TIR (no valid refraction at this H) folds - // all energy into reflection, so reflect/transmit stays a clean binary split. - const vec3 Hlocal = - sampleGGXVNDF(Vlocal, alpha, pcg_uniform(rs), pcg_uniform(rs)); - const float VdotH = fmaxf(dot(Vlocal, Hlocal), 0.0f); - const vec3 Fh = evalFresnelWithIridescence(state, F0, F90, VdotH); - - const vec3 Lrefl = glm::reflect(-Vlocal, Hlocal); - const vec3 Ltrans = glm::refract(-Vlocal, Hlocal, state->eta); - const bool totalInternalReflection = - hasTransmission && (glm::length(Ltrans) < 1e-6f || Ltrans.z >= 0.0f); - - const vec3 reflectEnergy = totalInternalReflection ? vec3(1.0f) : Fh; - const vec3 transmitEnergy = totalInternalReflection - ? vec3(0.0f) - : glm::max(vec3(1.0f) - Fh, vec3(0.0f)) * transmissionFilter; - const float reflW = fmaxf(luminance(reflectEnergy), 0.0f); - const float transW = fmaxf(luminance(transmitEnergy), 0.0f); - const float specTotal = reflW + transW; - const float reflectGivenSpec = specTotal > 0.0f ? reflW / specTotal : 1.0f; - - if (pcg_uniform(rs) < reflectGivenSpec) { - if (Lrefl.z <= 0.0f) - return NextRay{N, vec3(0.0f), 0.0f}; - const float NdotL = Lrefl.z; - const float G1 = smithG1GGX(NdotV, alpha2); - const float G2 = smithG2GGX(NdotV, NdotL, alpha2); - const vec3 Lworld = normalize(toWorld * Lrefl); - // VNDF: BRDF·cos/pdf = energy·G2/G1. Divide by the full reflect selection - // prob pSpec·reflectGivenSpec; the (1-clearcoatPick) factor cancels against - // the clearcoat entry attenuation, leaving only the exit attenuation. - const vec3 weight = reflectEnergy * (G2 / fmaxf(G1, 1e-8f)) - * clearcoatExitAttn(Lworld) / fmaxf(pSpec * reflectGivenSpec, 1e-8f); - return NextRay{Lworld, weight, pbrBsdfPdf(state, V, Lworld)}; - } - - // Transmission lobe (through the surface). - const float NdotLt = -Ltrans.z; - const float G1t = smithG1GGX(NdotV, alpha2); - const float G2t = smithG2GGX(NdotV, NdotLt, alpha2); - const vec3 Ltworld = normalize(toWorld * Ltrans); - const vec3 weightT = transmitEnergy * (G2t / fmaxf(G1t, 1e-8f)) - * clearcoatExitAttn(Ltworld) / fmaxf(pSpec * (1.0f - reflectGivenSpec), 1e-8f); - // Through-surface escape: NEE's evalBsdf early-outs at NdotL<=0, so the - // env behind glass can only be reached by this continuation. Report +inf so - // env MIS gives it w_bsdf=1 (the escape owns it), matching the pre-MIS flag. - return NextRay{ - Ltworld, weightT, INFINITY, NEXT_RAY_CONTINUES_THROUGH_SURFACE}; + return samplePhysicallyBased(state, -ray->dir, rs, qmc); } //----------------------------------------------------------------------------- diff --git a/devices/rtx/device/material/shaders/physicallyBasedSampling.h b/devices/rtx/device/material/shaders/physicallyBasedSampling.h new file mode 100644 index 000000000..9592be312 --- /dev/null +++ b/devices/rtx/device/material/shaders/physicallyBasedSampling.h @@ -0,0 +1,512 @@ +/* + * Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "gpu/samplingMath.h" +#include "gpu/shadingState.h" + +#include + +namespace visrtx { +namespace detail { + +// Clearcoat is fixed to IOR 1.5 per glTF KHR_materials_clearcoat (F0 = 0.04). +constexpr float CLEARCOAT_F0 = 0.04f; + +VISRTX_DEVICE vec3 computeVolumeTransmission( + const PhysicallyBasedShadingState *state) +{ + if (!(state->thickness > 0.0f && state->attenuationDistance > 0.0f + && isfinite(state->attenuationDistance))) + return vec3(1.0f); + + const float k = state->thickness / state->attenuationDistance; + return vec3(powf(fmaxf(state->attenuationColor.x, 1e-6f), k), + powf(fmaxf(state->attenuationColor.y, 1e-6f), k), + powf(fmaxf(state->attenuationColor.z, 1e-6f), k)); +} + +VISRTX_DEVICE vec3 computeTransmissionFilter( + const PhysicallyBasedShadingState *state) +{ + const float transmission = + fmaxf(0.0f, (1.0f - state->metallic) * state->transmission); + return state->baseColor * transmission * computeVolumeTransmission(state); +} + +// Smith Lambda for GGX (common subterm of G1 / G2). +VISRTX_DEVICE float smithLambdaGGX(float NdotX, float alpha2) +{ + const float NdotX2 = NdotX * NdotX; + const float safe = fmaxf(NdotX2, 1e-8f); + return 0.5f + * (-1.0f + sqrtf(fmaxf(0.0f, 1.0f + alpha2 * (1.0f - safe) / safe))); +} + +VISRTX_DEVICE float smithG2GGX(float NdotV, float NdotL, float alpha2) +{ + return 1.0f + / (1.0f + smithLambdaGGX(NdotV, alpha2) + smithLambdaGGX(NdotL, alpha2)); +} + +VISRTX_DEVICE float smithG1GGX(float NdotV, float alpha2) +{ + return 1.0f / (1.0f + smithLambdaGGX(NdotV, alpha2)); +} + +VISRTX_DEVICE float ggxD(float NdotH, float alpha2) +{ + // The textbook denom `x·(α²−1) + 1` cancels catastrophically in fp32 once + // α² is below eps(1) ≈ 1.19e-7 (our α² floor is 1e-8): `α²−1` rounds to + // exactly −1, and at x=1 the whole denom collapses to 0. The algebraically + // equivalent `α²·x + (1−x)` has no near-1 subtraction so it stays exact. + // The fminf clamp keeps `1−x ≥ 0` against dot-product rounding above 1. + const float NdotH2 = fminf(NdotH * NdotH, 1.0f); + const float denom = alpha2 * NdotH2 + (1.0f - NdotH2); + return alpha2 / (kPi * denom * denom); +} + +// Heitz 2018 (https://jcgt.org/published/0007/04/01/) visible-normal sampling +// for GGX. Ve is the view direction in local tangent space (+z = normal). +VISRTX_DEVICE vec3 sampleGGXVNDF( + const vec3 &Ve, float alpha, float u1, float u2) +{ + const vec3 Vh = normalize(vec3(alpha * Ve.x, alpha * Ve.y, Ve.z)); + const float lensq = Vh.x * Vh.x + Vh.y * Vh.y; + const vec3 T1 = lensq > 0.0f ? vec3(-Vh.y, Vh.x, 0.0f) * (1.0f / sqrtf(lensq)) + : vec3(1.0f, 0.0f, 0.0f); + const vec3 T2 = glm::cross(Vh, T1); + const float r = sqrtf(u1); + const float phi = kTwoPi * u2; + const float t1 = r * cosf(phi); + float t2 = r * sinf(phi); + const float s = 0.5f * (1.0f + Vh.z); + t2 = (1.0f - s) * sqrtf(fmaxf(0.0f, 1.0f - t1 * t1)) + s * t2; + const vec3 Nh = + t1 * T1 + t2 * T2 + sqrtf(fmaxf(0.0f, 1.0f - t1 * t1 - t2 * t2)) * Vh; + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, fmaxf(0.0f, Nh.z))); +} + +// glTF KHR_materials_iridescence thin-film Fresnel (port of the reference +// implementation at github.com/KhronosGroup/glTF-Sample-Renderer). Returns a +// per-channel Fresnel reflectance for a thin film of thickness T sitting on a +// base with Schlick F0. See the spec's Appendix B for the math. +VISRTX_DEVICE vec3 fresnel0ToIor(vec3 F0) +{ + const vec3 s = glm::sqrt(glm::clamp(F0, vec3(0.0f), vec3(0.9999f))); + return (vec3(1.0f) + s) / (vec3(1.0f) - s); +} + +VISRTX_DEVICE vec3 iorToFresnel0(vec3 transmittedIor, float incidentIor) +{ + const vec3 t = (transmittedIor - vec3(incidentIor)) + / (transmittedIor + vec3(incidentIor)); + return t * t; +} + +VISRTX_DEVICE float iorToFresnel0(float transmittedIor, float incidentIor) +{ + const float t = + (transmittedIor - incidentIor) / (transmittedIor + incidentIor); + return t * t; +} + +VISRTX_DEVICE vec3 evalSensitivity(float opd, vec3 shift) +{ + // Approximate spectral sensitivity of the standard observer as three + // Gaussians (Belcour & Barla 2017, simplified) so the result stays in RGB. + const float phase = kTwoPi * opd * 1e-9f; + const vec3 val = vec3(5.4856e-13f, 4.4201e-13f, 5.2481e-13f); + const vec3 pos = vec3(1.6810e+06f, 1.7953e+06f, 2.2084e+06f); + const vec3 var = vec3(4.3278e+09f, 9.3046e+09f, 6.6121e+09f); + + vec3 xyz = val * glm::sqrt(kTwoPi * var) * glm::cos(pos * phase + shift) + * glm::exp(-var * phase * phase); + xyz.x += 9.7470e-14f * sqrtf(kTwoPi * 4.5282e+09f) + * cosf(2.2399e+06f * phase + shift.x) + * expf(-4.5282e+09f * phase * phase); + xyz /= 1.0685e-7f; + + // sRGB conversion (D65). + return vec3(3.2404542f * xyz.x - 1.5371385f * xyz.y - 0.4985314f * xyz.z, + -0.9692660f * xyz.x + 1.8760108f * xyz.y + 0.0415560f * xyz.z, + 0.0556434f * xyz.x - 0.2040259f * xyz.y + 1.0572252f * xyz.z); +} + +VISRTX_DEVICE vec3 evalIridescence(float outsideIor, + float iridescenceIor, + float cosTheta1, + float thickness, + vec3 baseF0) +{ + // Handle the case where thin-film IOR is close to the outside IOR: return + // the base Fresnel to avoid division by zero and phase artifacts. + const float iridescenceIorSafe = fmaxf(iridescenceIor, outsideIor + 1e-4f); + + // Force iridescenceIor > outsideIor (otherwise Snell's law cannot refract). + const float sinTheta2Sq = + pow2(outsideIor / iridescenceIorSafe) * (1.0f - cosTheta1 * cosTheta1); + const float cosTheta2Sq = 1.0f - sinTheta2Sq; + if (cosTheta2Sq < 0.0f) + return vec3(1.0f); // Total internal reflection. + const float cosTheta2 = sqrtf(cosTheta2Sq); + + // First interface: Fresnel between outside and thin film. + const float R0_12 = iorToFresnel0(iridescenceIorSafe, outsideIor); + const float R12 = R0_12 + (1.0f - R0_12) * pow5(1.0f - cosTheta1); + const float T121 = 1.0f - R12; + const float phi12 = iridescenceIorSafe < outsideIor ? kPi : 0.0f; + const float phi21 = kPi - phi12; + + // Second interface: film to base. + const vec3 baseIor = + fresnel0ToIor(glm::clamp(baseF0, vec3(0.f), vec3(0.9999f))); + const vec3 R1 = iorToFresnel0(baseIor, iridescenceIorSafe); + const vec3 R23 = R1 + (vec3(1.0f) - R1) * pow5(1.0f - cosTheta2); + const vec3 phi23 = vec3(baseIor.x < iridescenceIorSafe ? kPi : 0.0f, + baseIor.y < iridescenceIorSafe ? kPi : 0.0f, + baseIor.z < iridescenceIorSafe ? kPi : 0.0f); + + const float opd = 2.0f * iridescenceIorSafe * thickness * cosTheta2; + const vec3 phi = vec3(phi21) + phi23; + + const vec3 R123 = glm::clamp(R12 * R23, vec3(1e-5f), vec3(0.9999f)); + const vec3 r123 = glm::sqrt(R123); + const vec3 Rs = pow2(T121) * R23 / (vec3(1.0f) - R123); + + // DC term. + vec3 C0 = R12 + Rs; + vec3 I = C0; + + // Higher-order terms. + vec3 Cm = Rs - T121; + for (int m = 1; m <= 2; ++m) { + Cm *= r123; + const vec3 Sm = 2.0f * evalSensitivity(float(m) * opd, float(m) * phi); + I += Cm * Sm; + } + + return glm::max(I, vec3(0.0f)); +} + +VISRTX_DEVICE vec3 computeDielectricF0(const PhysicallyBasedShadingState *state) +{ + // KHR_materials_specular: `specular` scales the dielectric reflection, so the + // ANARI default specular = 0 yields a pure-diffuse dielectric (no Fresnel). + const float iorF0 = pow2((1.0f - state->eta) / (1.0f + state->eta)); + return glm::min(vec3(iorF0) * state->specularColor, vec3(1.0f)) + * state->specular; +} + +VISRTX_DEVICE vec3 computeF0(const PhysicallyBasedShadingState *state) +{ + return glm::mix( + computeDielectricF0(state), state->baseColor, state->metallic); +} + +VISRTX_DEVICE vec3 computeF90(const PhysicallyBasedShadingState *state) +{ + return glm::mix(vec3(state->specular), vec3(1.0f), state->metallic); +} + +VISRTX_DEVICE vec3 schlickFresnel(vec3 F0, vec3 F90, float VdotH) +{ + return F0 + (F90 - F0) * pow5(1.0f - fabsf(VdotH)); +} + +VISRTX_DEVICE vec3 evalFresnelWithIridescence( + const PhysicallyBasedShadingState *state, + const vec3 &F0, + const vec3 &F90, + float cosTheta) +{ + vec3 F = schlickFresnel(F0, F90, cosTheta); + if (state->iridescence > 0.0f && state->iridescenceThickness > 0.0f) { + const vec3 iridescent = evalIridescence( + 1.0f, state->iridescenceIor, cosTheta, state->iridescenceThickness, F0); + F = glm::mix(F, iridescent, state->iridescence); + } + return F; +} + +//----------------------------------------------------------------------------- +// BSDF sampling pdf (solid angle), for environment MIS. This is the closed-form +// density of __direct_callable__nextRay's sampling strategy, evaluated for an +// arbitrary reflection-side direction. The sampler fills NextRay.pdf by calling +// this same function, so the NEE-side weight (materialEvalPdf) and the +// escape-side weight (NextRay.pdf) are identical functions and the balance- +// heuristic weights partition to 1 exactly (unbiased). +// +// Transmission (through-surface) directions return 0: NEE's evalBsdf +// early-outs at NdotL<=0, so they are never combined — the escape estimator +// owns them outright (NextRay.pdf = +inf at sample time). +//----------------------------------------------------------------------------- + +VISRTX_DEVICE float pbrBsdfPdf( + const PhysicallyBasedShadingState *state, const vec3 &V, const vec3 &L) +{ + const vec3 N = state->viewAdjustedNormal; + const float NdotV = dot(N, V); + const float NdotL = dot(N, L); + if (!(NdotV > 0.0f) || !(NdotL > 0.0f)) + return 0.0f; + + const vec3 F0 = computeF0(state); + const vec3 F90 = computeF90(state); + const vec3 Fv = evalFresnelWithIridescence(state, F0, F90, NdotV); + const vec3 transmissionFilter = computeTransmissionFilter(state); + + // V-only base split (diffuse vs specular) — mirrors the sampler exactly. + const float specSelW = fmaxf(luminance(Fv), 0.0f) + + fmaxf( + luminance(glm::max(vec3(1.0f) - Fv, vec3(0.0f)) * transmissionFilter), + 0.0f); + const float diffSelW = + fmaxf(luminance(glm::max(vec3(1.0f) - Fv, vec3(0.0f)) * state->baseColor + * (1.0f - state->metallic) * (1.0f - state->transmission) + * state->occlusion), + 0.0f); + const float baseSel = specSelW + diffSelW; + + float pdf = 0.0f; + if (baseSel > 0.0f) { + const float pSpec = specSelW / baseSel; + const float pDiff = diffSelW / baseSel; + + // Diffuse lobe: cosine-weighted around N. + pdf += pDiff * NdotL * kInvPi; + + // Specular reflection lobe: VNDF reflection density × reflect-given-spec. + const float alpha = fmaxf(pow2(state->roughness), 1e-4f); + const float alpha2 = alpha * alpha; + const vec3 H = normalize(V + L); + const float NdotH = fmaxf(dot(N, H), 0.0f); + const float VdotH = fmaxf(dot(V, H), 0.0f); + const vec3 Fh = evalFresnelWithIridescence(state, F0, F90, VdotH); + const vec3 Ltrans = glm::refract(-V, H, state->eta); + const bool tir = luminance(transmissionFilter) > 0.0f + && (glm::length(Ltrans) < 1e-6f || dot(Ltrans, N) >= 0.0f); + const float reflW = tir ? 1.0f : fmaxf(luminance(Fh), 0.0f); + const float transW = tir + ? 0.0f + : fmaxf(luminance( + glm::max(vec3(1.0f) - Fh, vec3(0.0f)) * transmissionFilter), + 0.0f); + const float reflectGivenSpec = + (reflW + transW) > 0.0f ? reflW / (reflW + transW) : 1.0f; + const float pdfReflVndf = + ggxD(NdotH, alpha2) * smithG1GGX(NdotV, alpha2) / (4.0f * NdotV); + pdf += pSpec * reflectGivenSpec * pdfReflVndf; + } + + // Clearcoat is a top-level pick with probability ccProb; the base mixture + // above is reached with the complementary (1 - ccProb). + const vec3 Nc = state->viewAdjustedClearcoatNormal; + const float NcDotV = fmaxf(dot(Nc, V), 0.0f); + const float FcV = CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - NcDotV); + const float ccProb = glm::clamp(state->clearcoat * FcV, 0.0f, 1.0f); + pdf *= (1.0f - ccProb); + + if (ccProb > 0.0f && NcDotV > 0.0f && dot(Nc, L) > 0.0f) { + const vec3 Hc = normalize(V + L); + const float NcDotH = fmaxf(dot(Nc, Hc), 0.0f); + const float alphaC = fmaxf(pow2(state->clearcoatRoughness), 1e-4f); + const float alphaC2 = alphaC * alphaC; + pdf += ccProb * ggxD(NcDotH, alphaC2) * smithG1GGX(NcDotV, alphaC2) + / (4.0f * NcDotV); + } + + return pdf; +} + +} // namespace detail + +// Shared continuation implementation. Callables supply the outgoing direction; +// tests call this same seam. Keep branch-local draws and early exits together. +VISRTX_DEVICE NextRay samplePhysicallyBased( + const PhysicallyBasedShadingState *state, + const vec3 &V, + RandState *rs, + const NextRayQmc *qmc) +{ + using namespace detail; + int qmcCursor = 0; + auto u = [&]() { return nextRayUniform(rs, qmc, qmcCursor); }; + + // Clearcoat lobe: pick it with probability `clearcoat·FcV(NcDotV)`. This + // exact weight makes the entry-side attenuation `1 - clearcoat·FcV` cancel + // the `1/(1-pick)` lobe-pick divisor in the base path below, so the base + // returns only need the exit-side `1 - clearcoat·FcL` multiplier. + const vec3 Nc = state->viewAdjustedClearcoatNormal; + const float NcDotV_world = fmaxf(dot(Nc, V), 0.0f); + const float FcV_world = + CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - NcDotV_world); + const float clearcoatPick = + glm::clamp(state->clearcoat * FcV_world, 0.0f, 1.0f); + + if (clearcoatPick > 0.0f && u() < clearcoatPick) { + const mat3 toWorldC = computeOrthonormalBasis(Nc); + const vec3 VlocalC = glm::transpose(toWorldC) * V; + if (VlocalC.z <= 0.0f) + return NextRay{Nc, vec3(0.0f), 0.0f}; + const float alphaC = fmaxf(pow2(state->clearcoatRoughness), 1e-4f); + const float alphaC2 = alphaC * alphaC; + const float coatU = u(); + const float coatV = u(); + const vec3 HlocalC = sampleGGXVNDF(VlocalC, alphaC, coatU, coatV); + const vec3 LlocalC = glm::reflect(-VlocalC, HlocalC); + if (LlocalC.z <= 0.0f) + return NextRay{Nc, vec3(0.0f), 0.0f}; + const float VdotHc = fmaxf(dot(VlocalC, HlocalC), 0.0f); + const float Fc = CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - VdotHc); + const float G1c = smithG1GGX(VlocalC.z, alphaC2); + const float G2c = smithG2GGX(VlocalC.z, LlocalC.z, alphaC2); + // VNDF gives BRDF·cos/pdf = clearcoat·Fc·G2/G1; the clearcoat factor + // cancels against the matching factor in clearcoatPick. + const vec3 weight = vec3(state->clearcoat * Fc * G2c / fmaxf(G1c, 1e-8f)) + / fmaxf(clearcoatPick, 1e-8f); + const vec3 Lworld = normalize(toWorldC * LlocalC); + return NextRay{Lworld, weight, pbrBsdfPdf(state, V, Lworld)}; + } + + // Exit-side clearcoat attenuation, applied to every base-path return. + // `fabsf` handles the transmission case where L points through the surface. + auto clearcoatExitAttn = [&](const vec3 &Lworld) -> float { + if (state->clearcoat <= 0.0f) + return 1.0f; + const float NcDotL = fabsf(dot(Nc, Lworld)); + const float FcL = + CLEARCOAT_F0 + (1.0f - CLEARCOAT_F0) * pow5(1.0f - NcDotL); + return glm::clamp(1.0f - state->clearcoat * FcL, 0.0f, 1.0f); + }; + + const vec3 N = state->viewAdjustedNormal; + const mat3 toWorld = computeOrthonormalBasis(N); + const mat3 toLocal = glm::transpose(toWorld); + const vec3 Vlocal = toLocal * V; + if (Vlocal.z <= 0.0f) + return NextRay{N, vec3(0.0f), 0.0f}; + + const float alpha = fmaxf(pow2(state->roughness), 1e-4f); + const float alpha2 = alpha * alpha; + const float NdotV = Vlocal.z; + + // V-only base split (diffuse vs specular), deterministic in V so the sampling + // density is the closed form pbrBsdfPdf evaluates. Fresnel at NdotV (Fv) sets + // the split; the per-lobe throughput below uses the microfacet Fresnel. + const vec3 F0 = computeF0(state); + const vec3 F90 = computeF90(state); + const vec3 Fv = evalFresnelWithIridescence(state, F0, F90, NdotV); + const vec3 transmissionFilter = computeTransmissionFilter(state); + const bool hasTransmission = luminance(transmissionFilter) > 0.0f; + + const float specSelW = fmaxf(luminance(Fv), 0.0f) + + fmaxf( + luminance(glm::max(vec3(1.0f) - Fv, vec3(0.0f)) * transmissionFilter), + 0.0f); + // Lambertian throughput collapses to this energy when sampled cosine-weighted + // (cos / pdf cancels with 1/pi); mirrors evalBsdf's diffuseBRDF factors. + const vec3 diffuseEnergy = glm::max(vec3(1.0f) - Fv, vec3(0.0f)) + * state->baseColor * (1.0f - state->metallic) + * (1.0f - state->transmission) * state->occlusion; + const float diffSelW = fmaxf(luminance(diffuseEnergy), 0.0f); + const float baseSel = specSelW + diffSelW; + if (baseSel <= 0.0f) + return NextRay{N, vec3(0.0f), 0.0f}; + const float pSpec = specSelW / baseSel; + const float pDiff = diffSelW / baseSel; + + // Diffuse lobe: sample around the shading normal so pdf=cos/pi matches the + // BRDF's NdotL (same axis as evalBsdf's diffuse term). + if (u() >= pSpec) { + const float diffuseU = u(); + const float diffuseV = u(); + const vec3 wi = sampleHemisphere(diffuseU, diffuseV, N); + const vec3 weight = + diffuseEnergy * clearcoatExitAttn(wi) / fmaxf(pDiff, 1e-8f); + return NextRay{wi, weight, pbrBsdfPdf(state, V, wi)}; + } + + // Specular lobe: VNDF-sample the microfacet, then split reflect/transmit by + // the microfacet Fresnel F(VdotH). TIR (no valid refraction at this H) folds + // all energy into reflection, so reflect/transmit stays a clean binary split. + const float specularU = u(); + const float specularV = u(); + const vec3 Hlocal = sampleGGXVNDF(Vlocal, alpha, specularU, specularV); + const float VdotH = fmaxf(dot(Vlocal, Hlocal), 0.0f); + const vec3 Fh = evalFresnelWithIridescence(state, F0, F90, VdotH); + + const vec3 Lrefl = glm::reflect(-Vlocal, Hlocal); + const vec3 Ltrans = glm::refract(-Vlocal, Hlocal, state->eta); + const bool totalInternalReflection = + hasTransmission && (glm::length(Ltrans) < 1e-6f || Ltrans.z >= 0.0f); + + const vec3 reflectEnergy = totalInternalReflection ? vec3(1.0f) : Fh; + const vec3 transmitEnergy = totalInternalReflection + ? vec3(0.0f) + : glm::max(vec3(1.0f) - Fh, vec3(0.0f)) * transmissionFilter; + const float reflW = fmaxf(luminance(reflectEnergy), 0.0f); + const float transW = fmaxf(luminance(transmitEnergy), 0.0f); + const float specTotal = reflW + transW; + const float reflectGivenSpec = specTotal > 0.0f ? reflW / specTotal : 1.0f; + + if (u() < reflectGivenSpec) { + if (Lrefl.z <= 0.0f) + return NextRay{N, vec3(0.0f), 0.0f}; + const float NdotL = Lrefl.z; + const float G1 = smithG1GGX(NdotV, alpha2); + const float G2 = smithG2GGX(NdotV, NdotL, alpha2); + const vec3 Lworld = normalize(toWorld * Lrefl); + // VNDF: BRDF·cos/pdf = energy·G2/G1. Divide by the full reflect selection + // prob pSpec·reflectGivenSpec; the (1-clearcoatPick) factor cancels against + // the clearcoat entry attenuation, leaving only the exit attenuation. + const vec3 weight = reflectEnergy * (G2 / fmaxf(G1, 1e-8f)) + * clearcoatExitAttn(Lworld) / fmaxf(pSpec * reflectGivenSpec, 1e-8f); + return NextRay{Lworld, weight, pbrBsdfPdf(state, V, Lworld)}; + } + + // Transmission lobe (through the surface). + const float NdotLt = -Ltrans.z; + const float G1t = smithG1GGX(NdotV, alpha2); + const float G2t = smithG2GGX(NdotV, NdotLt, alpha2); + const vec3 Ltworld = normalize(toWorld * Ltrans); + const vec3 weightT = transmitEnergy * (G2t / fmaxf(G1t, 1e-8f)) + * clearcoatExitAttn(Ltworld) + / fmaxf(pSpec * (1.0f - reflectGivenSpec), 1e-8f); + // Through-surface escape: NEE's evalBsdf early-outs at NdotL<=0, so the + // env behind glass can only be reached by this continuation. Report +inf so + // env MIS gives it w_bsdf=1 (the escape owns it), matching the pre-MIS flag. + return NextRay{ + Ltworld, weightT, INFINITY, NEXT_RAY_CONTINUES_THROUGH_SURFACE}; +} + +} // namespace visrtx diff --git a/devices/rtx/device/renderer/Quality_ptx.cu b/devices/rtx/device/renderer/Quality_ptx.cu index 665b02d93..c072b642f 100644 --- a/devices/rtx/device/renderer/Quality_ptx.cu +++ b/devices/rtx/device/renderer/Quality_ptx.cu @@ -1051,7 +1051,12 @@ VISRTX_GLOBAL void __raygen__() // accepted surface. Subsequent transport must not apply another fog // operation, even if it crosses more coverage layers. appearanceWeight = surfaceAppearanceWeight; - auto nextRay = materialNextRay(shadingState, ray, ss.rs); + NextRayQmc nextQmc{}; + nextQmc.n = 4; + for (int d = 0; d < 4; ++d) + nextQmc.u[d] = + owenSobol(sampleIdx, kSobolDimNextRay0 + uint32_t(d), qmcSeed); + auto nextRay = materialNextRay(shadingState, ray, ss.rs, &nextQmc); sampleContribution *= nextRay.contributionWeight; // Carry the bounce's solid-angle pdf for the env-MIS weight at a miss. From 33910872249d24223f2ba952f595751561a95e97 Mon Sep 17 00:00:00 2001 From: Thomas Arcila <134677+tarcila@users.noreply.github.com> Date: Tue, 10 Nov 2026 02:13:19 +0000 Subject: [PATCH 5/6] feat(rtx): add internal scramble seed Allow reproducible transport scrambles without changing renderer defaults or coupling the transport key to Halton camera addressing. --- devices/rtx/apps/tests/unit/CMakeLists.txt | 3 +- .../apps/tests/unit/sobol/seed-vectors.txt | 770 ++++++++++++++++++ .../apps/tests/unit/sobol/seed_reference.py | 63 ++ devices/rtx/apps/tests/unit/sobol/testSobol.h | 73 +- devices/rtx/device/gpu/owenSobol.h | 21 +- 5 files changed, 924 insertions(+), 6 deletions(-) create mode 100644 devices/rtx/apps/tests/unit/sobol/seed-vectors.txt create mode 100644 devices/rtx/apps/tests/unit/sobol/seed_reference.py diff --git a/devices/rtx/apps/tests/unit/CMakeLists.txt b/devices/rtx/apps/tests/unit/CMakeLists.txt index 7a99fdf28..405713910 100644 --- a/devices/rtx/apps/tests/unit/CMakeLists.txt +++ b/devices/rtx/apps/tests/unit/CMakeLists.txt @@ -151,7 +151,8 @@ foreach(sobol_target rtx_test_Sobol rtx_test_SobolCUDA) CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON) target_compile_definitions(${sobol_target} PRIVATE SOBOL_PARAMETER_FILE="${CMAKE_CURRENT_LIST_DIR}/sobol/joe-kuo.txt" - SOBOL_VECTOR_FILE="${CMAKE_CURRENT_LIST_DIR}/sobol/vectors.txt") + SOBOL_VECTOR_FILE="${CMAKE_CURRENT_LIST_DIR}/sobol/vectors.txt" + SOBOL_SEED_VECTOR_FILE="${CMAKE_CURRENT_LIST_DIR}/sobol/seed-vectors.txt") endforeach() # Match the RTX PTX's arithmetic configuration. target_compile_options(rtx_test_SobolCUDA PRIVATE diff --git a/devices/rtx/apps/tests/unit/sobol/seed-vectors.txt b/devices/rtx/apps/tests/unit/sobol/seed-vectors.txt new file mode 100644 index 000000000..8acaa6b95 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/seed-vectors.txt @@ -0,0 +1,770 @@ +# Offline Joe-Kuo / pinned pbrt FastOwen vectors; see README.md. +# x y scrambleSeed bounce transparency index dimension pixelKey vertexKey grid24 +00000001 00000002 00000000 00000000 00000000 00000000 00000000 339b28e2 339b28e2 00874f8b +00000001 00000002 00000000 00000000 00000000 00000000 00000001 339b28e2 339b28e2 000fcdfd +00000001 00000002 00000000 00000000 00000000 00000000 00000002 339b28e2 339b28e2 00e2e9bd +00000001 00000002 00000000 00000000 00000000 00000000 00000003 339b28e2 339b28e2 0075a683 +00000001 00000002 00000000 00000000 00000000 00000000 00000004 339b28e2 339b28e2 00dd00eb +00000001 00000002 00000000 00000000 00000000 00000000 00000005 339b28e2 339b28e2 002f37bc +00000001 00000002 00000000 00000000 00000000 00000000 00000006 339b28e2 339b28e2 00ac04aa +00000001 00000002 00000000 00000000 00000000 00000000 00000007 339b28e2 339b28e2 0077a326 +00000001 00000002 00000000 00000000 00000000 00000000 00000008 339b28e2 339b28e2 00b01aa1 +00000001 00000002 00000000 00000000 00000000 00000000 00000009 339b28e2 339b28e2 0017b72b +00000001 00000002 00000000 00000000 00000000 00000000 0000000a 339b28e2 339b28e2 00ca4766 +00000001 00000002 00000000 00000000 00000000 00000000 0000000b 339b28e2 339b28e2 00767df7 +00000001 00000002 00000000 00000000 00000000 00000000 0000000c 339b28e2 339b28e2 00fde7ae +00000001 00000002 00000000 00000000 00000000 00000000 0000000d 339b28e2 339b28e2 003ecc54 +00000001 00000002 00000000 00000000 00000000 00000000 0000000e 339b28e2 339b28e2 009fac0a +00000001 00000002 00000000 00000000 00000000 00000000 0000000f 339b28e2 339b28e2 0072bd0e +00000001 00000002 00000000 00000000 00000000 00000010 00000000 339b28e2 339b28e2 008a9d88 +00000001 00000002 00000000 00000000 00000000 00000010 00000001 339b28e2 339b28e2 00971902 +00000001 00000002 00000000 00000000 00000000 00000010 00000002 339b28e2 339b28e2 0061a8f9 +00000001 00000002 00000000 00000000 00000000 00000010 00000003 339b28e2 339b28e2 00cfbe18 +00000001 00000002 00000000 00000000 00000000 00000010 00000004 339b28e2 339b28e2 00139d57 +00000001 00000002 00000000 00000000 00000000 00000010 00000005 339b28e2 339b28e2 009ea86a +00000001 00000002 00000000 00000000 00000000 00000010 00000006 339b28e2 339b28e2 00e83b3f +00000001 00000002 00000000 00000000 00000000 00000010 00000007 339b28e2 339b28e2 00e3c831 +00000001 00000002 00000000 00000000 00000000 00000010 00000008 339b28e2 339b28e2 009f67ec +00000001 00000002 00000000 00000000 00000000 00000010 00000009 339b28e2 339b28e2 00b9a097 +00000001 00000002 00000000 00000000 00000000 00000010 0000000a 339b28e2 339b28e2 00c15282 +00000001 00000002 00000000 00000000 00000000 00000010 0000000b 339b28e2 339b28e2 0034c23f +00000001 00000002 00000000 00000000 00000000 00000010 0000000c 339b28e2 339b28e2 0008457b +00000001 00000002 00000000 00000000 00000000 00000010 0000000d 339b28e2 339b28e2 000132dd +00000001 00000002 00000000 00000000 00000000 00000010 0000000e 339b28e2 339b28e2 003e24af +00000001 00000002 00000000 00000000 00000000 00000010 0000000f 339b28e2 339b28e2 00b1ef1b +00000001 00000002 00000000 00000000 00000000 ffffffff 00000000 339b28e2 339b28e2 003dad69 +00000001 00000002 00000000 00000000 00000000 ffffffff 00000001 339b28e2 339b28e2 000fcdfd +00000001 00000002 00000000 00000000 00000000 ffffffff 00000002 339b28e2 339b28e2 00aa08c0 +00000001 00000002 00000000 00000000 00000000 ffffffff 00000003 339b28e2 339b28e2 005c173d +00000001 00000002 00000000 00000000 00000000 ffffffff 00000004 339b28e2 339b28e2 00a10c10 +00000001 00000002 00000000 00000000 00000000 ffffffff 00000005 339b28e2 339b28e2 0095bc03 +00000001 00000002 00000000 00000000 00000000 ffffffff 00000006 339b28e2 339b28e2 00f16f13 +00000001 00000002 00000000 00000000 00000000 ffffffff 00000007 339b28e2 339b28e2 00ebaf82 +00000001 00000002 00000000 00000000 00000000 ffffffff 00000008 339b28e2 339b28e2 00446a8c +00000001 00000002 00000000 00000000 00000000 ffffffff 00000009 339b28e2 339b28e2 00a9bf28 +00000001 00000002 00000000 00000000 00000000 ffffffff 0000000a 339b28e2 339b28e2 002074a9 +00000001 00000002 00000000 00000000 00000000 ffffffff 0000000b 339b28e2 339b28e2 00bfd17a +00000001 00000002 00000000 00000000 00000000 ffffffff 0000000c 339b28e2 339b28e2 005147aa +00000001 00000002 00000000 00000000 00000000 ffffffff 0000000d 339b28e2 339b28e2 009cead3 +00000001 00000002 00000000 00000000 00000000 ffffffff 0000000e 339b28e2 339b28e2 00bc8a05 +00000001 00000002 00000000 00000000 00000000 ffffffff 0000000f 339b28e2 339b28e2 00069e9c +00000001 00000002 00000000 00000001 00000000 00000000 00000000 339b28e2 adac515b 005d430e +00000001 00000002 00000000 00000001 00000000 00000000 00000001 339b28e2 adac515b 00b7402b +00000001 00000002 00000000 00000001 00000000 00000000 00000002 339b28e2 adac515b 000fdcb4 +00000001 00000002 00000000 00000001 00000000 00000000 00000003 339b28e2 adac515b 008c08f4 +00000001 00000002 00000000 00000001 00000000 00000000 00000004 339b28e2 adac515b 005fdc1b +00000001 00000002 00000000 00000001 00000000 00000000 00000005 339b28e2 adac515b 00f821fc +00000001 00000002 00000000 00000001 00000000 00000000 00000006 339b28e2 adac515b 003c6127 +00000001 00000002 00000000 00000001 00000000 00000000 00000007 339b28e2 adac515b 00ef36f0 +00000001 00000002 00000000 00000001 00000000 00000000 00000008 339b28e2 adac515b 00573706 +00000001 00000002 00000000 00000001 00000000 00000000 00000009 339b28e2 adac515b 009710cd +00000001 00000002 00000000 00000001 00000000 00000000 0000000a 339b28e2 adac515b 00161e74 +00000001 00000002 00000000 00000001 00000000 00000000 0000000b 339b28e2 adac515b 00a0f5ef +00000001 00000002 00000000 00000001 00000000 00000000 0000000c 339b28e2 adac515b 0050ba69 +00000001 00000002 00000000 00000001 00000000 00000000 0000000d 339b28e2 adac515b 00c37852 +00000001 00000002 00000000 00000001 00000000 00000000 0000000e 339b28e2 adac515b 002507f2 +00000001 00000002 00000000 00000001 00000000 00000000 0000000f 339b28e2 adac515b 00cc1e98 +00000001 00000002 00000000 00000001 00000000 00000010 00000000 339b28e2 adac515b 00567751 +00000001 00000002 00000000 00000001 00000000 00000010 00000001 339b28e2 adac515b 002a22ee +00000001 00000002 00000000 00000001 00000000 00000010 00000002 339b28e2 adac515b 00be2381 +00000001 00000002 00000000 00000001 00000000 00000010 00000003 339b28e2 adac515b 001b5a91 +00000001 00000002 00000000 00000001 00000000 00000010 00000004 339b28e2 adac515b 009ed941 +00000001 00000002 00000000 00000001 00000000 00000010 00000005 339b28e2 adac515b 007e6db1 +00000001 00000002 00000000 00000001 00000000 00000010 00000006 339b28e2 adac515b 006a6db1 +00000001 00000002 00000000 00000001 00000000 00000010 00000007 339b28e2 adac515b 006c1339 +00000001 00000002 00000000 00000001 00000000 00000010 00000008 339b28e2 adac515b 0073e423 +00000001 00000002 00000000 00000001 00000000 00000010 00000009 339b28e2 adac515b 00215749 +00000001 00000002 00000000 00000001 00000000 00000010 0000000a 339b28e2 adac515b 001c2843 +00000001 00000002 00000000 00000001 00000000 00000010 0000000b 339b28e2 adac515b 00c7de0e +00000001 00000002 00000000 00000001 00000000 00000010 0000000c 339b28e2 adac515b 00bbaf8e +00000001 00000002 00000000 00000001 00000000 00000010 0000000d 339b28e2 adac515b 00fd5e9a +00000001 00000002 00000000 00000001 00000000 00000010 0000000e 339b28e2 adac515b 009b6f76 +00000001 00000002 00000000 00000001 00000000 00000010 0000000f 339b28e2 adac515b 0001210b +00000001 00000002 00000000 00000001 00000000 ffffffff 00000000 339b28e2 adac515b 00cfaf4a +00000001 00000002 00000000 00000001 00000000 ffffffff 00000001 339b28e2 adac515b 00b7402b +00000001 00000002 00000000 00000001 00000000 ffffffff 00000002 339b28e2 adac515b 00669a31 +00000001 00000002 00000000 00000001 00000000 ffffffff 00000003 339b28e2 adac515b 00a6b04b +00000001 00000002 00000000 00000001 00000000 ffffffff 00000004 339b28e2 adac515b 003a5dc4 +00000001 00000002 00000000 00000001 00000000 ffffffff 00000005 339b28e2 adac515b 00727961 +00000001 00000002 00000000 00000001 00000000 ffffffff 00000006 339b28e2 adac515b 00792ab7 +00000001 00000002 00000000 00000001 00000000 ffffffff 00000007 339b28e2 adac515b 0063f61e +00000001 00000002 00000000 00000001 00000000 ffffffff 00000008 339b28e2 adac515b 00b63600 +00000001 00000002 00000000 00000001 00000000 ffffffff 00000009 339b28e2 adac515b 0038f439 +00000001 00000002 00000000 00000001 00000000 ffffffff 0000000a 339b28e2 adac515b 00f574e0 +00000001 00000002 00000000 00000001 00000000 ffffffff 0000000b 339b28e2 adac515b 00778075 +00000001 00000002 00000000 00000001 00000000 ffffffff 0000000c 339b28e2 adac515b 00e1675a +00000001 00000002 00000000 00000001 00000000 ffffffff 0000000d 339b28e2 adac515b 004a7ff2 +00000001 00000002 00000000 00000001 00000000 ffffffff 0000000e 339b28e2 adac515b 001b0476 +00000001 00000002 00000000 00000001 00000000 ffffffff 0000000f 339b28e2 adac515b 00a69cc2 +00000001 00000002 00000000 00000000 00000001 00000000 00000000 339b28e2 b670e289 000e1114 +00000001 00000002 00000000 00000000 00000001 00000000 00000001 339b28e2 b670e289 00e3521e +00000001 00000002 00000000 00000000 00000001 00000000 00000002 339b28e2 b670e289 0048f21a +00000001 00000002 00000000 00000000 00000001 00000000 00000003 339b28e2 b670e289 00cc45f9 +00000001 00000002 00000000 00000000 00000001 00000000 00000004 339b28e2 b670e289 0030c702 +00000001 00000002 00000000 00000000 00000001 00000000 00000005 339b28e2 b670e289 00a0446d +00000001 00000002 00000000 00000000 00000001 00000000 00000006 339b28e2 b670e289 0041c366 +00000001 00000002 00000000 00000000 00000001 00000000 00000007 339b28e2 b670e289 00be9418 +00000001 00000002 00000000 00000000 00000001 00000000 00000008 339b28e2 b670e289 001466be +00000001 00000002 00000000 00000000 00000001 00000000 00000009 339b28e2 b670e289 00d3b290 +00000001 00000002 00000000 00000000 00000001 00000000 0000000a 339b28e2 b670e289 0048dd45 +00000001 00000002 00000000 00000000 00000001 00000000 0000000b 339b28e2 b670e289 00fa46bd +00000001 00000002 00000000 00000000 00000001 00000000 0000000c 339b28e2 b670e289 002c4d20 +00000001 00000002 00000000 00000000 00000001 00000000 0000000d 339b28e2 b670e289 00808e3c +00000001 00000002 00000000 00000000 00000001 00000000 0000000e 339b28e2 b670e289 00438597 +00000001 00000002 00000000 00000000 00000001 00000000 0000000f 339b28e2 b670e289 0088bd5f +00000001 00000002 00000000 00000000 00000001 00000010 00000000 339b28e2 b670e289 000676d5 +00000001 00000002 00000000 00000000 00000001 00000010 00000001 339b28e2 b670e289 0074d5c0 +00000001 00000002 00000000 00000000 00000001 00000010 00000002 339b28e2 b670e289 00ea1be8 +00000001 00000002 00000000 00000000 00000001 00000010 00000003 339b28e2 b670e289 004325b9 +00000001 00000002 00000000 00000000 00000001 00000010 00000004 339b28e2 b670e289 00de2573 +00000001 00000002 00000000 00000000 00000001 00000010 00000005 339b28e2 b670e289 00204ebd +00000001 00000002 00000000 00000000 00000001 00000010 00000006 339b28e2 b670e289 003e7f49 +00000001 00000002 00000000 00000000 00000001 00000010 00000007 339b28e2 b670e289 003c884a +00000001 00000002 00000000 00000000 00000001 00000010 00000008 339b28e2 b670e289 002feea2 +00000001 00000002 00000000 00000000 00000001 00000010 00000009 339b28e2 b670e289 0061a462 +00000001 00000002 00000000 00000000 00000001 00000010 0000000a 339b28e2 b670e289 0047b656 +00000001 00000002 00000000 00000000 00000001 00000010 0000000b 339b28e2 b670e289 00b68307 +00000001 00000002 00000000 00000000 00000001 00000010 0000000c 339b28e2 b670e289 00ea18a1 +00000001 00000002 00000000 00000000 00000001 00000010 0000000d 339b28e2 b670e289 00a49809 +00000001 00000002 00000000 00000000 00000001 00000010 0000000e 339b28e2 b670e289 00ecae35 +00000001 00000002 00000000 00000000 00000001 00000010 0000000f 339b28e2 b670e289 006decee +00000001 00000002 00000000 00000000 00000001 ffffffff 00000000 339b28e2 b670e289 008bd092 +00000001 00000002 00000000 00000000 00000001 ffffffff 00000001 339b28e2 b670e289 00e3521e +00000001 00000002 00000000 00000000 00000001 ffffffff 00000002 339b28e2 b670e289 0017e12c +00000001 00000002 00000000 00000000 00000001 ffffffff 00000003 339b28e2 b670e289 00fdfab4 +00000001 00000002 00000000 00000000 00000001 ffffffff 00000004 339b28e2 b670e289 0073a194 +00000001 00000002 00000000 00000000 00000001 ffffffff 00000005 339b28e2 b670e289 002f75e6 +00000001 00000002 00000000 00000000 00000001 ffffffff 00000006 339b28e2 b670e289 00299498 +00000001 00000002 00000000 00000000 00000001 ffffffff 00000007 339b28e2 b670e289 0036e678 +00000001 00000002 00000000 00000000 00000001 ffffffff 00000008 339b28e2 b670e289 00c304d9 +00000001 00000002 00000000 00000000 00000001 ffffffff 00000009 339b28e2 b670e289 00755cc6 +00000001 00000002 00000000 00000000 00000001 ffffffff 0000000a 339b28e2 b670e289 00825a8a +00000001 00000002 00000000 00000000 00000001 ffffffff 0000000b 339b28e2 b670e289 000b5b1e +00000001 00000002 00000000 00000000 00000001 ffffffff 0000000c 339b28e2 b670e289 009fd8b7 +00000001 00000002 00000000 00000000 00000001 ffffffff 0000000d 339b28e2 b670e289 00198312 +00000001 00000002 00000000 00000000 00000001 ffffffff 0000000e 339b28e2 b670e289 007d4174 +00000001 00000002 00000000 00000000 00000001 ffffffff 0000000f 339b28e2 b670e289 00dd3f81 +00000001 00000002 00000000 00000003 00000007 00000000 00000000 339b28e2 404fcd24 00effdbb +00000001 00000002 00000000 00000003 00000007 00000000 00000001 339b28e2 404fcd24 005f1c93 +00000001 00000002 00000000 00000003 00000007 00000000 00000002 339b28e2 404fcd24 00961b9a +00000001 00000002 00000000 00000003 00000007 00000000 00000003 339b28e2 404fcd24 0003d5ad +00000001 00000002 00000000 00000003 00000007 00000000 00000004 339b28e2 404fcd24 00a48e5f +00000001 00000002 00000000 00000003 00000007 00000000 00000005 339b28e2 404fcd24 005c86e0 +00000001 00000002 00000000 00000003 00000007 00000000 00000006 339b28e2 404fcd24 00c7fd90 +00000001 00000002 00000000 00000003 00000007 00000000 00000007 339b28e2 404fcd24 00266574 +00000001 00000002 00000000 00000003 00000007 00000000 00000008 339b28e2 404fcd24 00db407c +00000001 00000002 00000000 00000003 00000007 00000000 00000009 339b28e2 404fcd24 005d8720 +00000001 00000002 00000000 00000003 00000007 00000000 0000000a 339b28e2 404fcd24 00bdbebb +00000001 00000002 00000000 00000003 00000007 00000000 0000000b 339b28e2 404fcd24 0012ed18 +00000001 00000002 00000000 00000003 00000007 00000000 0000000c 339b28e2 404fcd24 00804263 +00000001 00000002 00000000 00000003 00000007 00000000 0000000d 339b28e2 404fcd24 005f0906 +00000001 00000002 00000000 00000003 00000007 00000000 0000000e 339b28e2 404fcd24 00f69027 +00000001 00000002 00000000 00000003 00000007 00000000 0000000f 339b28e2 404fcd24 0039df4b +00000001 00000002 00000000 00000003 00000007 00000010 00000000 339b28e2 404fcd24 00e315b5 +00000001 00000002 00000000 00000003 00000007 00000010 00000001 339b28e2 404fcd24 00d9df6c +00000001 00000002 00000000 00000003 00000007 00000010 00000002 339b28e2 404fcd24 00067a4a +00000001 00000002 00000000 00000003 00000007 00000010 00000003 339b28e2 404fcd24 00b94ed6 +00000001 00000002 00000000 00000003 00000007 00000010 00000004 339b28e2 404fcd24 0059fa46 +00000001 00000002 00000000 00000003 00000007 00000010 00000005 339b28e2 404fcd24 00f6303b +00000001 00000002 00000000 00000003 00000007 00000010 00000006 339b28e2 404fcd24 00a0a5de +00000001 00000002 00000000 00000003 00000007 00000010 00000007 339b28e2 404fcd24 00ad26b2 +00000001 00000002 00000000 00000003 00000007 00000010 00000008 339b28e2 404fcd24 00f7f330 +00000001 00000002 00000000 00000003 00000007 00000010 00000009 339b28e2 404fcd24 00e451a2 +00000001 00000002 00000000 00000003 00000007 00000010 0000000a 339b28e2 404fcd24 00b62bef +00000001 00000002 00000000 00000003 00000007 00000010 0000000b 339b28e2 404fcd24 0075014a +00000001 00000002 00000000 00000003 00000007 00000010 0000000c 339b28e2 404fcd24 0059b021 +00000001 00000002 00000000 00000003 00000007 00000010 0000000d 339b28e2 404fcd24 006251b6 +00000001 00000002 00000000 00000003 00000007 00000010 0000000e 339b28e2 404fcd24 0052b6d0 +00000001 00000002 00000000 00000003 00000007 00000010 0000000f 339b28e2 404fcd24 00d12e33 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000000 339b28e2 404fcd24 005c6282 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000001 339b28e2 404fcd24 005f1c93 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000002 339b28e2 404fcd24 00f20640 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000003 339b28e2 404fcd24 0027d1b7 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000004 339b28e2 404fcd24 00f0d435 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000005 339b28e2 404fcd24 00fdef8d +00000001 00000002 00000000 00000003 00000007 ffffffff 00000006 339b28e2 404fcd24 00bdb3a1 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000007 339b28e2 404fcd24 00a3705b +00000001 00000002 00000000 00000003 00000007 ffffffff 00000008 339b28e2 404fcd24 000a38f3 +00000001 00000002 00000000 00000003 00000007 ffffffff 00000009 339b28e2 404fcd24 00fc45b8 +00000001 00000002 00000000 00000003 00000007 ffffffff 0000000a 339b28e2 404fcd24 007a794e +00000001 00000002 00000000 00000003 00000007 ffffffff 0000000b 339b28e2 404fcd24 00ec6b83 +00000001 00000002 00000000 00000003 00000007 ffffffff 0000000c 339b28e2 404fcd24 003fcb2b +00000001 00000002 00000000 00000003 00000007 ffffffff 0000000d 339b28e2 404fcd24 00f9d6b8 +00000001 00000002 00000000 00000003 00000007 ffffffff 0000000e 339b28e2 404fcd24 00d04cf2 +00000001 00000002 00000000 00000003 00000007 ffffffff 0000000f 339b28e2 404fcd24 00661306 +00000001 00000002 00000001 00000000 00000000 00000000 00000000 5b12b822 5b12b822 009456f9 +00000001 00000002 00000001 00000000 00000000 00000000 00000001 5b12b822 5b12b822 000d1ab0 +00000001 00000002 00000001 00000000 00000000 00000000 00000002 5b12b822 5b12b822 00f39535 +00000001 00000002 00000001 00000000 00000000 00000000 00000003 5b12b822 5b12b822 007e343b +00000001 00000002 00000001 00000000 00000000 00000000 00000004 5b12b822 5b12b822 00c00491 +00000001 00000002 00000001 00000000 00000000 00000000 00000005 5b12b822 5b12b822 00296417 +00000001 00000002 00000001 00000000 00000000 00000000 00000006 5b12b822 5b12b822 00be7d07 +00000001 00000002 00000001 00000000 00000000 00000000 00000007 5b12b822 5b12b822 007b8758 +00000001 00000002 00000001 00000000 00000000 00000000 00000008 5b12b822 5b12b822 00a5fdbd +00000001 00000002 00000001 00000000 00000000 00000000 00000009 5b12b822 5b12b822 0017ae92 +00000001 00000002 00000001 00000000 00000000 00000000 0000000a 5b12b822 5b12b822 00d60802 +00000001 00000002 00000001 00000000 00000000 00000000 0000000b 5b12b822 5b12b822 007e8cb9 +00000001 00000002 00000001 00000000 00000000 00000000 0000000c 5b12b822 5b12b822 00e975c8 +00000001 00000002 00000001 00000000 00000000 00000000 0000000d 5b12b822 5b12b822 003a2e24 +00000001 00000002 00000001 00000000 00000000 00000000 0000000e 5b12b822 5b12b822 008ac1bd +00000001 00000002 00000001 00000000 00000000 00000000 0000000f 5b12b822 5b12b822 0078e280 +00000001 00000002 00000001 00000000 00000000 00000010 00000000 5b12b822 5b12b822 009ec42a +00000001 00000002 00000001 00000000 00000000 00000010 00000001 5b12b822 5b12b822 00850346 +00000001 00000002 00000001 00000000 00000000 00000010 00000002 5b12b822 5b12b822 006f08de +00000001 00000002 00000001 00000000 00000000 00000010 00000003 5b12b822 5b12b822 00d2ea97 +00000001 00000002 00000001 00000000 00000000 00000010 00000004 5b12b822 5b12b822 00121e7a +00000001 00000002 00000001 00000000 00000000 00000010 00000005 5b12b822 5b12b822 0082eee4 +00000001 00000002 00000001 00000000 00000000 00000010 00000006 5b12b822 5b12b822 00f549a0 +00000001 00000002 00000001 00000000 00000000 00000010 00000007 5b12b822 5b12b822 00fe57ed +00000001 00000002 00000001 00000000 00000000 00000010 00000008 5b12b822 5b12b822 00833af8 +00000001 00000002 00000001 00000000 00000000 00000010 00000009 5b12b822 5b12b822 00a4be61 +00000001 00000002 00000001 00000000 00000000 00000010 0000000a 5b12b822 5b12b822 00dd6980 +00000001 00000002 00000001 00000000 00000000 00000010 0000000b 5b12b822 5b12b822 003350a7 +00000001 00000002 00000001 00000000 00000000 00000010 0000000c 5b12b822 5b12b822 000bdaab +00000001 00000002 00000001 00000000 00000000 00000010 0000000d 5b12b822 5b12b822 0003ef27 +00000001 00000002 00000001 00000000 00000000 00000010 0000000e 5b12b822 5b12b822 003934da +00000001 00000002 00000001 00000000 00000000 00000010 0000000f 5b12b822 5b12b822 00a15d78 +00000001 00000002 00000001 00000000 00000000 ffffffff 00000000 5b12b822 5b12b822 0039c872 +00000001 00000002 00000001 00000000 00000000 ffffffff 00000001 5b12b822 5b12b822 000d1ab0 +00000001 00000002 00000001 00000000 00000000 ffffffff 00000002 5b12b822 5b12b822 00b2e665 +00000001 00000002 00000001 00000000 00000000 ffffffff 00000003 5b12b822 5b12b822 0056414c +00000001 00000002 00000001 00000000 00000000 ffffffff 00000004 5b12b822 5b12b822 00b413e3 +00000001 00000002 00000001 00000000 00000000 ffffffff 00000005 5b12b822 5b12b822 008958dc +00000001 00000002 00000001 00000000 00000000 ffffffff 00000006 5b12b822 5b12b822 00e435ae +00000001 00000002 00000001 00000000 00000000 ffffffff 00000007 5b12b822 5b12b822 00f79423 +00000001 00000002 00000001 00000000 00000000 ffffffff 00000008 5b12b822 5b12b822 004eb81b +00000001 00000002 00000001 00000000 00000000 ffffffff 00000009 5b12b822 5b12b822 00b99899 +00000001 00000002 00000001 00000000 00000000 ffffffff 0000000a 5b12b822 5b12b822 00278e74 +00000001 00000002 00000001 00000000 00000000 ffffffff 0000000b 5b12b822 5b12b822 00aa169a +00000001 00000002 00000001 00000000 00000000 ffffffff 0000000c 5b12b822 5b12b822 005b2872 +00000001 00000002 00000001 00000000 00000000 ffffffff 0000000d 5b12b822 5b12b822 0085aa57 +00000001 00000002 00000001 00000000 00000000 ffffffff 0000000e 5b12b822 5b12b822 00a75bae +00000001 00000002 00000001 00000000 00000000 ffffffff 0000000f 5b12b822 5b12b822 00052f24 +00000001 00000002 00000001 00000001 00000000 00000000 00000000 5b12b822 c525c19b 0052c316 +00000001 00000002 00000001 00000001 00000000 00000000 00000001 5b12b822 c525c19b 00a51509 +00000001 00000002 00000001 00000001 00000000 00000000 00000002 5b12b822 c525c19b 000d0cf3 +00000001 00000002 00000001 00000001 00000000 00000000 00000003 5b12b822 c525c19b 00912f20 +00000001 00000002 00000001 00000001 00000000 00000000 00000004 5b12b822 c525c19b 005568bf +00000001 00000002 00000001 00000001 00000000 00000000 00000005 5b12b822 c525c19b 00e9052c +00000001 00000002 00000001 00000001 00000000 00000000 00000006 5b12b822 c525c19b 0039d8f5 +00000001 00000002 00000001 00000001 00000000 00000000 00000007 5b12b822 c525c19b 00fd3674 +00000001 00000002 00000001 00000001 00000000 00000000 00000008 5b12b822 c525c19b 005d983e +00000001 00000002 00000001 00000001 00000000 00000000 00000009 5b12b822 c525c19b 008af597 +00000001 00000002 00000001 00000001 00000000 00000000 0000000a 5b12b822 c525c19b 0016e794 +00000001 00000002 00000001 00000001 00000000 00000000 0000000b 5b12b822 c525c19b 00b0ca0d +00000001 00000002 00000001 00000001 00000000 00000000 0000000c 5b12b822 c525c19b 005fde83 +00000001 00000002 00000001 00000001 00000000 00000000 0000000d 5b12b822 c525c19b 00d16909 +00000001 00000002 00000001 00000001 00000000 00000000 0000000e 5b12b822 c525c19b 0021c1b1 +00000001 00000002 00000001 00000001 00000000 00000000 0000000f 5b12b822 c525c19b 00d86a52 +00000001 00000002 00000001 00000001 00000000 00000010 00000000 5b12b822 c525c19b 005e9d94 +00000001 00000002 00000001 00000001 00000000 00000010 00000001 5b12b822 c525c19b 002ede10 +00000001 00000002 00000001 00000001 00000000 00000010 00000002 5b12b822 c525c19b 00a4f1c9 +00000001 00000002 00000001 00000001 00000000 00000010 00000003 5b12b822 c525c19b 001b2f2e +00000001 00000002 00000001 00000001 00000000 00000010 00000004 5b12b822 c525c19b 00831695 +00000001 00000002 00000001 00000001 00000000 00000010 00000005 5b12b822 c525c19b 00751479 +00000001 00000002 00000001 00000001 00000000 00000010 00000006 5b12b822 c525c19b 00621b9b +00000001 00000002 00000001 00000001 00000000 00000010 00000007 5b12b822 c525c19b 0067cb48 +00000001 00000002 00000001 00000001 00000000 00000010 00000008 5b12b822 c525c19b 007ea90e +00000001 00000002 00000001 00000001 00000000 00000010 00000009 5b12b822 c525c19b 002670f1 +00000001 00000002 00000001 00000001 00000000 00000010 0000000a 5b12b822 c525c19b 001d05ee +00000001 00000002 00000001 00000001 00000000 00000010 0000000b 5b12b822 c525c19b 00d4cfe5 +00000001 00000002 00000001 00000001 00000000 00000010 0000000c 5b12b822 c525c19b 00afbf86 +00000001 00000002 00000001 00000001 00000000 00000010 0000000d 5b12b822 c525c19b 00e80258 +00000001 00000002 00000001 00000001 00000000 00000010 0000000e 5b12b822 c525c19b 0080604b +00000001 00000002 00000001 00000001 00000000 00000010 0000000f 5b12b822 c525c19b 00039c0d +00000001 00000002 00000001 00000001 00000000 ffffffff 00000000 5b12b822 c525c19b 00db8d25 +00000001 00000002 00000001 00000001 00000000 ffffffff 00000001 5b12b822 c525c19b 00a51509 +00000001 00000002 00000001 00000001 00000000 ffffffff 00000002 5b12b822 c525c19b 006f9a96 +00000001 00000002 00000001 00000001 00000000 ffffffff 00000003 5b12b822 c525c19b 00b395f8 +00000001 00000002 00000001 00000001 00000000 ffffffff 00000004 5b12b822 c525c19b 003d7476 +00000001 00000002 00000001 00000001 00000000 ffffffff 00000005 5b12b822 c525c19b 007f522d +00000001 00000002 00000001 00000001 00000000 ffffffff 00000006 5b12b822 c525c19b 0075b448 +00000001 00000002 00000001 00000001 00000000 ffffffff 00000007 5b12b822 c525c19b 006fef1c +00000001 00000002 00000001 00000001 00000000 ffffffff 00000008 5b12b822 c525c19b 00a86bd3 +00000001 00000002 00000001 00000001 00000000 ffffffff 00000009 5b12b822 c525c19b 003e2242 +00000001 00000002 00000001 00000001 00000000 ffffffff 0000000a 5b12b822 c525c19b 00e1e934 +00000001 00000002 00000001 00000001 00000000 ffffffff 0000000b 5b12b822 c525c19b 00790bbe +00000001 00000002 00000001 00000001 00000000 ffffffff 0000000c 5b12b822 c525c19b 00f198d7 +00000001 00000002 00000001 00000001 00000000 ffffffff 0000000d 5b12b822 c525c19b 00406800 +00000001 00000002 00000001 00000001 00000000 ffffffff 0000000e 5b12b822 c525c19b 001ade96 +00000001 00000002 00000001 00000001 00000000 ffffffff 0000000f 5b12b822 c525c19b 00b4693f +00000001 00000002 00000001 00000000 00000001 00000000 00000000 5b12b822 def97249 000dcfee +00000001 00000002 00000001 00000000 00000001 00000000 00000001 5b12b822 def97249 00fe6f1e +00000001 00000002 00000001 00000000 00000001 00000000 00000002 5b12b822 def97249 00446c87 +00000001 00000002 00000001 00000000 00000001 00000000 00000003 5b12b822 def97249 00d518af +00000001 00000002 00000001 00000000 00000001 00000000 00000004 5b12b822 def97249 0036311b +00000001 00000002 00000001 00000000 00000001 00000000 00000005 5b12b822 def97249 00bbb01a +00000001 00000002 00000001 00000000 00000001 00000000 00000006 5b12b822 def97249 004e49de +00000001 00000002 00000001 00000000 00000001 00000000 00000007 5b12b822 def97249 00a4e9b2 +00000001 00000002 00000001 00000000 00000001 00000000 00000008 5b12b822 def97249 0015e063 +00000001 00000002 00000001 00000000 00000001 00000000 00000009 5b12b822 def97249 00c90949 +00000001 00000002 00000001 00000000 00000001 00000000 0000000a 5b12b822 def97249 00460b53 +00000001 00000002 00000001 00000000 00000001 00000000 0000000b 5b12b822 def97249 00e4adcc +00000001 00000002 00000001 00000000 00000001 00000000 0000000c 5b12b822 def97249 00291f20 +00000001 00000002 00000001 00000000 00000001 00000000 0000000d 5b12b822 def97249 0095c2ed +00000001 00000002 00000001 00000000 00000001 00000000 0000000e 5b12b822 def97249 004eb429 +00000001 00000002 00000001 00000000 00000001 00000000 0000000f 5b12b822 def97249 009ad07f +00000001 00000002 00000001 00000000 00000001 00000010 00000000 5b12b822 def97249 0005b08f +00000001 00000002 00000001 00000000 00000001 00000010 00000001 5b12b822 def97249 0078ec5c +00000001 00000002 00000001 00000000 00000001 00000010 00000002 5b12b822 def97249 00fa7b53 +00000001 00000002 00000001 00000000 00000001 00000010 00000003 5b12b822 def97249 0049ec59 +00000001 00000002 00000001 00000000 00000001 00000010 00000004 5b12b822 def97249 00c5fe1a +00000001 00000002 00000001 00000000 00000001 00000010 00000005 5b12b822 def97249 00270ebc +00000001 00000002 00000001 00000000 00000001 00000010 00000006 5b12b822 def97249 0038c1eb +00000001 00000002 00000001 00000000 00000001 00000010 00000007 5b12b822 def97249 003aea9a +00000001 00000002 00000001 00000000 00000001 00000010 00000008 5b12b822 def97249 0028f409 +00000001 00000002 00000001 00000000 00000001 00000010 00000009 5b12b822 def97249 006b8226 +00000001 00000002 00000001 00000000 00000001 00000010 0000000a 5b12b822 def97249 004efafd +00000001 00000002 00000001 00000000 00000001 00000010 0000000b 5b12b822 def97249 00a29f5a +00000001 00000002 00000001 00000000 00000001 00000010 0000000c 5b12b822 def97249 00f740e5 +00000001 00000002 00000001 00000000 00000001 00000010 0000000d 5b12b822 def97249 00b9061f +00000001 00000002 00000001 00000000 00000001 00000010 0000000e 5b12b822 def97249 00f3be91 +00000001 00000002 00000001 00000000 00000001 00000010 0000000f 5b12b822 def97249 0066bf80 +00000001 00000002 00000001 00000000 00000001 ffffffff 00000000 5b12b822 def97249 00995b77 +00000001 00000002 00000001 00000000 00000001 ffffffff 00000001 5b12b822 def97249 00fe6f1e +00000001 00000002 00000001 00000000 00000001 ffffffff 00000002 5b12b822 def97249 0016abcb +00000001 00000002 00000001 00000000 00000001 ffffffff 00000003 5b12b822 def97249 00e543c1 +00000001 00000002 00000001 00000000 00000001 ffffffff 00000004 5b12b822 def97249 007cf956 +00000001 00000002 00000001 00000000 00000001 ffffffff 00000005 5b12b822 def97249 0028264d +00000001 00000002 00000001 00000000 00000001 ffffffff 00000006 5b12b822 def97249 002e9aa1 +00000001 00000002 00000001 00000000 00000001 ffffffff 00000007 5b12b822 def97249 0033f56d +00000001 00000002 00000001 00000000 00000001 ffffffff 00000008 5b12b822 def97249 00db66e5 +00000001 00000002 00000001 00000000 00000001 ffffffff 00000009 5b12b822 def97249 007a58e1 +00000001 00000002 00000001 00000000 00000001 ffffffff 0000000a 5b12b822 def97249 00904e8f +00000001 00000002 00000001 00000000 00000001 ffffffff 0000000b 5b12b822 def97249 0008bc10 +00000001 00000002 00000001 00000000 00000001 ffffffff 0000000c 5b12b822 def97249 008d26f0 +00000001 00000002 00000001 00000000 00000001 ffffffff 0000000d 5b12b822 def97249 0018e1b1 +00000001 00000002 00000001 00000000 00000001 ffffffff 0000000e 5b12b822 def97249 0077c9ed +00000001 00000002 00000001 00000000 00000001 ffffffff 0000000f 5b12b822 def97249 00cfd878 +00000001 00000002 00000001 00000003 00000007 00000000 00000000 5b12b822 28c65de4 00fd45a7 +00000001 00000002 00000001 00000003 00000007 00000000 00000001 5b12b822 28c65de4 0053b86d +00000001 00000002 00000001 00000003 00000007 00000000 00000002 5b12b822 28c65de4 008ae18f +00000001 00000002 00000001 00000003 00000007 00000000 00000003 5b12b822 28c65de4 0000c106 +00000001 00000002 00000001 00000003 00000007 00000000 00000004 5b12b822 28c65de4 00b63f36 +00000001 00000002 00000001 00000003 00000007 00000000 00000005 5b12b822 28c65de4 0054032a +00000001 00000002 00000001 00000003 00000007 00000000 00000006 5b12b822 28c65de4 00d4eeb4 +00000001 00000002 00000001 00000003 00000007 00000000 00000007 5b12b822 28c65de4 00202eab +00000001 00000002 00000001 00000003 00000007 00000000 00000008 5b12b822 28c65de4 00cf9d43 +00000001 00000002 00000001 00000003 00000007 00000000 00000009 5b12b822 28c65de4 005221ea +00000001 00000002 00000001 00000003 00000007 00000000 0000000a 5b12b822 28c65de4 00a855d3 +00000001 00000002 00000001 00000003 00000007 00000000 0000000b 5b12b822 28c65de4 00134546 +00000001 00000002 00000001 00000003 00000007 00000000 0000000c 5b12b822 28c65de4 009de9b2 +00000001 00000002 00000001 00000003 00000007 00000000 0000000d 5b12b822 28c65de4 00558f71 +00000001 00000002 00000001 00000003 00000007 00000000 0000000e 5b12b822 28c65de4 00e2d6a4 +00000001 00000002 00000001 00000003 00000007 00000000 0000000f 5b12b822 28c65de4 003f6692 +00000001 00000002 00000001 00000003 00000007 00000010 00000000 5b12b822 28c65de4 00f6b648 +00000001 00000002 00000001 00000003 00000007 00000010 00000001 5b12b822 28c65de4 00c469e5 +00000001 00000002 00000001 00000003 00000007 00000010 00000002 5b12b822 28c65de4 0004bea1 +00000001 00000002 00000001 00000003 00000007 00000010 00000003 5b12b822 28c65de4 00ace4c0 +00000001 00000002 00000001 00000003 00000007 00000010 00000004 5b12b822 28c65de4 0057baf8 +00000001 00000002 00000001 00000003 00000007 00000010 00000005 5b12b822 28c65de4 00ec7aea +00000001 00000002 00000001 00000003 00000007 00000010 00000006 5b12b822 28c65de4 00b0a15f +00000001 00000002 00000001 00000003 00000007 00000010 00000007 5b12b822 28c65de4 00b920eb +00000001 00000002 00000001 00000003 00000007 00000010 00000008 5b12b822 28c65de4 00edb1c0 +00000001 00000002 00000001 00000003 00000007 00000010 00000009 5b12b822 28c65de4 00fcb35d +00000001 00000002 00000001 00000003 00000007 00000010 0000000a 5b12b822 28c65de4 00a55b3b +00000001 00000002 00000001 00000003 00000007 00000010 0000000b 5b12b822 28c65de4 007e9fff +00000001 00000002 00000001 00000003 00000007 00000010 0000000c 5b12b822 28c65de4 00553602 +00000001 00000002 00000001 00000003 00000007 00000010 0000000d 5b12b822 28c65de4 006e63b2 +00000001 00000002 00000001 00000003 00000007 00000010 0000000e 5b12b822 28c65de4 005b6d81 +00000001 00000002 00000001 00000003 00000007 00000010 0000000f 5b12b822 28c65de4 00c40eec +00000001 00000002 00000001 00000003 00000007 ffffffff 00000000 5b12b822 28c65de4 0057e861 +00000001 00000002 00000001 00000003 00000007 ffffffff 00000001 5b12b822 28c65de4 0053b86d +00000001 00000002 00000001 00000003 00000007 ffffffff 00000002 5b12b822 28c65de4 00ec6ca4 +00000001 00000002 00000001 00000003 00000007 ffffffff 00000003 5b12b822 28c65de4 002265b4 +00000001 00000002 00000001 00000003 00000007 ffffffff 00000004 5b12b822 28c65de4 00e1771b +00000001 00000002 00000001 00000003 00000007 ffffffff 00000005 5b12b822 28c65de4 00e511d3 +00000001 00000002 00000001 00000003 00000007 ffffffff 00000006 5b12b822 28c65de4 00a70ad3 +00000001 00000002 00000001 00000003 00000007 ffffffff 00000007 5b12b822 28c65de4 00b330e6 +00000001 00000002 00000001 00000003 00000007 ffffffff 00000008 5b12b822 28c65de4 0009c20e +00000001 00000002 00000001 00000003 00000007 ffffffff 00000009 5b12b822 28c65de4 00e85494 +00000001 00000002 00000001 00000003 00000007 ffffffff 0000000a 5b12b822 28c65de4 0074b927 +00000001 00000002 00000001 00000003 00000007 ffffffff 0000000b 5b12b822 28c65de4 00fe148b +00000001 00000002 00000001 00000003 00000007 ffffffff 0000000c 5b12b822 28c65de4 003860d5 +00000001 00000002 00000001 00000003 00000007 ffffffff 0000000d 5b12b822 28c65de4 00e67365 +00000001 00000002 00000001 00000003 00000007 ffffffff 0000000e 5b12b822 28c65de4 00cc43e0 +00000001 00000002 00000001 00000003 00000007 ffffffff 0000000f 5b12b822 28c65de4 006a1fee +00000001 00000002 12345678 00000000 00000000 00000000 00000000 c67c3474 c67c3474 008f8d5f +00000001 00000002 12345678 00000000 00000000 00000000 00000001 c67c3474 c67c3474 006091c8 +00000001 00000002 12345678 00000000 00000000 00000000 00000002 c67c3474 c67c3474 00e56e50 +00000001 00000002 12345678 00000000 00000000 00000000 00000003 c67c3474 c67c3474 000c9801 +00000001 00000002 12345678 00000000 00000000 00000000 00000004 c67c3474 c67c3474 00d8f583 +00000001 00000002 12345678 00000000 00000000 00000000 00000005 c67c3474 c67c3474 006b0a51 +00000001 00000002 12345678 00000000 00000000 00000000 00000006 c67c3474 c67c3474 00a1b3dd +00000001 00000002 12345678 00000000 00000000 00000000 00000007 c67c3474 c67c3474 00323d96 +00000001 00000002 12345678 00000000 00000000 00000000 00000008 c67c3474 c67c3474 00b3d4af +00000001 00000002 12345678 00000000 00000000 00000000 00000009 c67c3474 c67c3474 006bb86b +00000001 00000002 12345678 00000000 00000000 00000000 0000000a c67c3474 c67c3474 00c4e95d +00000001 00000002 12345678 00000000 00000000 00000000 0000000b c67c3474 c67c3474 0012ede3 +00000001 00000002 12345678 00000000 00000000 00000000 0000000c c67c3474 c67c3474 00f5e37e +00000001 00000002 12345678 00000000 00000000 00000000 0000000d c67c3474 c67c3474 00603e1c +00000001 00000002 12345678 00000000 00000000 00000000 0000000e c67c3474 c67c3474 009e1be6 +00000001 00000002 12345678 00000000 00000000 00000000 0000000f c67c3474 c67c3474 002b00dc +00000001 00000002 12345678 00000000 00000000 00000010 00000000 c67c3474 c67c3474 0082466e +00000001 00000002 12345678 00000000 00000000 00000010 00000001 c67c3474 c67c3474 00af251b +00000001 00000002 12345678 00000000 00000000 00000010 00000002 c67c3474 c67c3474 000fb4fc +00000001 00000002 12345678 00000000 00000000 00000010 00000003 c67c3474 c67c3474 00c351f9 +00000001 00000002 12345678 00000000 00000000 00000010 00000004 c67c3474 c67c3474 006b011e +00000001 00000002 12345678 00000000 00000000 00000010 00000005 c67c3474 c67c3474 0084a004 +00000001 00000002 12345678 00000000 00000000 00000010 00000006 c67c3474 c67c3474 00d825ba +00000001 00000002 12345678 00000000 00000000 00000010 00000007 c67c3474 c67c3474 00d3ea3c +00000001 00000002 12345678 00000000 00000000 00000010 00000008 c67c3474 c67c3474 0084946b +00000001 00000002 12345678 00000000 00000000 00000010 00000009 c67c3474 c67c3474 009280ab +00000001 00000002 12345678 00000000 00000000 00000010 0000000a c67c3474 c67c3474 00cc6838 +00000001 00000002 12345678 00000000 00000000 00000010 0000000b c67c3474 c67c3474 004a3b33 +00000001 00000002 12345678 00000000 00000000 00000010 0000000c c67c3474 c67c3474 00679e00 +00000001 00000002 12345678 00000000 00000000 00000010 0000000d c67c3474 c67c3474 0051730f +00000001 00000002 12345678 00000000 00000000 00000010 0000000e c67c3474 c67c3474 006c00c1 +00000001 00000002 12345678 00000000 00000000 00000010 0000000f c67c3474 c67c3474 00abfb15 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000000 c67c3474 c67c3474 0066c540 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000001 c67c3474 c67c3474 006091c8 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000002 c67c3474 c67c3474 0096f9ee +00000001 00000002 12345678 00000000 00000000 ffffffff 00000003 c67c3474 c67c3474 00355187 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000004 c67c3474 c67c3474 008aca45 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000005 c67c3474 c67c3474 0088d1aa +00000001 00000002 12345678 00000000 00000000 ffffffff 00000006 c67c3474 c67c3474 00c96fa7 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000007 c67c3474 c67c3474 00de4991 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000008 c67c3474 c67c3474 00029890 +00000001 00000002 12345678 00000000 00000000 ffffffff 00000009 c67c3474 c67c3474 0081c5a8 +00000001 00000002 12345678 00000000 00000000 ffffffff 0000000a c67c3474 c67c3474 004d94d5 +00000001 00000002 12345678 00000000 00000000 ffffffff 0000000b c67c3474 c67c3474 008fc90f +00000001 00000002 12345678 00000000 00000000 ffffffff 0000000c c67c3474 c67c3474 002d4b65 +00000001 00000002 12345678 00000000 00000000 ffffffff 0000000d c67c3474 c67c3474 009d5110 +00000001 00000002 12345678 00000000 00000000 ffffffff 0000000e c67c3474 c67c3474 00a7766e +00000001 00000002 12345678 00000000 00000000 ffffffff 0000000f c67c3474 c67c3474 0051251c +00000001 00000002 12345678 00000001 00000000 00000000 00000000 c67c3474 584b4dcd 00337c13 +00000001 00000002 12345678 00000001 00000000 00000000 00000001 c67c3474 584b4dcd 00b04dcb +00000001 00000002 12345678 00000001 00000000 00000000 00000002 c67c3474 584b4dcd 004c8726 +00000001 00000002 12345678 00000001 00000000 00000000 00000003 c67c3474 584b4dcd 0089abff +00000001 00000002 12345678 00000001 00000000 00000000 00000004 c67c3474 584b4dcd 000bfcd4 +00000001 00000002 12345678 00000001 00000000 00000000 00000005 c67c3474 584b4dcd 00f67086 +00000001 00000002 12345678 00000001 00000000 00000000 00000006 c67c3474 584b4dcd 0045831c +00000001 00000002 12345678 00000001 00000000 00000000 00000007 c67c3474 584b4dcd 00eed90e +00000001 00000002 12345678 00000001 00000000 00000000 00000008 c67c3474 584b4dcd 002dfc9f +00000001 00000002 12345678 00000001 00000000 00000000 00000009 c67c3474 584b4dcd 009d7381 +00000001 00000002 12345678 00000001 00000000 00000000 0000000a c67c3474 584b4dcd 004c8f8b +00000001 00000002 12345678 00000001 00000000 00000000 0000000b c67c3474 584b4dcd 00af548e +00000001 00000002 12345678 00000001 00000000 00000000 0000000c c67c3474 584b4dcd 0013ce46 +00000001 00000002 12345678 00000001 00000000 00000000 0000000d c67c3474 584b4dcd 00c07d68 +00000001 00000002 12345678 00000001 00000000 00000000 0000000e c67c3474 584b4dcd 0047260c +00000001 00000002 12345678 00000001 00000000 00000000 0000000f c67c3474 584b4dcd 00cdb284 +00000001 00000002 12345678 00000001 00000000 00000010 00000000 c67c3474 584b4dcd 003827a1 +00000001 00000002 12345678 00000001 00000000 00000010 00000001 c67c3474 584b4dcd 006af255 +00000001 00000002 12345678 00000001 00000000 00000010 00000002 c67c3474 584b4dcd 00b8cc2c +00000001 00000002 12345678 00000001 00000000 00000010 00000003 c67c3474 584b4dcd 0041347b +00000001 00000002 12345678 00000001 00000000 00000010 00000004 c67c3474 584b4dcd 00922d4a +00000001 00000002 12345678 00000001 00000000 00000010 00000005 c67c3474 584b4dcd 0017791a +00000001 00000002 12345678 00000001 00000000 00000010 00000006 c67c3474 584b4dcd 000576d7 +00000001 00000002 12345678 00000001 00000000 00000010 00000007 c67c3474 584b4dcd 00074ce3 +00000001 00000002 12345678 00000001 00000000 00000010 00000008 c67c3474 584b4dcd 001f6c66 +00000001 00000002 12345678 00000001 00000000 00000010 00000009 c67c3474 584b4dcd 007b52d9 +00000001 00000002 12345678 00000001 00000000 00000010 0000000a c67c3474 584b4dcd 00470ddb +00000001 00000002 12345678 00000001 00000000 00000010 0000000b c67c3474 584b4dcd 00f9a4c5 +00000001 00000002 12345678 00000001 00000000 00000010 0000000c c67c3474 584b4dcd 00bb6aa1 +00000001 00000002 12345678 00000001 00000000 00000010 0000000d c67c3474 584b4dcd 00e4aadd +00000001 00000002 12345678 00000001 00000000 00000010 0000000e c67c3474 584b4dcd 00bd022b +00000001 00000002 12345678 00000001 00000000 00000010 0000000f c67c3474 584b4dcd 00705acd +00000001 00000002 12345678 00000001 00000000 ffffffff 00000000 c67c3474 584b4dcd 00ce422e +00000001 00000002 12345678 00000001 00000000 ffffffff 00000001 c67c3474 584b4dcd 00b04dcb +00000001 00000002 12345678 00000001 00000000 ffffffff 00000002 c67c3474 584b4dcd 00235a55 +00000001 00000002 12345678 00000001 00000000 ffffffff 00000003 c67c3474 584b4dcd 00b1c745 +00000001 00000002 12345678 00000001 00000000 ffffffff 00000004 c67c3474 584b4dcd 006887d0 +00000001 00000002 12345678 00000001 00000000 ffffffff 00000005 c67c3474 584b4dcd 001f7589 +00000001 00000002 12345678 00000001 00000000 ffffffff 00000006 c67c3474 584b4dcd 001e8fca +00000001 00000002 12345678 00000001 00000000 ffffffff 00000007 c67c3474 584b4dcd 000db4a9 +00000001 00000002 12345678 00000001 00000000 ffffffff 00000008 c67c3474 584b4dcd 0083660e +00000001 00000002 12345678 00000001 00000000 ffffffff 00000009 c67c3474 584b4dcd 006cbefc +00000001 00000002 12345678 00000001 00000000 ffffffff 0000000a c67c3474 584b4dcd 00dd74bd +00000001 00000002 12345678 00000001 00000000 ffffffff 0000000b c67c3474 584b4dcd 00353b17 +00000001 00000002 12345678 00000001 00000000 ffffffff 0000000c c67c3474 584b4dcd 00d162e4 +00000001 00000002 12345678 00000001 00000000 ffffffff 0000000d c67c3474 584b4dcd 002a192f +00000001 00000002 12345678 00000001 00000000 ffffffff 0000000e c67c3474 584b4dcd 006601ca +00000001 00000002 12345678 00000001 00000000 ffffffff 0000000f c67c3474 584b4dcd 008338f5 +00000001 00000002 12345678 00000000 00000001 00000000 00000000 c67c3474 4397fe1f 00562697 +00000001 00000002 12345678 00000000 00000001 00000000 00000001 c67c3474 4397fe1f 00e6b6bf +00000001 00000002 12345678 00000000 00000001 00000000 00000002 c67c3474 4397fe1f 003d9388 +00000001 00000002 12345678 00000000 00000001 00000000 00000003 c67c3474 4397fe1f 00cac33e +00000001 00000002 12345678 00000000 00000001 00000000 00000004 c67c3474 4397fe1f 0052f22e +00000001 00000002 12345678 00000000 00000001 00000000 00000005 c67c3474 4397fe1f 00aeda16 +00000001 00000002 12345678 00000000 00000001 00000000 00000006 c67c3474 4397fe1f 000afbc2 +00000001 00000002 12345678 00000000 00000001 00000000 00000007 c67c3474 4397fe1f 00bdfd52 +00000001 00000002 12345678 00000000 00000001 00000000 00000008 c67c3474 4397fe1f 005c30c6 +00000001 00000002 12345678 00000000 00000001 00000000 00000009 c67c3474 4397fe1f 00da6af3 +00000001 00000002 12345678 00000000 00000001 00000000 0000000a c67c3474 4397fe1f 00265891 +00000001 00000002 12345678 00000000 00000001 00000000 0000000b c67c3474 4397fe1f 00f5e048 +00000001 00000002 12345678 00000000 00000001 00000000 0000000c c67c3474 4397fe1f 005db6c3 +00000001 00000002 12345678 00000000 00000001 00000000 0000000d c67c3474 4397fe1f 0082056e +00000001 00000002 12345678 00000000 00000001 00000000 0000000e c67c3474 4397fe1f 00107f7e +00000001 00000002 12345678 00000000 00000001 00000000 0000000f c67c3474 4397fe1f 0088e970 +00000001 00000002 12345678 00000000 00000001 00000010 00000000 c67c3474 4397fe1f 005f8c6d +00000001 00000002 12345678 00000000 00000001 00000010 00000001 c67c3474 4397fe1f 001802ea +00000001 00000002 12345678 00000000 00000001 00000010 00000002 c67c3474 4397fe1f 00ef2cd7 +00000001 00000002 12345678 00000000 00000001 00000010 00000003 c67c3474 4397fe1f 002d6e7e +00000001 00000002 12345678 00000000 00000001 00000010 00000004 c67c3474 4397fe1f 00d0c9af +00000001 00000002 12345678 00000000 00000001 00000010 00000005 c67c3474 4397fe1f 0066986e +00000001 00000002 12345678 00000000 00000001 00000010 00000006 c67c3474 4397fe1f 0075211c +00000001 00000002 12345678 00000000 00000001 00000010 00000007 c67c3474 4397fe1f 007375aa +00000001 00000002 12345678 00000000 00000001 00000010 00000008 c67c3474 4397fe1f 006dbd88 +00000001 00000002 12345678 00000000 00000001 00000010 00000009 c67c3474 4397fe1f 00199e32 +00000001 00000002 12345678 00000000 00000001 00000010 0000000a c67c3474 4397fe1f 002a8893 +00000001 00000002 12345678 00000000 00000001 00000010 0000000b c67c3474 4397fe1f 00877588 +00000001 00000002 12345678 00000000 00000001 00000010 0000000c c67c3474 4397fe1f 00e9b868 +00000001 00000002 12345678 00000000 00000001 00000010 0000000d c67c3474 4397fe1f 00b001b4 +00000001 00000002 12345678 00000000 00000001 00000010 0000000e c67c3474 4397fe1f 00c1848f +00000001 00000002 12345678 00000000 00000001 00000010 0000000f c67c3474 4397fe1f 0037ee6e +00000001 00000002 12345678 00000000 00000001 ffffffff 00000000 c67c3474 4397fe1f 008bf19c +00000001 00000002 12345678 00000000 00000001 ffffffff 00000001 c67c3474 4397fe1f 00e6b6bf +00000001 00000002 12345678 00000000 00000001 ffffffff 00000002 c67c3474 4397fe1f 007c988e +00000001 00000002 12345678 00000000 00000001 ffffffff 00000003 c67c3474 4397fe1f 00e6cbb6 +00000001 00000002 12345678 00000000 00000001 ffffffff 00000004 c67c3474 4397fe1f 000da76e +00000001 00000002 12345678 00000000 00000001 ffffffff 00000005 c67c3474 4397fe1f 006c1343 +00000001 00000002 12345678 00000000 00000001 ffffffff 00000006 c67c3474 4397fe1f 0065dfca +00000001 00000002 12345678 00000000 00000001 ffffffff 00000007 c67c3474 4397fe1f 0079d7e8 +00000001 00000002 12345678 00000000 00000001 ffffffff 00000008 c67c3474 4397fe1f 00f9606e +00000001 00000002 12345678 00000000 00000001 ffffffff 00000009 c67c3474 4397fe1f 000efcfa +00000001 00000002 12345678 00000000 00000001 ffffffff 0000000a c67c3474 4397fe1f 00a1a8f0 +00000001 00000002 12345678 00000000 00000001 ffffffff 0000000b c67c3474 4397fe1f 006c6183 +00000001 00000002 12345678 00000000 00000001 ffffffff 0000000c c67c3474 4397fe1f 00a276f8 +00000001 00000002 12345678 00000000 00000001 ffffffff 0000000d c67c3474 4397fe1f 004bfe84 +00000001 00000002 12345678 00000000 00000001 ffffffff 0000000e c67c3474 4397fe1f 002058f6 +00000001 00000002 12345678 00000000 00000001 ffffffff 0000000f c67c3474 4397fe1f 00f06400 +00000001 00000002 12345678 00000003 00000007 00000000 00000000 c67c3474 b5a8d1b2 00eb96b6 +00000001 00000002 12345678 00000003 00000007 00000000 00000001 c67c3474 b5a8d1b2 0003f212 +00000001 00000002 12345678 00000003 00000007 00000000 00000002 c67c3474 b5a8d1b2 00984e04 +00000001 00000002 12345678 00000003 00000007 00000000 00000003 c67c3474 b5a8d1b2 004bbc7a +00000001 00000002 12345678 00000003 00000007 00000000 00000004 c67c3474 b5a8d1b2 00acfb72 +00000001 00000002 12345678 00000003 00000007 00000000 00000005 c67c3474 b5a8d1b2 003df33a +00000001 00000002 12345678 00000003 00000007 00000000 00000006 c67c3474 b5a8d1b2 00c0f776 +00000001 00000002 12345678 00000003 00000007 00000000 00000007 c67c3474 b5a8d1b2 0048d668 +00000001 00000002 12345678 00000003 00000007 00000000 00000008 c67c3474 b5a8d1b2 00d20690 +00000001 00000002 12345678 00000003 00000007 00000000 00000009 c67c3474 b5a8d1b2 00159853 +00000001 00000002 12345678 00000003 00000007 00000000 0000000a c67c3474 b5a8d1b2 00beedf3 +00000001 00000002 12345678 00000003 00000007 00000000 0000000b c67c3474 b5a8d1b2 00406b19 +00000001 00000002 12345678 00000003 00000007 00000000 0000000c c67c3474 b5a8d1b2 0082cf95 +00000001 00000002 12345678 00000003 00000007 00000000 0000000d c67c3474 b5a8d1b2 002f3979 +00000001 00000002 12345678 00000003 00000007 00000000 0000000e c67c3474 b5a8d1b2 00f9588f +00000001 00000002 12345678 00000003 00000007 00000000 0000000f c67c3474 b5a8d1b2 0046bb12 +00000001 00000002 12345678 00000003 00000007 00000010 00000000 c67c3474 b5a8d1b2 00e03fdc +00000001 00000002 12345678 00000003 00000007 00000010 00000001 c67c3474 b5a8d1b2 00f7b941 +00000001 00000002 12345678 00000003 00000007 00000010 00000002 c67c3474 b5a8d1b2 005ace1d +00000001 00000002 12345678 00000003 00000007 00000010 00000003 c67c3474 b5a8d1b2 00b87cf6 +00000001 00000002 12345678 00000003 00000007 00000010 00000004 c67c3474 b5a8d1b2 0015534b +00000001 00000002 12345678 00000003 00000007 00000010 00000005 c67c3474 b5a8d1b2 00eb8446 +00000001 00000002 12345678 00000003 00000007 00000010 00000006 c67c3474 b5a8d1b2 0084b83c +00000001 00000002 12345678 00000003 00000007 00000010 00000007 c67c3474 b5a8d1b2 008ef6f8 +00000001 00000002 12345678 00000003 00000007 00000010 00000008 c67c3474 b5a8d1b2 00eb05fc +00000001 00000002 12345678 00000003 00000007 00000010 00000009 c67c3474 b5a8d1b2 00d18bb3 +00000001 00000002 12345678 00000003 00000007 00000010 0000000a c67c3474 b5a8d1b2 00b1f419 +00000001 00000002 12345678 00000003 00000007 00000010 0000000b c67c3474 b5a8d1b2 0023b9a2 +00000001 00000002 12345678 00000003 00000007 00000010 0000000c c67c3474 b5a8d1b2 0006fd8b +00000001 00000002 12345678 00000003 00000007 00000010 0000000d c67c3474 b5a8d1b2 000a84d1 +00000001 00000002 12345678 00000003 00000007 00000010 0000000e c67c3474 b5a8d1b2 002ce588 +00000001 00000002 12345678 00000003 00000007 00000010 0000000f c67c3474 b5a8d1b2 00c804c8 +00000001 00000002 12345678 00000003 00000007 ffffffff 00000000 c67c3474 b5a8d1b2 00285642 +00000001 00000002 12345678 00000003 00000007 ffffffff 00000001 c67c3474 b5a8d1b2 0003f212 +00000001 00000002 12345678 00000003 00000007 ffffffff 00000002 c67c3474 b5a8d1b2 00d8aefe +00000001 00000002 12345678 00000003 00000007 ffffffff 00000003 c67c3474 b5a8d1b2 0067a7ad +00000001 00000002 12345678 00000003 00000007 ffffffff 00000004 c67c3474 b5a8d1b2 00cc8006 +00000001 00000002 12345678 00000003 00000007 ffffffff 00000005 c67c3474 b5a8d1b2 00e60ce9 +00000001 00000002 12345678 00000003 00000007 ffffffff 00000006 c67c3474 b5a8d1b2 009e4030 +00000001 00000002 12345678 00000003 00000007 ffffffff 00000007 c67c3474 b5a8d1b2 0081c02b +00000001 00000002 12345678 00000003 00000007 ffffffff 00000008 c67c3474 b5a8d1b2 007154b7 +00000001 00000002 12345678 00000003 00000007 ffffffff 00000009 c67c3474 b5a8d1b2 00c46c35 +00000001 00000002 12345678 00000003 00000007 ffffffff 0000000a c67c3474 b5a8d1b2 00355ffe +00000001 00000002 12345678 00000003 00000007 ffffffff 0000000b c67c3474 b5a8d1b2 00c5e02e +00000001 00000002 12345678 00000003 00000007 ffffffff 0000000c c67c3474 b5a8d1b2 00671f99 +00000001 00000002 12345678 00000003 00000007 ffffffff 0000000d c67c3474 b5a8d1b2 00f7ceb3 +00000001 00000002 12345678 00000003 00000007 ffffffff 0000000e c67c3474 b5a8d1b2 00ceead8 +00000001 00000002 12345678 00000003 00000007 ffffffff 0000000f c67c3474 b5a8d1b2 000bb99e +00000001 00000002 ffffffff 00000000 00000000 00000000 00000000 54f3aaa8 54f3aaa8 00e9efa6 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000001 54f3aaa8 54f3aaa8 00620825 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000002 54f3aaa8 54f3aaa8 0087ad22 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000003 54f3aaa8 54f3aaa8 003d5a36 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000004 54f3aaa8 54f3aaa8 00a8a162 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000005 54f3aaa8 54f3aaa8 006be274 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000006 54f3aaa8 54f3aaa8 00d3aad3 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000007 54f3aaa8 54f3aaa8 000547bc +00000001 00000002 ffffffff 00000000 00000000 00000000 00000008 54f3aaa8 54f3aaa8 00cd0409 +00000001 00000002 ffffffff 00000000 00000000 00000000 00000009 54f3aaa8 54f3aaa8 0068f30d +00000001 00000002 ffffffff 00000000 00000000 00000000 0000000a 54f3aaa8 54f3aaa8 00bea86b +00000001 00000002 ffffffff 00000000 00000000 00000000 0000000b 54f3aaa8 54f3aaa8 002ef541 +00000001 00000002 ffffffff 00000000 00000000 00000000 0000000c 54f3aaa8 54f3aaa8 00907597 +00000001 00000002 ffffffff 00000000 00000000 00000000 0000000d 54f3aaa8 54f3aaa8 00601ccc +00000001 00000002 ffffffff 00000000 00000000 00000000 0000000e 54f3aaa8 54f3aaa8 00feee05 +00000001 00000002 ffffffff 00000000 00000000 00000000 0000000f 54f3aaa8 54f3aaa8 0014a0e1 +00000001 00000002 ffffffff 00000000 00000000 00000010 00000000 54f3aaa8 54f3aaa8 00e7adca +00000001 00000002 ffffffff 00000000 00000000 00000010 00000001 54f3aaa8 54f3aaa8 00d7d463 +00000001 00000002 ffffffff 00000000 00000000 00000010 00000002 54f3aaa8 54f3aaa8 0032f2ac +00000001 00000002 ffffffff 00000000 00000000 00000010 00000003 54f3aaa8 54f3aaa8 00b214f6 +00000001 00000002 ffffffff 00000000 00000000 00000010 00000004 54f3aaa8 54f3aaa8 0062067b +00000001 00000002 ffffffff 00000000 00000000 00000010 00000005 54f3aaa8 54f3aaa8 00ed16c8 +00000001 00000002 ffffffff 00000000 00000000 00000010 00000006 54f3aaa8 54f3aaa8 00a88643 +00000001 00000002 ffffffff 00000000 00000000 00000010 00000007 54f3aaa8 54f3aaa8 00ab3107 +00000001 00000002 ffffffff 00000000 00000000 00000010 00000008 54f3aaa8 54f3aaa8 00e775fe +00000001 00000002 ffffffff 00000000 00000000 00000010 00000009 54f3aaa8 54f3aaa8 00fcd291 +00000001 00000002 ffffffff 00000000 00000000 00000010 0000000a 54f3aaa8 54f3aaa8 00b7dad2 +00000001 00000002 ffffffff 00000000 00000000 00000010 0000000b 54f3aaa8 54f3aaa8 005b2866 +00000001 00000002 ffffffff 00000000 00000000 00000010 0000000c 54f3aaa8 54f3aaa8 006a4e0a +00000001 00000002 ffffffff 00000000 00000000 00000010 0000000d 54f3aaa8 54f3aaa8 00452866 +00000001 00000002 ffffffff 00000000 00000000 00000010 0000000e 54f3aaa8 54f3aaa8 00651cc5 +00000001 00000002 ffffffff 00000000 00000000 00000010 0000000f 54f3aaa8 54f3aaa8 00d22037 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000000 54f3aaa8 54f3aaa8 006fc6ae +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000001 54f3aaa8 54f3aaa8 00620825 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000002 54f3aaa8 54f3aaa8 00f69e21 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000003 54f3aaa8 54f3aaa8 00028ef1 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000004 54f3aaa8 54f3aaa8 00ea55c3 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000005 54f3aaa8 54f3aaa8 00e738e2 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000006 54f3aaa8 54f3aaa8 00b1abb8 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000007 54f3aaa8 54f3aaa8 00a73d04 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000008 54f3aaa8 54f3aaa8 003c02e4 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 00000009 54f3aaa8 54f3aaa8 00ecf474 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 0000000a 54f3aaa8 54f3aaa8 00530419 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 0000000b 54f3aaa8 54f3aaa8 00e55be2 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 0000000c 54f3aaa8 54f3aaa8 001b4822 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 0000000d 54f3aaa8 54f3aaa8 00f7655c +00000001 00000002 ffffffff 00000000 00000000 ffffffff 0000000e 54f3aaa8 54f3aaa8 00d1bbc3 +00000001 00000002 ffffffff 00000000 00000000 ffffffff 0000000f 54f3aaa8 54f3aaa8 0043ead2 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000000 54f3aaa8 cac4d311 00110233 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000001 54f3aaa8 cac4d311 00d24f8a +00000001 00000002 ffffffff 00000001 00000000 00000000 00000002 54f3aaa8 cac4d311 004d0550 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000003 54f3aaa8 cac4d311 00f99242 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000004 54f3aaa8 cac4d311 002a5143 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000005 54f3aaa8 cac4d311 0086a323 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000006 54f3aaa8 cac4d311 00460c66 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000007 54f3aaa8 cac4d311 0096b84f +00000001 00000002 ffffffff 00000001 00000000 00000000 00000008 54f3aaa8 cac4d311 00088045 +00000001 00000002 ffffffff 00000001 00000000 00000000 00000009 54f3aaa8 cac4d311 00e0df04 +00000001 00000002 ffffffff 00000001 00000000 00000000 0000000a 54f3aaa8 cac4d311 004d5e8c +00000001 00000002 ffffffff 00000001 00000000 00000000 0000000b 54f3aaa8 cac4d311 00cc6483 +00000001 00000002 ffffffff 00000001 00000000 00000000 0000000c 54f3aaa8 cac4d311 0034e37b +00000001 00000002 ffffffff 00000001 00000000 00000000 0000000d 54f3aaa8 cac4d311 00a6cf23 +00000001 00000002 ffffffff 00000001 00000000 00000000 0000000e 54f3aaa8 cac4d311 0045150c +00000001 00000002 ffffffff 00000001 00000000 00000000 0000000f 54f3aaa8 cac4d311 00ad46d6 +00000001 00000002 ffffffff 00000001 00000000 00000010 00000000 54f3aaa8 cac4d311 001b750e +00000001 00000002 ffffffff 00000001 00000000 00000010 00000001 54f3aaa8 cac4d311 007594bd +00000001 00000002 ffffffff 00000001 00000000 00000010 00000002 54f3aaa8 cac4d311 00d53c10 +00000001 00000002 ffffffff 00000001 00000000 00000010 00000003 54f3aaa8 cac4d311 0048abef +00000001 00000002 ffffffff 00000001 00000000 00000010 00000004 54f3aaa8 cac4d311 00e227cc +00000001 00000002 ffffffff 00000001 00000000 00000010 00000005 54f3aaa8 cac4d311 003f3ba9 +00000001 00000002 ffffffff 00000001 00000000 00000010 00000006 54f3aaa8 cac4d311 00219317 +00000001 00000002 ffffffff 00000001 00000000 00000010 00000007 54f3aaa8 cac4d311 002865e0 +00000001 00000002 ffffffff 00000001 00000000 00000010 00000008 54f3aaa8 cac4d311 003efa15 +00000001 00000002 ffffffff 00000001 00000000 00000010 00000009 54f3aaa8 cac4d311 00631d7d +00000001 00000002 ffffffff 00000001 00000000 00000010 0000000a 54f3aaa8 cac4d311 00414231 +00000001 00000002 ffffffff 00000001 00000000 00000010 0000000b 54f3aaa8 cac4d311 008c808a +00000001 00000002 ffffffff 00000001 00000000 00000010 0000000c 54f3aaa8 cac4d311 00d4d6c0 +00000001 00000002 ffffffff 00000001 00000000 00000010 0000000d 54f3aaa8 cac4d311 009b9f11 +00000001 00000002 ffffffff 00000001 00000000 00000010 0000000e 54f3aaa8 cac4d311 00d253b9 +00000001 00000002 ffffffff 00000001 00000000 00000010 0000000f 54f3aaa8 cac4d311 00683432 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000000 54f3aaa8 cac4d311 00a13546 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000001 54f3aaa8 cac4d311 00d24f8a +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000002 54f3aaa8 cac4d311 0000622d +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000003 54f3aaa8 cac4d311 00d702c6 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000004 54f3aaa8 cac4d311 007ca118 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000005 54f3aaa8 cac4d311 003204b5 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000006 54f3aaa8 cac4d311 003d551f +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000007 54f3aaa8 cac4d311 0024de5d +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000008 54f3aaa8 cac4d311 00fca2d3 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 00000009 54f3aaa8 cac4d311 0073565f +00000001 00000002 ffffffff 00000001 00000000 ffffffff 0000000a 54f3aaa8 cac4d311 00b2c72e +00000001 00000002 ffffffff 00000001 00000000 ffffffff 0000000b 54f3aaa8 cac4d311 001de9a8 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 0000000c 54f3aaa8 cac4d311 00ba1f96 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 0000000d 54f3aaa8 cac4d311 000057dd +00000001 00000002 ffffffff 00000001 00000000 ffffffff 0000000e 54f3aaa8 cac4d311 0077b0a2 +00000001 00000002 ffffffff 00000001 00000000 ffffffff 0000000f 54f3aaa8 cac4d311 00f38772 +00000001 00000002 ffffffff 00000000 00000001 00000000 00000000 54f3aaa8 d11860c3 005664d2 +00000001 00000002 ffffffff 00000000 00000001 00000000 00000001 54f3aaa8 d11860c3 00936767 +00000001 00000002 ffffffff 00000000 00000001 00000000 00000002 54f3aaa8 d11860c3 0014c417 +00000001 00000002 ffffffff 00000000 00000001 00000000 00000003 54f3aaa8 d11860c3 00a62c4e +00000001 00000002 ffffffff 00000000 00000001 00000000 00000004 54f3aaa8 d11860c3 0051c988 +00000001 00000002 ffffffff 00000000 00000001 00000000 00000005 54f3aaa8 d11860c3 00c35a0e +00000001 00000002 ffffffff 00000000 00000001 00000000 00000006 54f3aaa8 d11860c3 0024c41e +00000001 00000002 ffffffff 00000000 00000001 00000000 00000007 54f3aaa8 d11860c3 00d5f8af +00000001 00000002 ffffffff 00000000 00000001 00000000 00000008 54f3aaa8 d11860c3 005ef4ab +00000001 00000002 ffffffff 00000000 00000001 00000000 00000009 54f3aaa8 d11860c3 00b0018a +00000001 00000002 ffffffff 00000000 00000001 00000000 0000000a 54f3aaa8 d11860c3 000daf41 +00000001 00000002 ffffffff 00000000 00000001 00000000 0000000b 54f3aaa8 d11860c3 008b3a46 +00000001 00000002 ffffffff 00000000 00000001 00000000 0000000c 54f3aaa8 d11860c3 005ccc42 +00000001 00000002 ffffffff 00000000 00000001 00000000 0000000d 54f3aaa8 d11860c3 00faffe2 +00000001 00000002 ffffffff 00000000 00000001 00000000 0000000e 54f3aaa8 d11860c3 003d0b45 +00000001 00000002 ffffffff 00000000 00000001 00000000 0000000f 54f3aaa8 d11860c3 00f4d219 +00000001 00000002 ffffffff 00000000 00000001 00000010 00000000 54f3aaa8 d11860c3 0059e860 +00000001 00000002 ffffffff 00000000 00000001 00000010 00000001 54f3aaa8 d11860c3 003ae4d4 +00000001 00000002 ffffffff 00000000 00000001 00000010 00000002 54f3aaa8 d11860c3 00920c6b +00000001 00000002 ffffffff 00000000 00000001 00000010 00000003 54f3aaa8 d11860c3 000af2b6 +00000001 00000002 ffffffff 00000000 00000001 00000010 00000004 54f3aaa8 d11860c3 00b47bdc +00000001 00000002 ffffffff 00000000 00000001 00000010 00000005 54f3aaa8 d11860c3 0073a18e +00000001 00000002 ffffffff 00000000 00000001 00000010 00000006 54f3aaa8 d11860c3 006940b7 +00000001 00000002 ffffffff 00000000 00000001 00000010 00000007 54f3aaa8 d11860c3 0062423e +00000001 00000002 ffffffff 00000000 00000001 00000010 00000008 54f3aaa8 d11860c3 007354fb +00000001 00000002 ffffffff 00000000 00000001 00000010 00000009 54f3aaa8 d11860c3 003c1723 +00000001 00000002 ffffffff 00000000 00000001 00000010 0000000a 54f3aaa8 d11860c3 00078a1d +00000001 00000002 ffffffff 00000000 00000001 00000010 0000000b 54f3aaa8 d11860c3 00fe4082 +00000001 00000002 ffffffff 00000000 00000001 00000010 0000000c 54f3aaa8 d11860c3 0096223a +00000001 00000002 ffffffff 00000000 00000001 00000010 0000000d 54f3aaa8 d11860c3 00dcf02c +00000001 00000002 ffffffff 00000000 00000001 00000010 0000000e 54f3aaa8 d11860c3 00a7a6ad +00000001 00000002 ffffffff 00000000 00000001 00000010 0000000f 54f3aaa8 d11860c3 0011e97f +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000000 54f3aaa8 d11860c3 00fb24fe +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000001 54f3aaa8 d11860c3 00936767 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000002 54f3aaa8 d11860c3 00670388 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000003 54f3aaa8 d11860c3 0092ab86 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000004 54f3aaa8 d11860c3 002456a3 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000005 54f3aaa8 d11860c3 0078986f +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000006 54f3aaa8 d11860c3 007d471a +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000007 54f3aaa8 d11860c3 006a5ea5 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000008 54f3aaa8 d11860c3 008a1a64 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 00000009 54f3aaa8 d11860c3 002d798b +00000001 00000002 ffffffff 00000000 00000001 ffffffff 0000000a 54f3aaa8 d11860c3 00c7a2bd +00000001 00000002 ffffffff 00000000 00000001 ffffffff 0000000b 54f3aaa8 d11860c3 007bc070 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 0000000c 54f3aaa8 d11860c3 00c25e16 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 0000000d 54f3aaa8 d11860c3 004fd2a7 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 0000000e 54f3aaa8 d11860c3 000ba4f3 +00000001 00000002 ffffffff 00000000 00000001 ffffffff 0000000f 54f3aaa8 d11860c3 008bf359 +00000001 00000002 ffffffff 00000003 00000007 00000000 00000000 54f3aaa8 27274f6e 0093cc51 +00000001 00000002 ffffffff 00000003 00000007 00000000 00000001 54f3aaa8 27274f6e 0021b091 +00000001 00000002 ffffffff 00000003 00000007 00000000 00000002 54f3aaa8 27274f6e 00e470ef +00000001 00000002 ffffffff 00000003 00000007 00000000 00000003 54f3aaa8 27274f6e 004ba989 +00000001 00000002 ffffffff 00000003 00000007 00000000 00000004 54f3aaa8 27274f6e 00ce58da +00000001 00000002 ffffffff 00000003 00000007 00000000 00000005 54f3aaa8 27274f6e 001fc5f1 +00000001 00000002 ffffffff 00000003 00000007 00000000 00000006 54f3aaa8 27274f6e 00a47d15 +00000001 00000002 ffffffff 00000003 00000007 00000000 00000007 54f3aaa8 27274f6e 004ab5db +00000001 00000002 ffffffff 00000003 00000007 00000000 00000008 54f3aaa8 27274f6e 00b3ee6c +00000001 00000002 ffffffff 00000003 00000007 00000000 00000009 54f3aaa8 27274f6e 00361ee3 +00000001 00000002 ffffffff 00000003 00000007 00000000 0000000a 54f3aaa8 27274f6e 00daa583 +00000001 00000002 ffffffff 00000003 00000007 00000000 0000000b 54f3aaa8 27274f6e 0040f690 +00000001 00000002 ffffffff 00000003 00000007 00000000 0000000c 54f3aaa8 27274f6e 00f1f80e +00000001 00000002 ffffffff 00000003 00000007 00000000 0000000d 54f3aaa8 27274f6e 000c5b2c +00000001 00000002 ffffffff 00000003 00000007 00000000 0000000e 54f3aaa8 27274f6e 008a8973 +00000001 00000002 ffffffff 00000003 00000007 00000000 0000000f 54f3aaa8 27274f6e 00449d7e +00000001 00000002 ffffffff 00000003 00000007 00000010 00000000 54f3aaa8 27274f6e 0098e3f0 +00000001 00000002 ffffffff 00000003 00000007 00000010 00000001 54f3aaa8 27274f6e 00898247 +00000001 00000002 ffffffff 00000003 00000007 00000010 00000002 54f3aaa8 27274f6e 005c2a7c +00000001 00000002 ffffffff 00000003 00000007 00000010 00000003 54f3aaa8 27274f6e 00d02b38 +00000001 00000002 ffffffff 00000003 00000007 00000010 00000004 54f3aaa8 27274f6e 003d8646 +00000001 00000002 ffffffff 00000003 00000007 00000010 00000005 54f3aaa8 27274f6e 009de4aa +00000001 00000002 ffffffff 00000003 00000007 00000010 00000006 54f3aaa8 27274f6e 00f0c7ab +00000001 00000002 ffffffff 00000003 00000007 00000010 00000007 54f3aaa8 27274f6e 00f27ef5 +00000001 00000002 ffffffff 00000003 00000007 00000010 00000008 54f3aaa8 27274f6e 0094cbb2 +00000001 00000002 ffffffff 00000003 00000007 00000010 00000009 54f3aaa8 27274f6e 00b96a8e +00000001 00000002 ffffffff 00000003 00000007 00000010 0000000a 54f3aaa8 27274f6e 00d7a5c1 +00000001 00000002 ffffffff 00000003 00000007 00000010 0000000b 54f3aaa8 27274f6e 000558cf +00000001 00000002 ffffffff 00000003 00000007 00000010 0000000c 54f3aaa8 27274f6e 00294016 +00000001 00000002 ffffffff 00000003 00000007 00000010 0000000d 54f3aaa8 27274f6e 002b7abf +00000001 00000002 ffffffff 00000003 00000007 00000010 0000000e 54f3aaa8 27274f6e 0006be08 +00000001 00000002 ffffffff 00000003 00000007 00000010 0000000f 54f3aaa8 27274f6e 00a1f91b +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000000 54f3aaa8 27274f6e 00029255 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000001 54f3aaa8 27274f6e 0021b091 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000002 54f3aaa8 27274f6e 00be6cac +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000003 54f3aaa8 27274f6e 00727e18 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000004 54f3aaa8 27274f6e 00ab7a94 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000005 54f3aaa8 27274f6e 009457de +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000006 54f3aaa8 27274f6e 00e69a82 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000007 54f3aaa8 27274f6e 00fddb40 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000008 54f3aaa8 27274f6e 00692570 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 00000009 54f3aaa8 27274f6e 00ac20f6 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 0000000a 54f3aaa8 27274f6e 001bb4cd +00000001 00000002 ffffffff 00000003 00000007 ffffffff 0000000b 54f3aaa8 27274f6e 00af6ad5 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 0000000c 54f3aaa8 27274f6e 0078b4d7 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 0000000d 54f3aaa8 27274f6e 008d62ba +00000001 00000002 ffffffff 00000003 00000007 ffffffff 0000000e 54f3aaa8 27274f6e 00ac3665 +00000001 00000002 ffffffff 00000003 00000007 ffffffff 0000000f 54f3aaa8 27274f6e 002d73c3 diff --git a/devices/rtx/apps/tests/unit/sobol/seed_reference.py b/devices/rtx/apps/tests/unit/sobol/seed_reference.py new file mode 100644 index 000000000..fae5f1e57 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/seed_reference.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Offline pixel/depth vectors from Joe-Kuo parameters and uint32 arithmetic. + +No production headers are read. FastOwen follows the pinned pbrt excerpt in +this directory; see README.md / LICENSE.pbrt and LICENSE.joe-kuo. +""" +from pathlib import Path + +here = Path(__file__).parent +mask = (1 << 32) - 1 +columns = [[1 << (31 - i) for i in range(32)]] +for line in (here / "joe-kuo.txt").read_text().splitlines()[4:]: + d, degree, a, *m = map(int, line.split()) + assert d == len(columns) + 1 + row = [n << (31 - i) for i, n in enumerate(m)] + for i in range(degree, 32): + value = row[i-degree] ^ (row[i-degree] >> degree) + for k in range(1, degree): + if a & (1 << (degree-1-k)): + value ^= row[i-k] + row.append(value) + columns.append(row) + + +def finalizer(value): + value ^= value >> 16 + value = value * 0x7feb352d & mask + value ^= value >> 15 + value = value * 0x846ca68b & mask + return value ^ (value >> 16) + + +def reverse(value): + return int(f"{value:032b}"[::-1], 2) + + +def scramble(value, seed): + value = reverse(value) + value ^= value * 0x3d20adea & mask + value = (value + seed) & mask + value = value * ((seed >> 16) | 1) & mask + value ^= value * 0x05526c56 & mask + value ^= value * 0x53a22864 & mask + return reverse(value) + + +text = "# Offline Joe-Kuo / pinned pbrt FastOwen vectors; see README.md.\n" +text += "# x y scrambleSeed bounce transparency index dimension pixelKey vertexKey grid24\n" +x, y = 1, 2 +for seed in [0, 1, 0x12345678, mask]: + pixel = finalizer((x + y * 0x9e3779b9 + 0xb5297a4d) & mask) ^ finalizer(seed) + for bounce, transparency in [(0, 0), (1, 0), (0, 1), (3, 7)]: + vertex = pixel ^ (bounce * 0x9e3779b9 & mask) ^ (transparency * 0x85ebca6b & mask) + for index in [0, 16, mask]: + for d, row in enumerate(columns): + raw = 0 + for bit, column in enumerate(row): + if index & (1 << bit): + raw ^= column + grid = scramble(raw, vertex ^ ((d + 1) * 0x9e3779b9 & mask)) >> 8 + text += " ".join(f"{v:08x}" for v in + [x, y, seed, bounce, transparency, index, d, pixel, vertex, grid]) + "\n" +(here / "seed-vectors.txt").write_text(text) diff --git a/devices/rtx/apps/tests/unit/sobol/testSobol.h b/devices/rtx/apps/tests/unit/sobol/testSobol.h index 0a9a877c9..87ce0e149 100644 --- a/devices/rtx/apps/tests/unit/sobol/testSobol.h +++ b/devices/rtx/apps/tests/unit/sobol/testSobol.h @@ -88,7 +88,7 @@ static Columns referenceColumns() struct Input { uint32_t index, dimension, seed; - uint32_t x = 0, y = 0; + uint32_t x = 0, y = 0, scrambleSeed = 0; int bounce = 0, transparency = 0; bool pixelSeedInput = false; }; @@ -107,7 +107,7 @@ struct Output VISRTX_HOST_DEVICE Output evaluate(Input in) { const auto pixelKey = in.pixelSeedInput - ? visrtx::owenPixelSeed(in.x, in.y) + ? visrtx::owenPixelSeed(in.x, in.y, in.scrambleSeed) : in.seed; const auto vertexKey = visrtx::owenBounceSeed(pixelKey, in.bounce, in.transparency); @@ -254,8 +254,76 @@ static void checkDevice(const std::vector &inputs) } #endif +static void checkPixelKeys() +{ + // Worked uint32 finalizer vectors, independent of production evaluation. + struct Pixel + { + uint32_t x, y; + std::array keys; + }; + const Pixel pixels[] = { + {0, 0, {0xf1a85082u, 0x9921c042u, 0x044f4c14u, 0x96c0d2c8u}}, + {1, 2, {0x339b28e2u, 0x5b12b822u, 0xc67c3474u, 0x54f3aaa8u}}, + {1920, 1080, {0xeebd993au, 0x863409fau, 0x1b5a85acu, 0x89d51b70u}}, + {0xffffffffu, + 0xffffffffu, + {0x4ab06c79u, 0x2239fcb9u, 0xbf5770efu, 0x2dd8ee33u}}}; + const uint32_t seeds[] = {0, 1, 0x12345678u, 0xffffffffu}; + for (const auto &pixel : pixels) { + require(visrtx::owenPixelSeed(pixel.x, pixel.y) == pixel.keys[0], + "default pixel key preserves legacy vector"); + for (unsigned s = 0; s < 4; ++s) { + require( + visrtx::owenPixelSeed(pixel.x, pixel.y, seeds[s]) == pixel.keys[s], + "explicit scramble seed pixel-key vector"); + require( + visrtx::owenPixelSeed(pixel.x, pixel.y, seeds[s]) == pixel.keys[s], + "repeated scramble seed reproduces pixel key"); + } + } +} + +static void checkSeedVectors(std::vector &inputs) +{ + std::ifstream vectors(SOBOL_SEED_VECTOR_FILE); + require(bool(vectors), "cannot open pixel/depth vectors"); + std::string line; + std::getline(vectors, line); + std::getline(vectors, line); + Input in{}; + in.pixelSeedInput = true; + uint32_t pixel, vertex, grid; + unsigned count = 0; + while (vectors >> std::hex >> in.x >> in.y >> in.scrambleSeed >> in.bounce + >> in.transparency >> in.index >> in.dimension >> pixel >> vertex + >> grid) { + const auto actual = evaluate(in); + require(actual.pixelKey == pixel && actual.vertexKey == vertex, + "fixed pixel/bounce/coverage key vector " + std::to_string(count)); + require(sameFloat(actual.sample, std::ldexp(float(grid), -24)), + "fixed controlled-scramble sample vector " + std::to_string(count)); + require(sameFloat(evaluate(in).sample, actual.sample), + "repeated controlled scramble reproduces sample"); + inputs.push_back(in); + ++count; + } + require(vectors.eof() && count == 768, "incomplete pixel/depth vectors"); + // Only selected vectors must change, not every float or arbitrary depth + // tuple. + for (uint32_t seed : {1u, 0x12345678u, 0xffffffffu}) { + const auto base = visrtx::owenSobolHemi(16, visrtx::owenPixelSeed(1, 2)); + const auto alternate = + visrtx::owenSobolHemi(16, visrtx::owenPixelSeed(1, 2, seed)); + require(!sameFloat(base.x, alternate.x) || !sameFloat(base.y, alternate.y), + "selected alternate scramble changes transport vector"); + } + std::cout << count << " fixed pixel/depth sampler vectors pass\n"; +} + inline int run() try { + checkPixelKeys(); // Direct endpoints exercise production conversion, not accidental samples. require(visrtx::sobolFloat(0) == 0.f && visrtx::sobolFloat(0xffu) == 0.f && visrtx::sobolFloat(0x100u) == 0x1p-24f @@ -335,6 +403,7 @@ try { } } } + checkSeedVectors(inputs); for (uint32_t endpoint : {0u, 0xffu, 0x100u, 0xffffffffu}) inputs.push_back({endpoint, 0, 0}); #ifdef SOBOL_CUDA diff --git a/devices/rtx/device/gpu/owenSobol.h b/devices/rtx/device/gpu/owenSobol.h index 3a2dbf291..122bf00b9 100644 --- a/devices/rtx/device/gpu/owenSobol.h +++ b/devices/rtx/device/gpu/owenSobol.h @@ -117,10 +117,11 @@ VISRTX_HOST_DEVICE uint32_t sobolUInt(uint32_t index, uint32_t dimension) return x; } -VISRTX_HOST_DEVICE uint32_t owenPixelSeed(uint32_t x, uint32_t y) +namespace detail { +// Bijective on uint32: XOR-right-shifts are invertible bit by bit, and odd +// multipliers have inverses modulo 2^32. Each operation fixes zero, so M(0)=0. +VISRTX_HOST_DEVICE uint32_t owenSeedFinalizer(uint32_t v) { - // Preserve the legacy Halton pixel hash, now seeding Owen rather than index. - uint32_t v = x + y * 0x9E3779B9u + 0xB5297A4Du; v ^= v >> 16; v *= 0x7feb352du; v ^= v >> 15; @@ -128,6 +129,20 @@ VISRTX_HOST_DEVICE uint32_t owenPixelSeed(uint32_t x, uint32_t y) v ^= v >> 16; return v; } +} // namespace detail + +VISRTX_HOST_DEVICE uint32_t owenPixelSeed( + uint32_t x, uint32_t y, uint32_t scrambleSeed = 0) +{ + // Legacy Halton pixel hash, now seeding Owen rather than the index. Zero + // preserves pixel keys, not old images after table/addressing fixes. + // Distinct seeds at a fixed pixel give distinct keys, not independent floats. + // Renderer callers keep the default: full-render replicate/PCG/reset policy + // remains deferred; this is only reproducible internal sampler control. + const uint32_t legacy = + detail::owenSeedFinalizer(x + y * 0x9E3779B9u + 0xB5297A4Du); + return legacy ^ detail::owenSeedFinalizer(scrambleSeed); +} // Bounce 0 / no alpha pass-through keeps the transport pixel seed (XOR 0). // Later bounces and coverage-continue vertices reseed so dims 0–11 can be From 404fcde05a7320118d8bc86f1dea495fef34a431 Mon Sep 17 00:00:00 2001 From: Thomas Arcila <134677+tarcila@users.noreply.github.com> Date: Tue, 10 Nov 2026 02:14:16 +0000 Subject: [PATCH 6/6] docs(rtx): explain hybrid sampling policy Describe the Halton camera, bounded Sobol surface transport and PCG fallback roles, their contracts, reference provenance and test commands. Keep development logs and historical audit records out of shipped docs. --- devices/rtx/apps/tests/unit/sobol/README.md | 204 ++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 devices/rtx/apps/tests/unit/sobol/README.md diff --git a/devices/rtx/apps/tests/unit/sobol/README.md b/devices/rtx/apps/tests/unit/sobol/README.md new file mode 100644 index 000000000..541a2d088 --- /dev/null +++ b/devices/rtx/apps/tests/unit/sobol/README.md @@ -0,0 +1,204 @@ +# Camera and transport sampling + +VisRTX uses a bounded hybrid: **Halton for the camera, Sobol for fixed-size +surface transport decisions, and PCG for variable-length or fallback work**. +The purpose is predictable sample addressing and low-discrepancy surface +sampling without forcing variable-length tracking loops into a fixed dimension +budget. No universal convergence improvement or statistical independence of +hashed streams is claimed. + +## Camera: Halton + +Pixel jitter uses bases 2/3 and aperture uses bases 5/7. The camera index is the +completed-sample ordinal plus a per-pixel hash, with uint32 wrapping. Camera and +transport share an ordinal but not their sampling sequence or dimension space. + +Both progressive raygen loops use `completedSamples + iteration`; the frame +counter already counts samples, not launches. Positive `pixelSamples` therefore +uses a contiguous prefix across batches. Checkerboarding uses effective spp=1 +and advances the ordinal once per four-tile cycle. The existing signed frame +counter must not overflow; this is not an unlimited accumulation contract. + +The first accumulated sample centers pixel jitter but still samples aperture. +Ray-buffer cameras bypass jitter and aperture. These are per-pixel integration +samples, not frame-wide reconstruction jitter or temporal-upscaler inputs. +Changing batching does not promise byte-identical general rendered images: +PCG initialization and floating-point accumulation can also affect results. + +## Surface transport: Sobol + +Quality uses the binary sample ordinal with pbrt-style **FastOwenScrambler**. +This is a hash-based fast approximation, not pbrt's separate OwenScrambler or a +proof of independent nested random permutations. A pixel key is mixed with +bounce and cumulative transparency depth before each surface vertex's draws. + +| Sobol dimensions (zero-based) | Role | +| --- | --- | +| 0–1 | Ambient hemisphere and HDRI cosine strategy | +| 2–3 | Analytic-light coordinates or HDRI CDF row/column | +| 4–5 | HDRI within-texel jitter | +| 6–7 | Light category and instance selection | +| 8–11 | First four sequential material requests | + +The raw table supports 16 dimensions; 12–15 are unassigned capacity, not camera +reservations. Distinct dimensions or keys do not prove independence. Ambient +and HDRI cosine terms can intentionally use the same direction at a vertex; +that correlates their estimates but does not by itself establish biased MIS. +The 32-bit depth-key mixer does not promise collision-free arbitrary tuples. + +`sobolUInt` evaluates the binary index directly, not a Gray-code iterator index. +The float conversion is exactly `(scrambled >> 8) * 2^-24`: a 24-bit grid in +`[0,1)`, including zero and excluding one. There is no global clamp or implicit +open-interval conversion for exponential sampling. + +`owenPixelSeed` accepts an internal optional scramble seed. Zero preserves the +pixel-key hash; nonzero seeds provide reproducible sampler experiments. Renderer +callers use zero. This is not public full-render replicate control: that would +also need a PCG policy and accumulation-reset semantics. + +## PCG and material consumption + +Volume free flights, volume light/phase sampling, ratio-tracking shadows, +geometry-light coordinates, surface roulette and coverage rejection remain on +PCG. Interactive's material and light paths retain their PCG defaults. + +`NextRayQmc` supplies up to four uniforms. Native material lobe choices consume +this same branch-dependent sequence; it is not a fixed semantic role assignment +across every material configuration. Draws are ordered and remain inside their +original branches and early exits. A fifth request falls back to PCG. + +A non-null overlay requires signed `0 <= n <= 4` and `0 <= cursor <= n`. +Supplied requests advance the cursor without touching PCG. Exhausted requests +advance PCG once and leave the cursor at n. A null overlay requires cursor=0, +advances PCG once per request and leaves the cursor unchanged. PCG state must be +valid whenever fallback is reached. Unsupported dimensions and invalid overlay +bounds abort on the host or trap on CUDA, including NDEBUG builds; this is a +programmer-error contract, not a recoverable frame-failure mechanism. + +## Shared implementation and test coverage + +Native continuation sampling and its required pure helpers live in +`material/shaders/physicallyBasedSampling.h`. The OptiX callable delegates to +`samplePhysicallyBased`; the host branch tests call that same implementation. +The existing PDF helper is shared with sampling, while parameter initialization, +texture/normal-map access and the NEE evaluation callable remain in the shader. +Shared basis/hemisphere math lives in `gpu/samplingMath.h`. + +MDL assigns `sample_data.xi` using `materialUniform4` in `gpu/shadingState.h`. +This helper orders four fixed component requests; native PBR does not eagerly +use it because its draw consumption depends on branches and early exits. +No C++ source-text extraction or generated shader-expression header is used. +The shared functions compile as host inline functions with the C++ compiler and +as device functions with NVCC through the existing `VISRTX_DEVICE` macro. +The tests still require CUDA/OptiX headers; host-compilable does not mean +CUDA-toolkit-free. + +| Test | Observable contract | +| --- | --- | +| `rtx::Sobol`, `rtx::SobolCUDA` | Independent direction recurrence, integer/grid vectors, dyadic 1D strata, seed vectors, Halton rational reference, host/device behavior | +| `rtx::SobolTableHeader` | Offline complete-header byte identity, including notices and guard | +| `rtx::SobolReferencePublication` | Validation, input-read and staging failures preserve existing fixtures | +| `rtx::SamplerContractsAssert`, `rtx::SamplerContractsNDEBUG` | Complete valid/invalid overlay matrix, exact PCG state and host SIGABRT | +| `rtx::SamplerContractsCUDAAssert`, `rtx::SamplerContractsCUDANDEBUG` | Same production contracts and isolated device failure outcomes | +| `rtx::DrawOrder` | Native directions, branch-local fallback consumption, early exits, and ordered full/mixed MDL components through shared functions | +| `rtx::LightDrawOrder` | Real rectangle/HDRI/hemisphere sampling and PCG consumption on CUDA | +| `rtx::SampleOrdinal`, `TestSampleAddressing` | Ordinal prefix, batching/reset/checkerboarding and actual camera mapping, including perspective aperture | +| `TestMaterialSampling` | Quality/Interactive callable integration for Matte, native PBR and available MDL materials | + +The exhaustive n/cursor matrix belongs in SamplerContracts, not each material +test. Light ordering is tested through the real CUDA samplers rather than +repeated host-extracted coordinate expressions. This does not independently +qualify those light expressions under a second compiler. Native host tests use +asymmetric supplied values and independent analytic directions; CUDA builds and +API tests remain necessary to verify device compilation and callable wiring. + +The negative-process harness is UNIX-only. Each CUDA child first establishes a +successful ordinary launch, then requires an assert/illegal-instruction/launch- +failure synchronization error and normal expected-error exit. Unrelated errors, +crashes and timeouts fail. Each child owns a disposable context; none is reused +after a trap. This is not Windows failure-policy qualification. + +## Reference provenance + +- [pbrt-v4 direction matrices](https://github.com/mmp/pbrt-v4/blob/b0bdf461ba5dd6504b70ebf0932acc0fe7aa744f/src/pbrt/util/sobolmatrices.cpp): + rows 0..15 and columns 0..31, with source row stride **52**. +- [Joe–Kuo primitive parameters](https://github.com/joe-kuo/sobol_data/blob/835a7d7b1ee3bc83e575e302a985c66ec4b65249/new-joe-kuo-6.21201): + the unchanged header and one-based dimension rows 2..16, with attribution. +- [pbrt-v4 FastOwenScrambler](https://github.com/mmp/pbrt-v4/blob/b0bdf461ba5dd6504b70ebf0932acc0fe7aa744f/src/pbrt/util/lowdiscrepancy.h): + retained integer operations and a vendored reference excerpt. + +`LICENSE.pbrt`, `LICENSE.joe-kuo` and `NOTICE` retain source attribution and are +installed for binary distributions even when tests are disabled. There is no +pbrt runtime dependency and ordinary tests need no reference downloads. + +SHA-256 digests: + +- Table: exactly 512 dimension-major/column-minor uint32 words serialized + little-endian, without header: + `357f257f40c9f9b7efb784bdf355b543f456984987e8519686fc978cf319be96`. +- Exact attributed parameter fixture bytes: + `d155655216d8f60bac3d2b34f2926cf03b64e288c7df74d6c25c13cccce3b26f`. +- `vectors.txt`: + `a25db35646e5f5efc17500bff4f6d957102d2c5ea78cd3baee8813919eb779f9`. + +The parameter oracle regenerates columns independently of production data. +Dimension zero uses `1u << (31-i)`; other rows use their primitive-polynomial +recurrence. Raw Sobol tests use binary indexing. Halton expectations use integer +digit reversal and a double rational division, allowing absolute error `2^-21` +for float reciprocal/FMA differences; Halton CPU/CUDA bit identity is not +required. Sobol integer/grid comparisons require exact agreement. + +## Regeneration + +Download pinned inputs independently, then invoke the generator from the +workspace root. Source hashes are verified before processing: + +```sh +pbrt=b0bdf461ba5dd6504b70ebf0932acc0fe7aa744f +joe=835a7d7b1ee3bc83e575e302a985c66ec4b65249 +curl -fL https://raw.githubusercontent.com/mmp/pbrt-v4/$pbrt/src/pbrt/util/sobolmatrices.cpp -o /tmp/sobol-matrices.cpp +curl -fL https://raw.githubusercontent.com/mmp/pbrt-v4/$pbrt/src/pbrt/util/lowdiscrepancy.h -o /tmp/sobol-lowdiscrepancy.h +curl -fL https://raw.githubusercontent.com/mmp/pbrt-v4/$pbrt/LICENSE.txt -o /tmp/sobol-pbrt-license +curl -fL https://raw.githubusercontent.com/joe-kuo/sobol_data/$joe/new-joe-kuo-6.21201 -o /tmp/sobol-parameters +curl -fL https://raw.githubusercontent.com/joe-kuo/sobol_data/$joe/LICENSE -o /tmp/sobol-joe-license +python3 -B devices/rtx/apps/tests/unit/sobol/reference.py \ + /tmp/sobol-matrices.cpp /tmp/sobol-parameters \ + --fast-owen-source /tmp/sobol-lowdiscrepancy.h \ + --pbrt-license /tmp/sobol-pbrt-license --joe-license /tmp/sobol-joe-license \ + --table devices/rtx/device/gpu/sobolDirections.h +python3 -B devices/rtx/apps/tests/unit/sobol/seed_reference.py +``` + +Regeneration prepares all requested outputs and checks oracle agreement before +publishing any files. It stages all outputs before atomic per-file replacements, +preserving existing files on validation, input-read or staging failure. This is +not a multi-file filesystem transaction: a replacement failure midway through +publication can still require recovery. A disagreement must be investigated, +not resolved by modifying the oracle to match production. + +## Running the tests + +Enable `VISRTX_BUILD_TESTS=ON`; Python 3 is required for offline fixture tests. +Use native-PBR and MDL-backed-PBR configurations, rebuild affected PTX, and +ensure the tests load that build's device library rather than an installed copy. +For a single-config native build, for example: + +```sh +cmake -S . -B _out/native -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DVISRTX_BUILD_GL_DEVICE=OFF -DVISRTX_BUILD_TESTS=ON \ + -DVISRTX_ENABLE_MDL_SUPPORT=OFF +cmake --build _out/native --parallel +LD_LIBRARY_PATH="$PWD/_out/native:${LD_LIBRARY_PATH:-}" \ + ctest --test-dir _out/native --output-on-failure \ + -R '^(rtx::(Sobol.*|SamplerContracts.*|DrawOrder|LightDrawOrder|SampleOrdinal)|TestSampleAddressing|TestMaterialSampling)$' +``` + +For MDL-backed PBR enable both `VISRTX_ENABLE_MDL_SUPPORT` and +`VISRTX_USE_MDL_FOR_PHYSICALLY_BASED`, then also run `TestEmissiveMaterialParity`. +For multi-config builds select the configuration with `--config` / `ctest -C` +and put that configuration's library directory on the loader path. + +These are correctness and integration checks, not convergence/timing claims. +Variable-length volume sampling, geometry-light QMC, public replicate controls, +non-positive pixelSamples, CDF zero-mass ties and signed frame-counter overflow +are outside this implementation's guarantees.