From 7d188bd84a35f0db4e8fdc40c062e61134683e0b Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 25 Jan 2022 13:32:24 -0800 Subject: [PATCH 001/149] SphericalTriangleArea(): use [Van Oosterom and Strackee 1983] --- src/pbrt/util/vecmath.h | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/pbrt/util/vecmath.h b/src/pbrt/util/vecmath.h index eeb74903b..60f691dbc 100644 --- a/src/pbrt/util/vecmath.h +++ b/src/pbrt/util/vecmath.h @@ -1636,20 +1636,8 @@ PBRT_CPU_GPU inline Bounds2 Union(const Bounds2 &b, Point2 p) { // Spherical Geometry Inline Functions PBRT_CPU_GPU inline Float SphericalTriangleArea(Vector3f a, Vector3f b, Vector3f c) { - // Compute normalized cross products of all direction pairs - Vector3f n_ab = Cross(a, b), n_bc = Cross(b, c), n_ca = Cross(c, a); - if (LengthSquared(n_ab) == 0 || LengthSquared(n_bc) == 0 || LengthSquared(n_ca) == 0) - return {}; - n_ab = Normalize(n_ab); - n_bc = Normalize(n_bc); - n_ca = Normalize(n_ca); - - // Find angles $\alpha$, $\beta$, and $\gamma$ at spherical triangle vertices - Float alpha = AngleBetween(n_ab, -n_ca); - Float beta = AngleBetween(n_bc, -n_ab); - Float gamma = AngleBetween(n_ca, -n_bc); - - return std::abs(alpha + beta + gamma - Pi); + return std::abs( + 2 * std::atan2(Dot(a, Cross(b, c)), 1 + Dot(a, b) + Dot(a, c) + Dot(b, c))); } PBRT_CPU_GPU inline Float SphericalQuadArea(Vector3f a, Vector3f b, Vector3f c, From 06d697f10c9ecd7ca93d03fca7177f94ab9b3bc7 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 25 Jan 2022 13:33:43 -0800 Subject: [PATCH 002/149] Simplified computation of BVH SAH costs Via issue #223, with thanks to @adruomnfd. --- src/pbrt/cpu/aggregates.cpp | 39 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/pbrt/cpu/aggregates.cpp b/src/pbrt/cpu/aggregates.cpp index f7e4a44c5..a1d0621d2 100644 --- a/src/pbrt/cpu/aggregates.cpp +++ b/src/pbrt/cpu/aggregates.cpp @@ -290,24 +290,23 @@ BVHBuildNode *BVHAggregate::buildRecursive(ThreadLocal &threadAllocat // Compute costs for splitting after each bucket constexpr int nSplits = nBuckets - 1; - int countBelow[nSplits], countAbove[nSplits]; - Bounds3f boundsBelow[nSplits], boundsAbove[nSplits]; - // Initialize _countBelow_ and _boundsBelow_ using a forward scan over - // splits - countBelow[0] = buckets[0].count; - boundsBelow[0] = buckets[0].bounds; - for (int i = 1; i < nSplits; ++i) { - countBelow[i] = countBelow[i - 1] + buckets[i].count; - boundsBelow[i] = Union(boundsBelow[i - 1], buckets[i].bounds); + float costs[nSplits] = {}; + // Partially initialize _costs_ using a forward scan over splits + int countBelow = 0; + Bounds3f boundBelow; + for (int i = 0; i < nSplits; ++i) { + boundBelow = Union(boundBelow, buckets[i].bounds); + countBelow += buckets[i].count; + costs[i] += countBelow * boundBelow.SurfaceArea(); } - // Initialize _countAbove_ and _boundsAbove_ using a backwards scan - // over splits - countAbove[nSplits - 1] = buckets[nBuckets - 1].count; - boundsAbove[nSplits - 1] = buckets[nBuckets - 1].bounds; - for (int i = nSplits - 2; i >= 0; --i) { - countAbove[i] = countAbove[i + 1] + buckets[i + 1].count; - boundsAbove[i] = Union(boundsAbove[i + 1], buckets[i + 1].bounds); + // Finish initializing _costs_ using a backwards scan over splits + int countAbove = 0; + Bounds3f boundAbove; + for (int i = nSplits; i >= 1; --i) { + boundAbove = Union(boundAbove, buckets[i].bounds); + countAbove += buckets[i].count; + costs[i - 1] += countAbove * boundAbove.SurfaceArea(); } // Find bucket to split at that minimizes SAH metric @@ -316,12 +315,8 @@ BVHBuildNode *BVHAggregate::buildRecursive(ThreadLocal &threadAllocat for (int i = 0; i < nSplits; ++i) { // Compute cost for candidate split and update minimum if // necessary - if (countBelow[i] == 0 || countAbove[i] == 0) - continue; - Float cost = (countBelow[i] * boundsBelow[i].SurfaceArea() + - countAbove[i] * boundsAbove[i].SurfaceArea()); - if (cost < minCost) { - minCost = cost; + if (costs[i] < minCost) { + minCost = costs[i]; minCostSplitBucket = i; } } From abf5f0a75188331530ee072bf44060e6e4c01a96 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 27 Jan 2022 10:52:29 -0800 Subject: [PATCH 003/149] Improve assorted Material::ToString() methods - normalMap was missing from most of them - DiffuseTransmission was missing "scale" - CoatedConductor was using %f, not %s for printing *Textures. - etc. --- src/pbrt/materials.cpp | 69 +++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index 484930989..be6765bfd 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -41,9 +41,10 @@ std::string NormalBumpEvalContext::ToString() const { // DielectricMaterial Method Definitions std::string DielectricMaterial::ToString() const { - return StringPrintf("[ DielectricMaterial displacement: %s uRoughness: %s " + return StringPrintf("[ DielectricMaterial displacement: %s normalMap: %s uRoughness: %s " "vRoughness: %s eta: %s remapRoughness: %s ]", - displacement, uRoughness, vRoughness, eta, remapRoughness); + displacement, normalMap ? normalMap->ToString() : std::string("(nullptr)"), + uRoughness, vRoughness, eta, remapRoughness); } DielectricMaterial *DielectricMaterial::Create( @@ -73,8 +74,9 @@ DielectricMaterial *DielectricMaterial::Create( // ThinDielectricMaterial Method Definitions std::string ThinDielectricMaterial::ToString() const { - return StringPrintf("[ ThinDielectricMaterial displacement: %s eta: %s ]", - displacement, eta); + return StringPrintf("[ ThinDielectricMaterial displacement: %s normalMap: %s eta: %s ]", + displacement, normalMap ? normalMap->ToString() + : std::string("(nullptr)"), eta); } ThinDielectricMaterial *ThinDielectricMaterial::Create( @@ -180,8 +182,10 @@ HairMaterial *HairMaterial::Create(const TextureParameterDictionary ¶meters, // DiffuseMaterial Method Definitions std::string DiffuseMaterial::ToString() const { - return StringPrintf("[ DiffuseMaterial displacement: %s reflectance: %s ]", - displacement, reflectance); + return StringPrintf("[ DiffuseMaterial displacement: %s normapMap: %s reflectance: %s ]", + displacement, + normalMap ? normalMap->ToString() : std::string("(nullptr)"), + reflectance); } DiffuseMaterial *DiffuseMaterial::Create(const TextureParameterDictionary ¶meters, @@ -199,11 +203,12 @@ DiffuseMaterial *DiffuseMaterial::Create(const TextureParameterDictionary ¶m // ConductorMaterial Method Definitions std::string ConductorMaterial::ToString() const { - return StringPrintf("[ ConductorMaterial displacement: %s eta: %s k: %s reflectance: " - "%s uRoughness: %s " - "vRoughness: %s remapRoughness: %s]", - displacement, eta, k, reflectance, uRoughness, vRoughness, - remapRoughness); + return StringPrintf("[ ConductorMaterial displacement: %s normalMap: %s eta: %s " + "k: %s reflectance: %s uRoughness: %s vRoughness: %s " + "remapRoughness: %s ]", + displacement, + normalMap ? normalMap->ToString() : std::string("(nullptr)"), + eta, k, reflectance, uRoughness, vRoughness, remapRoughness); } ConductorMaterial *ConductorMaterial::Create(const TextureParameterDictionary ¶meters, @@ -284,10 +289,11 @@ template CoatedDiffuseBxDF CoatedDiffuseMaterial::GetBxDF( std::string CoatedDiffuseMaterial::ToString() const { return StringPrintf( - "[ CoatedDiffuseMaterial displacement: %s reflectance: %s uRoughness: %s " - "vRoughness: %s thickness: %s eta: %s remapRoughness: %s ]", - displacement, reflectance, uRoughness, vRoughness, thickness, eta, - remapRoughness); + "[ CoatedDiffuseMaterial displacement: %s normalMap: %s reflectance: %s " + "uRoughness: %s vRoughness: %s thickness: %s eta: %s remapRoughness: %s ]", + displacement, + normalMap ? normalMap->ToString() : std::string("(nullptr)"), + reflectance, uRoughness, vRoughness, thickness, eta, remapRoughness); } CoatedDiffuseMaterial *CoatedDiffuseMaterial::Create( @@ -389,13 +395,14 @@ template CoatedConductorBxDF CoatedConductorMaterial::GetBxDF( SampledWavelengths &lambda) const; std::string CoatedConductorMaterial::ToString() const { - return StringPrintf("[ CoatedConductorMaterial displacement: %f interfaceURoughness: " - "%f interfaceVRoughness: %f thickness: %f " - "interfaceEta: %f g: %s albedo: %s conductorURoughness: %s " - "conductorVRoughness: %s " - "conductorEta: %s k: %s conductorReflectance: %s remapRoughness: " - "%s maxDepth: %d nSamples: %d ]", - displacement, interfaceURoughness, interfaceVRoughness, thickness, + return StringPrintf("[ CoatedConductorMaterial displacement: %s normalMap: %s " + "interfaceURoughness: %s interfaceVRoughness: %s thickness: %s " + "interfaceEta: %s g: %s albedo: %s conductorURoughness: %s " + "conductorVRoughness: %s conductorEta: %s k: %s " + "conductorReflectance: %s remapRoughness: %s maxDepth: %d nSamples: %d ]", + displacement, + normalMap ? normalMap->ToString() : std::string("(nullptr)"), + interfaceURoughness, interfaceVRoughness, thickness, interfaceEta, g, albedo, conductorURoughness, conductorVRoughness, conductorEta, k, reflectance, remapRoughness, maxDepth, nSamples); } @@ -477,12 +484,11 @@ CoatedConductorMaterial *CoatedConductorMaterial::Create( // SubsurfaceMaterial Method Definitions std::string SubsurfaceMaterial::ToString() const { - return StringPrintf("[ SubsurfaceMaterial displacement: %s scale: %f " - "sigma_a: %s sigma_s: %s " - "reflectance: %s mfp: %s uRoughness: %s vRoughness: %s " - "eta: %f remapRoughness: %s ]", + return StringPrintf("[ SubsurfaceMaterial displacement: %s normalMap: %s scale: %f " + "sigma_a: %s sigma_s: %s reflectance: %s mfp: %s uRoughness: %s " + "vRoughness: %s scale: %f eta: %f remapRoughness: %s ]", displacement, scale, sigma_a, sigma_s, reflectance, mfp, - uRoughness, vRoughness, eta, remapRoughness); + uRoughness, vRoughness, scale, eta, remapRoughness); } SubsurfaceMaterial *SubsurfaceMaterial::Create( @@ -559,8 +565,8 @@ SubsurfaceMaterial *SubsurfaceMaterial::Create( // DiffuseTransmissionMaterial Method Definitions std::string DiffuseTransmissionMaterial::ToString() const { return StringPrintf("[ DiffuseTransmissionMaterial displacement: %s reflectance: %s " - "transmittance: %s ]", - displacement, reflectance, transmittance); + "transmittance: %s scale: %f ]", + displacement, reflectance, transmittance, scale); } DiffuseTransmissionMaterial *DiffuseTransmissionMaterial::Create( @@ -592,8 +598,9 @@ MeasuredMaterial::MeasuredMaterial(const std::string &filename, FloatTexture dis } std::string MeasuredMaterial::ToString() const { - return StringPrintf("[ MeasuredMaterial displacement: %s normalMap: %p ]", - displacement, normalMap); + return StringPrintf("[ MeasuredMaterial displacement: %s normalMap: %s ]", + displacement, + normalMap ? normalMap->ToString() : std::string("(nullptr)")); } MeasuredMaterial *MeasuredMaterial::Create(const TextureParameterDictionary ¶meters, From ba4a3133c7acd06e0c91724248533cd5af36314c Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 27 Jan 2022 10:53:02 -0800 Subject: [PATCH 004/149] Improvements to --upgrade - Handle "random" -> "independent" sampler - Rewrite Transform{Begin,End} to non-deprecated Attribute{Begin,End} --- src/pbrt/parser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pbrt/parser.cpp b/src/pbrt/parser.cpp index 5fcc6674a..159c13fd2 100644 --- a/src/pbrt/parser.cpp +++ b/src/pbrt/parser.cpp @@ -1170,6 +1170,8 @@ void FormattingParserTarget::Sampler(const std::string &name, ParsedParameterVec Printf("%sSampler \"paddedsobol\"\n", indent()); else if (name == "maxmindist") Printf("%sSampler \"pmj02bn\"\n", indent()); + else if (name == "random") + Printf("%sSampler \"independent\"\n", indent()); else Printf("%sSampler \"%s\"\n", indent(), name); } else @@ -1277,13 +1279,15 @@ void FormattingParserTarget::Attribute(const std::string &target, ParsedParamete } void FormattingParserTarget::TransformBegin(FileLoc loc) { - Printf("%sTransformBegin\n", indent()); + Warning(&loc, "Rewriting \"TransformBegin\" to \"AttributeBegin\"."); + Printf("%sAttributeBegin\n", indent()); catIndentCount += 4; } void FormattingParserTarget::TransformEnd(FileLoc loc) { catIndentCount -= 4; - Printf("%sTransformEnd\n", indent()); + Warning(&loc, "Rewriting \"TransformEnd\" to \"AttributeEnd\"."); + Printf("%sAttributeEnd\n", indent()); } void FormattingParserTarget::Texture(const std::string &name, const std::string &type, From 36a1705878137358bf16d726201f15800e72e96d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 27 Jan 2022 12:23:02 -0800 Subject: [PATCH 005/149] Improvements to the github actions configs. - Break linux/osx/windows into separate .yml files - Test a smorgasbord of c++ compilers on linux --- .github/workflows/ci-cpu-linux.yml | 77 +++++++++++++++++++ .../{ci-cpu.yml => ci-cpu-macos.yml} | 21 ++--- .github/workflows/ci-cpu-windows.yml | 50 ++++++++++++ README.md | 4 +- 4 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/ci-cpu-linux.yml rename .github/workflows/{ci-cpu.yml => ci-cpu-macos.yml} (61%) create mode 100644 .github/workflows/ci-cpu-windows.yml diff --git a/.github/workflows/ci-cpu-linux.yml b/.github/workflows/ci-cpu-linux.yml new file mode 100644 index 000000000..5452500c6 --- /dev/null +++ b/.github/workflows/ci-cpu-linux.yml @@ -0,0 +1,77 @@ +name: linux-cpu-build-and-test + +on: + push: + paths-ignore: + - '**.md' + - 'images/**' + pull_request: + paths-ignore: + - '**.md' + - 'images/**' + +jobs: + build: + strategy: + matrix: + config: [ '', '-DPBRT_DBG_LOGGING=True', '-DPBRT_FLOAT_AS_DOUBLE=True' ] + compilers: + - { + cc: "gcc-9", + cxx: "g++-9", + } + - { + cc: "gcc-10", + cxx: "g++-10", + } + - { + cc: "clang-10", + cxx: "clang++-10", + } + - { + cc: "clang-11", + cxx: "clang++-11", + } + - { + cc: "clang-12", + cxx: "clang++-12", + } + + fail-fast: false + + runs-on: ubuntu-20.04 + name: Build and test ${{ matrix.compilers.cxx }} - ${{ matrix.config }} + + steps: + - name: Checkout pbrt + uses: actions/checkout@v2 + with: + submodules: true + + - name: Checkout rgb2spectrum tables + uses: actions/checkout@v2 + with: + repository: mmp/rgb2spectrum + path: build + + - name: Get cmake + uses: lukka/get-cmake@latest + + - name: Install OpenEXR + run: sudo apt-get -y install libopenexr-dev + + - name: Install compilers + run: sudo apt-get -y install ${{ matrix.compilers.cc }} ${{ matrix.compilers.cxx }} + + - name: Configure + run: | + cd build + env CC=${{ matrix.compilers.cc }} CXX=${{ matrix.compilers.cxx }} cmake .. -DPBRT_USE_PREGENERATED_RGB_TO_SPECTRUM_TABLES=True ${{ matrix.config }} + + - name: Build + run: cmake --build build --parallel --config Release + + - name: Test + if: ${{ matrix.config == '' }} + run: ./pbrt_test + working-directory: build diff --git a/.github/workflows/ci-cpu.yml b/.github/workflows/ci-cpu-macos.yml similarity index 61% rename from .github/workflows/ci-cpu.yml rename to .github/workflows/ci-cpu-macos.yml index 3c6650b36..1f965afc5 100644 --- a/.github/workflows/ci-cpu.yml +++ b/.github/workflows/ci-cpu-macos.yml @@ -1,4 +1,4 @@ -name: cpu-build-and-test +name: macos-cpu-build-and-test on: push: @@ -17,10 +17,9 @@ jobs: strategy: matrix: config: [ '', '-DPBRT_DBG_LOGGING=True', '-DPBRT_FLOAT_AS_DOUBLE=True' ] - os: [ ubuntu-20.04, macos-latest, windows-latest ] fail-fast: false - runs-on: ${{ matrix.os }} + runs-on: macos-latest steps: - name: Checkout pbrt @@ -37,12 +36,7 @@ jobs: - name: Get cmake uses: lukka/get-cmake@latest - - name: Install OpenEXR (Ubuntu) - if: ${{ matrix.os == 'ubuntu-20.04' }} - run: sudo apt-get -y install libopenexr-dev - - - name: Install OpenEXR (MacOS) - if: ${{ matrix.os == 'macos-latest' }} + - name: Install OpenEXR env: HOMEBREW_NO_INSTALL_CLEANUP: 1 run: brew install openexr @@ -55,12 +49,7 @@ jobs: - name: Build run: cmake --build build --parallel --config Release - - name: Test (Ubuntu/MacOS) - if: ${{ (matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest') && matrix.config == '' }} + - name: Test + if: ${{ matrix.config == '' }} run: ./pbrt_test working-directory: build - - - name: Test (Windows) - if: ${{ matrix.os == 'windows-latest' && matrix.config == '' }} - run: .\Release\pbrt_test.exe - working-directory: build diff --git a/.github/workflows/ci-cpu-windows.yml b/.github/workflows/ci-cpu-windows.yml new file mode 100644 index 000000000..457c6ff2c --- /dev/null +++ b/.github/workflows/ci-cpu-windows.yml @@ -0,0 +1,50 @@ +name: windows-cpu-build-and-test + +on: + push: + paths-ignore: + - '**.md' + - 'images/**' + pull_request: + paths-ignore: + - '**.md' + - 'images/**' + +jobs: + build: + name: Build and test + + strategy: + matrix: + config: [ '', '-DPBRT_DBG_LOGGING=True', '-DPBRT_FLOAT_AS_DOUBLE=True' ] + fail-fast: false + + runs-on: windows-latest + + steps: + - name: Checkout pbrt + uses: actions/checkout@v2 + with: + submodules: true + + - name: Checkout rgb2spectrum tables + uses: actions/checkout@v2 + with: + repository: mmp/rgb2spectrum + path: build + + - name: Get cmake + uses: lukka/get-cmake@latest + + - name: Configure + run: | + cd build + cmake .. -DPBRT_USE_PREGENERATED_RGB_TO_SPECTRUM_TABLES=True ${{ matrix.config }} + + - name: Build + run: cmake --build build --parallel --config Release + + - name: Test + if: ${{ matrix.config == '' }} + run: .\Release\pbrt_test.exe + working-directory: build diff --git a/README.md b/README.md index feeb2b944..35f769137 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ pbrt, Version 4 (Early Release) =============================== -[](https://github.com/mmp/pbrt-v4/actions?query=workflow%3Acpu-build-and-test) +[](https://github.com/mmp/pbrt-v4/actions?query=workflow%3Acpu-linux-build-and-test) +[](https://github.com/mmp/pbrt-v4/actions?query=workflow%3Acpu-macos-build-and-test) +[](https://github.com/mmp/pbrt-v4/actions?query=workflow%3Acpu-windows-build-and-test) [](https://github.com/mmp/pbrt-v4/actions?query=workflow%3Agpu-build-only) ![Transparent Machines frame, via @beeple](images/teaser-transparent-machines.png) From 79bc178329eda6b5274f06cbdc26567352ff0c8e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 27 Jan 2022 13:45:10 -0800 Subject: [PATCH 006/149] Windows improvements - #undefine interface, which somehow gets #defined in debug builds, thwarting the layered BxDF code - Move a CHECK out of (possibly) GPU code - And some cmake tidying --- CMakeLists.txt | 16 ++++++++++++++++ src/ext/CMakeLists.txt | 4 ++++ src/pbrt/samplers.h | 2 +- src/pbrt/wavefront/samples.cpp | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4f19ad63..4465ed1c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -787,6 +787,8 @@ set (PBRT_SOA_GENERATED ${PBRT_SOA_GENERATED} ${CMAKE_CURRENT_BINARY_DIR}/wavefr add_custom_target (pbrt_soa_generated DEPENDS ${PBRT_SOA_GENERATED}) +set_property (TARGET soac PROPERTY FOLDER "cmd") + ###################### # pbrt_lib @@ -909,6 +911,8 @@ if (NOT PBRT_USE_PREGENERATED_RGB_TO_SPECTRUM_TABLES) DEPENDS rgb2spec_opt) endif () +set_property (TARGET rgb2spec_opt PROPERTY FOLDER "cmd") + ###################### # Main renderer @@ -924,6 +928,8 @@ set_target_properties (pbrt_exe PROPERTIES OUTPUT_NAME pbrt) add_sanitizers (pbrt_exe) +set_property (TARGET pbrt_exe PROPERTY FOLDER "cmd") + ###################### # imgtool @@ -940,6 +946,8 @@ target_link_libraries (imgtool PRIVATE ${ALL_PBRT_LIBS} pbrt_opt pbrt_warnings s add_sanitizers (imgtool) +set_property (TARGET imgtool PROPERTY FOLDER "cmd") + ###################### # pspec @@ -953,6 +961,8 @@ target_link_libraries (pspec PRIVATE ${ALL_PBRT_LIBS} pbrt_warnings) add_sanitizers (pspec) +set_property (TARGET pspec PROPERTY FOLDER "cmd") + ###################### # plytool @@ -968,6 +978,8 @@ set_target_properties (plytool PROPERTIES OUTPUT_NAME plytool) add_sanitizers (plytool) +set_property (TARGET plytool PROPERTY FOLDER "cmd") + ###################### # cyhair2pbrt @@ -979,6 +991,8 @@ target_link_libraries (cyhair2pbrt PRIVATE pbrt_opt pbrt_warnings) add_sanitizers (cyhair2pbrt) +set_property (TARGET cyhair2pbrt PROPERTY FOLDER "cmd") + ################## # Unit tests @@ -1026,6 +1040,8 @@ add_sanitizers (pbrt_test) add_test (pbrt_unit_test pbrt_test) +set_property (TARGET pbrt_test PROPERTY FOLDER "cmd") + ############################### # Installation diff --git a/src/ext/CMakeLists.txt b/src/ext/CMakeLists.txt index 58d3da883..d7f47f673 100644 --- a/src/ext/CMakeLists.txt +++ b/src/ext/CMakeLists.txt @@ -23,6 +23,8 @@ add_subdirectory (libdeflate) set (LIBDEFLATE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libdeflate PARENT_SCOPE) set (LIBDEFLATE_LIBRARIES deflate::deflate PARENT_SCOPE) +set_property (TARGET deflate PROPERTY FOLDER "ext") + ########################################################################### # zlib @@ -135,3 +137,5 @@ set (NANOVDB_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/openvdb/nanovdb PARENT_SCOPE) set (FLIP_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/flip PARENT_SCOPE) add_library (flip_lib STATIC ${CMAKE_CURRENT_SOURCE_DIR}/flip/flip.cpp) + +set_property (TARGET flip_lib PROPERTY FOLDER "ext") diff --git a/src/pbrt/samplers.h b/src/pbrt/samplers.h index dfaf69c84..62cfe4cd4 100644 --- a/src/pbrt/samplers.h +++ b/src/pbrt/samplers.h @@ -740,10 +740,10 @@ class DebugMLTSampler : public MLTSampler { PBRT_CPU_GPU Float Get1D() { int index = GetNextIndex(); - CHECK_LT(index, u.size()); #ifdef PBRT_IS_GPU_CODE return 0; #else + DCHECK_LT(index, u.size()); return u[index]; #endif } diff --git a/src/pbrt/wavefront/samples.cpp b/src/pbrt/wavefront/samples.cpp index b6cbabc8a..c53fe9871 100644 --- a/src/pbrt/wavefront/samples.cpp +++ b/src/pbrt/wavefront/samples.cpp @@ -9,6 +9,10 @@ #include +#ifdef interface +#undef interface +#endif // interface + namespace pbrt { // WavefrontPathIntegrator Sampler Methods From 6b6341633ad75089af823face45fb7ecb3a30e1e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 28 Jan 2022 06:24:40 -0800 Subject: [PATCH 007/149] Fix github actions badges (hopefully) --- .github/workflows/ci-cpu-linux.yml | 2 +- .github/workflows/ci-cpu-macos.yml | 2 +- .github/workflows/ci-cpu-windows.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cpu-linux.yml b/.github/workflows/ci-cpu-linux.yml index 5452500c6..0199250f1 100644 --- a/.github/workflows/ci-cpu-linux.yml +++ b/.github/workflows/ci-cpu-linux.yml @@ -1,4 +1,4 @@ -name: linux-cpu-build-and-test +name: cpu-linux-build-and-test on: push: diff --git a/.github/workflows/ci-cpu-macos.yml b/.github/workflows/ci-cpu-macos.yml index 1f965afc5..93faa79b4 100644 --- a/.github/workflows/ci-cpu-macos.yml +++ b/.github/workflows/ci-cpu-macos.yml @@ -1,4 +1,4 @@ -name: macos-cpu-build-and-test +name: cpu-macos-build-and-test on: push: diff --git a/.github/workflows/ci-cpu-windows.yml b/.github/workflows/ci-cpu-windows.yml index 457c6ff2c..d75e49e32 100644 --- a/.github/workflows/ci-cpu-windows.yml +++ b/.github/workflows/ci-cpu-windows.yml @@ -1,4 +1,4 @@ -name: windows-cpu-build-and-test +name: cpu-windows-build-and-test on: push: From c7e3879c782f5434525639fe585b98e4aa0d9298 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 2 Feb 2022 07:10:03 -0800 Subject: [PATCH 008/149] Unicode normalization (#225) Normalize unicode strings for user-supplied names (objects, materials, media, etc.) Note that there is no need to normalize strings for things like the name of the selected sampler, light source types, or the parameters provided to pbrt objects, as all of the valid ones are plain old ASCII text. We also intentionally do not normalize pathnames, as doing so can cause all sorts of trouble. --- .gitmodules | 3 +++ CMakeLists.txt | 3 +++ src/ext/CMakeLists.txt | 7 +++++++ src/ext/utf8proc | 1 + src/pbrt/scene.cpp | 33 +++++++++++++++++++++++---------- src/pbrt/util/string.cpp | 18 ++++++++++++++++++ src/pbrt/util/string.h | 2 ++ src/pbrt/util/string_test.cpp | 26 ++++++++++++++++++++++++++ 8 files changed, 83 insertions(+), 10 deletions(-) create mode 160000 src/ext/utf8proc create mode 100644 src/pbrt/util/string_test.cpp diff --git a/.gitmodules b/.gitmodules index b299bd0ff..a908a29b5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,3 +27,6 @@ [submodule "src/ext/lodepng"] path = src/ext/lodepng url = https://github.com/lvandeve/lodepng.git +[submodule "src/ext/utf8proc"] + path = src/ext/utf8proc + url = https://github.com/JuliaStrings/utf8proc.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4465ed1c5..1619858f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ check_ext ("filesystem" "filesystem/filesystem" c5f9de30142453eb3c6fe991e82dfc25 check_ext ("libdeflate" "libdeflate/common" 1fd0bea6ca2073c68493632dafc4b1ddda1bcbc3) check_ext ("lodepng" "lodepng/examples" 8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a) check_ext ("stb" "stb/tools" af1a5bc352164740c1cc1354942b1c6b72eacb8a) +check_ext ("utf8proc" "utf8proc/bench" 2484e2ed5e1d9c19edcccf392a7d9920ad90dfaf) check_ext ("zlib" "zlib/doc" 54d591eabf9fe0e84c725638f8d5d8d202a093fa) add_compile_definitions ("$<$:PBRT_DEBUG_BUILD>") @@ -861,6 +862,7 @@ set (ALL_PBRT_LIBS ${LIBDEFLATE_LIBRARIES} double-conversion ${PBRT_CUDA_LIB} + utf8proc ) if (PBRT_CUDA_ENABLED) @@ -1024,6 +1026,7 @@ set (PBRT_TEST_SOURCE src/pbrt/util/sampling_test.cpp src/pbrt/util/spectrum_test.cpp src/pbrt/util/splines_test.cpp + src/pbrt/util/string_test.cpp src/pbrt/util/taggedptr_test.cpp src/pbrt/util/transform_test.cpp src/pbrt/util/vecmath_test.cpp diff --git a/src/ext/CMakeLists.txt b/src/ext/CMakeLists.txt index d7f47f673..3968d18f3 100644 --- a/src/ext/CMakeLists.txt +++ b/src/ext/CMakeLists.txt @@ -139,3 +139,10 @@ set (FLIP_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/flip PARENT_SCOPE) add_library (flip_lib STATIC ${CMAKE_CURRENT_SOURCE_DIR}/flip/flip.cpp) set_property (TARGET flip_lib PROPERTY FOLDER "ext") + +########################################################################### +# utf8proc + +set (UTF8PROC_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/utf8proc PARENT_SCOPE) + +add_subdirectory (utf8proc) diff --git a/src/ext/utf8proc b/src/ext/utf8proc new file mode 160000 index 000000000..2484e2ed5 --- /dev/null +++ b/src/ext/utf8proc @@ -0,0 +1 @@ +Subproject commit 2484e2ed5e1d9c19edcccf392a7d9920ad90dfaf diff --git a/src/pbrt/scene.cpp b/src/pbrt/scene.cpp index 8f99579bc..91ec02642 100644 --- a/src/pbrt/scene.cpp +++ b/src/pbrt/scene.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -122,11 +123,13 @@ void BasicSceneBuilder::Translate(Float dx, Float dy, Float dz, FileLoc loc) { [=](auto t) { return t * pbrt::Translate(Vector3f(dx, dy, dz)); }); } -void BasicSceneBuilder::CoordinateSystem(const std::string &name, FileLoc loc) { +void BasicSceneBuilder::CoordinateSystem(const std::string &origName, FileLoc loc) { + std::string name = NormalizeUTF8(origName); namedCoordinateSystems[name] = graphicsState.ctm; } -void BasicSceneBuilder::CoordSysTransform(const std::string &name, FileLoc loc) { +void BasicSceneBuilder::CoordSysTransform(const std::string &origName, FileLoc loc) { + std::string name = NormalizeUTF8(origName); if (namedCoordinateSystems.find(name) != namedCoordinateSystems.end()) graphicsState.ctm = namedCoordinateSystems[name]; else @@ -230,8 +233,9 @@ void BasicSceneBuilder::WorldBegin(FileLoc loc) { scene->SetOptions(filter, film, camera, sampler, integrator, accelerator); } -void BasicSceneBuilder::MakeNamedMedium(const std::string &name, +void BasicSceneBuilder::MakeNamedMedium(const std::string &origName, ParsedParameterVector params, FileLoc loc) { + std::string name = NormalizeUTF8(origName); // Issue error if medium _name_ is multiply defined if (mediumNames.find(name) != mediumNames.end()) { ErrorExitDeferred(&loc, "Named medium \"%s\" redefined.", name); @@ -302,7 +306,9 @@ void BasicSceneBuilder::Shape(const std::string &name, ParsedParameterVector par } } -void BasicSceneBuilder::ObjectBegin(const std::string &name, FileLoc loc) { +void BasicSceneBuilder::ObjectBegin(const std::string &origName, FileLoc loc) { + std::string name = NormalizeUTF8(origName); + VERIFY_WORLD("ObjectBegin"); pushedGraphicsStates.push_back(graphicsState); @@ -356,7 +362,8 @@ void BasicSceneBuilder::ObjectEnd(FileLoc loc) { activeInstanceDefinition = nullptr; } -void BasicSceneBuilder::ObjectInstance(const std::string &name, FileLoc loc) { +void BasicSceneBuilder::ObjectInstance(const std::string &origName, FileLoc loc) { + std::string name = NormalizeUTF8(origName); VERIFY_WORLD("ObjectInstance"); if (activeInstanceDefinition) { @@ -643,15 +650,19 @@ void BasicSceneBuilder::Integrator(const std::string &name, ParsedParameterVecto integrator = SceneEntity(name, std::move(dict), loc); } -void BasicSceneBuilder::MediumInterface(const std::string &insideName, - const std::string &outsideName, FileLoc loc) { +void BasicSceneBuilder::MediumInterface(const std::string &origInsideName, + const std::string &origOutsideName, FileLoc loc) { + std::string insideName = NormalizeUTF8(origInsideName); + std::string outsideName = NormalizeUTF8(origOutsideName); + graphicsState.currentInsideMedium = insideName; graphicsState.currentOutsideMedium = outsideName; } -void BasicSceneBuilder::Texture(const std::string &name, const std::string &type, +void BasicSceneBuilder::Texture(const std::string &origName, const std::string &type, const std::string &texname, ParsedParameterVector params, FileLoc loc) { + std::string name = NormalizeUTF8(origName); VERIFY_WORLD("Texture"); ParameterDictionary dict(std::move(params), graphicsState.textureAttributes, @@ -691,8 +702,9 @@ void BasicSceneBuilder::Material(const std::string &name, ParsedParameterVector graphicsState.currentMaterialName.clear(); } -void BasicSceneBuilder::MakeNamedMaterial(const std::string &name, +void BasicSceneBuilder::MakeNamedMaterial(const std::string &origName, ParsedParameterVector params, FileLoc loc) { + std::string name = NormalizeUTF8(origName); VERIFY_WORLD("MakeNamedMaterial"); ParameterDictionary dict(std::move(params), graphicsState.materialAttributes, @@ -707,7 +719,8 @@ void BasicSceneBuilder::MakeNamedMaterial(const std::string &name, scene->AddNamedMaterial(name, SceneEntity("", std::move(dict), loc)); } -void BasicSceneBuilder::NamedMaterial(const std::string &name, FileLoc loc) { +void BasicSceneBuilder::NamedMaterial(const std::string &origName, FileLoc loc) { + std::string name = NormalizeUTF8(origName); VERIFY_WORLD("NamedMaterial"); graphicsState.currentMaterialName = name; graphicsState.currentMaterialIndex = -1; diff --git a/src/pbrt/util/string.cpp b/src/pbrt/util/string.cpp index 4d1087595..6a2486297 100644 --- a/src/pbrt/util/string.cpp +++ b/src/pbrt/util/string.cpp @@ -9,6 +9,10 @@ #include #include +#include + +#define UTF8PROC_STATIC +#include #include #include @@ -185,4 +189,18 @@ std::u16string UTF16FromUTF8(std::string str) { return utf16; } +std::string NormalizeUTF8(std::string str) { + utf8proc_option_t options = UTF8PROC_COMPOSE; + + utf8proc_uint8_t *result; + utf8proc_ssize_t length = utf8proc_map((const unsigned char *)str.data(), str.size(), + &result, options); + if (length < 0) + ErrorExit("Unicode normalization error: %s: \"%s\"", utf8proc_errmsg(length), str); + + str = std::string(result, result + length); + free(result); + return str; +} + } // namespace pbrt diff --git a/src/pbrt/util/string.h b/src/pbrt/util/string.h index 8db24f285..319e80ece 100644 --- a/src/pbrt/util/string.h +++ b/src/pbrt/util/string.h @@ -36,6 +36,8 @@ std::wstring WStringFromUTF8(std::string str); std::string UTF8FromWString(std::wstring str); #endif // PBRT_IS_WINDOWS +std::string NormalizeUTF8(std::string str); + // InternedString Definition class InternedString { public: diff --git a/src/pbrt/util/string_test.cpp b/src/pbrt/util/string_test.cpp new file mode 100644 index 000000000..11fc0ccd8 --- /dev/null +++ b/src/pbrt/util/string_test.cpp @@ -0,0 +1,26 @@ +// 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 + +#include + +#include +#include + +#include + +using namespace pbrt; + +TEST(Unicode, BasicNormalization) { + // "Amélie" two ways, via https://en.wikipedia.org/wiki/Unicode_equivalence + std::u16string nfc16(u"\u0041\u006d\u00e9\u006c\u0069\u0065"); + std::u16string nfd16(u"\u0041\u006d\u0065\u0301\u006c\u0069\u0065"); + EXPECT_NE(nfc16, nfd16); + + std::string nfc8 = UTF8FromUTF16(nfc16); + std::string nfd8 = UTF8FromUTF16(nfd16); + EXPECT_NE(nfc8, nfd8); + + EXPECT_EQ(nfc8, NormalizeUTF8(nfc8)); // nfc is already normalized + EXPECT_EQ(nfc8, NormalizeUTF8(nfd8)); // normalizing nfd should make it equal nfc +} From 16b0e10e6f11653c26d7c2000e913990da675e16 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 9 Feb 2022 13:47:51 -0800 Subject: [PATCH 009/149] GPU path: Workaround bug in recent NVIDIA drivers. Issue #226. --- src/pbrt/gpu/aggregate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index 1a2cb4031..e0436d496 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -1054,6 +1054,10 @@ OptixModule OptiXAggregate::createOptiXModule(OptixDeviceContext optixContext, moduleCompileOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE; #endif + // Workaround driver 510/511 bug with debug builds. + // (See https://github.com/mmp/pbrt-v4/issues/226). + moduleCompileOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE; + OptixPipelineCompileOptions pipelineCompileOptions = getPipelineCompileOptions(); char log[4096]; From a2789a7c8ff7c7422ef0771f598cfab453924823 Mon Sep 17 00:00:00 2001 From: ruevs Date: Wed, 23 Feb 2022 18:14:36 +0200 Subject: [PATCH 010/149] Make submodule URLs consistent (#229) Add `.git` to the double-conversion and zlib submodules URLs. --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index a908a29b5..ba41f6b2f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ [submodule "src/ext/zlib"] path = src/ext/zlib - url = https://github.com/mitsuba-renderer/zlib + url = https://github.com/mitsuba-renderer/zlib.git [submodule "src/ext/ptex"] path = src/ext/ptex url = https://github.com/wdas/ptex.git [submodule "src/ext/double-conversion"] path = src/ext/double-conversion - url = https://github.com/mmp/double-conversion + url = https://github.com/mmp/double-conversion.git [submodule "src/ext/stb"] path = src/ext/stb url = https://github.com/nothings/stb.git From e9d316705547fec65b6391016de53b71bed3f296 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 1 Mar 2022 11:01:55 -0800 Subject: [PATCH 011/149] Add support for reading/writing string metadata in EXR files --- src/pbrt/cmd/imgtool.cpp | 4 ++++ src/pbrt/util/image.cpp | 10 +++++++++- src/pbrt/util/image.h | 1 + src/pbrt/util/image_test.cpp | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 5d75d366e..9b64c9b6f 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -1302,6 +1302,9 @@ static void printImageStats(const char *name, const Image &image, if (metadata.MSE) printf("\tMSE vs. reference image: %g\n", *metadata.MSE); + for (const auto &iter : metadata.strings) + printf("\t\"%s\": \"%s\"\n", iter.first.c_str(), iter.second.c_str()); + for (const auto &iter : metadata.stringVectors) { printf("\t\"%s\": [ ", iter.first.c_str()); for (const std::string &str : iter.second) @@ -2226,6 +2229,7 @@ int makeequiarea(std::vector args) { ImageMetadata equiRectMetadata; equiRectMetadata.cameraFromWorld = latlong.metadata.cameraFromWorld; equiRectMetadata.colorSpace = latlong.metadata.colorSpace; + equiRectMetadata.strings = latlong.metadata.strings; equiRectMetadata.stringVectors = latlong.metadata.stringVectors; equiRectImage.Write(outFilename, equiRectMetadata); diff --git a/src/pbrt/util/image.cpp b/src/pbrt/util/image.cpp index 0a7b10aa2..b4c8536b1 100644 --- a/src/pbrt/util/image.cpp +++ b/src/pbrt/util/image.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #endif @@ -1078,8 +1079,13 @@ static ImageAndMetadata ReadEXR(const std::string &name, Allocator alloc) { if (mseAttrib) metadata.MSE = mseAttrib->value(); - // Find any string vector attributes + // Find any string or string vector attributes for (auto iter = file.header().begin(); iter != file.header().end(); ++iter) { + if (strcmp(iter.attribute().typeName(), "string") == 0) { + Imf::StringAttribute &sv = + (Imf::StringAttribute &)iter.attribute(); + metadata.strings[iter.name()] = sv.value(); + } if (strcmp(iter.attribute().typeName(), "stringvector") == 0) { Imf::StringVectorAttribute &sv = (Imf::StringVectorAttribute &)iter.attribute(); @@ -1195,6 +1201,8 @@ bool Image::WriteEXR(const std::string &name, const ImageMetadata &metadata) con Imf::IntAttribute(*metadata.samplesPerPixel)); if (metadata.MSE) header.insert("MSE", Imf::FloatAttribute(*metadata.MSE)); + for (const auto &iter : metadata.strings) + header.insert(iter.first, Imf::StringAttribute(iter.second)); for (const auto &iter : metadata.stringVectors) header.insert(iter.first, Imf::StringVectorAttribute(iter.second)); diff --git a/src/pbrt/util/image.h b/src/pbrt/util/image.h index 1ed605e09..b2621edf4 100644 --- a/src/pbrt/util/image.h +++ b/src/pbrt/util/image.h @@ -158,6 +158,7 @@ struct ImageMetadata { pstd::optional samplesPerPixel; pstd::optional MSE; pstd::optional colorSpace; + std::map strings; std::map> stringVectors; }; diff --git a/src/pbrt/util/image_test.cpp b/src/pbrt/util/image_test.cpp index ca94671cc..9f96678b2 100644 --- a/src/pbrt/util/image_test.cpp +++ b/src/pbrt/util/image_test.cpp @@ -390,6 +390,7 @@ TEST(Image, ExrNoMetadata) { EXPECT_EQ(*metadata.pixelBounds, Bounds2i({0, 0}, res)); EXPECT_TRUE((bool)metadata.fullResolution); EXPECT_EQ(*metadata.fullResolution, res); + EXPECT_EQ(0, metadata.strings.size()); EXPECT_EQ(0, metadata.stringVectors.size()); EXPECT_TRUE(RemoveFile(filename.c_str())); @@ -417,6 +418,7 @@ TEST(Image, ExrMetadata) { outMetadata.NDCFromWorld = w2n; outMetadata.pixelBounds = pb; outMetadata.fullResolution = fullRes; + outMetadata.strings["pbrt"] = "v4"; outMetadata.stringVectors = stringVectors; EXPECT_TRUE(image.Write(filename, outMetadata)); @@ -440,6 +442,9 @@ TEST(Image, ExrMetadata) { EXPECT_TRUE((bool)inMetadata.fullResolution); EXPECT_EQ(*inMetadata.fullResolution, fullRes); + EXPECT_EQ(1, inMetadata.strings.size()); + EXPECT_EQ("v4", inMetadata.strings["pbrt"]); + EXPECT_EQ(1, inMetadata.stringVectors.size()); auto iter = stringVectors.find("yolo"); EXPECT_TRUE(iter != stringVectors.end()); From 999be053fb56b6a4062f025e473afe80e5aa785d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 1 Mar 2022 11:09:30 -0800 Subject: [PATCH 012/149] Add SpectralFilm. This writes spectral images using the layout proposed in "An OpenEXR Layout for Sepctral Images" by Fichet et al., https://jcgt.org/published/0010/03/01/. --- src/pbrt/base/film.h | 3 +- src/pbrt/film.cpp | 211 +++++++++++++++++++++++++++++++++++++++++++ src/pbrt/film.h | 121 +++++++++++++++++++++++++ 3 files changed, 334 insertions(+), 1 deletion(-) diff --git a/src/pbrt/base/film.h b/src/pbrt/base/film.h index ac0c3f8aa..8063802f1 100644 --- a/src/pbrt/base/film.h +++ b/src/pbrt/base/film.h @@ -18,10 +18,11 @@ namespace pbrt { class VisibleSurface; class RGBFilm; class GBufferFilm; +class SpectralFilm; class PixelSensor; // Film Definition -class Film : public TaggedPointer { +class Film : public TaggedPointer { public: // Film Interface PBRT_CPU_GPU inline void AddSample(Point2i pFilm, SampledSpectrum L, diff --git a/src/pbrt/film.cpp b/src/pbrt/film.cpp index 24b640b21..277e750d8 100644 --- a/src/pbrt/film.cpp +++ b/src/pbrt/film.cpp @@ -29,6 +29,7 @@ #include #include +#include namespace pbrt { @@ -835,6 +836,213 @@ GBufferFilm *GBufferFilm::Create(const ParameterDictionary ¶meters, writeFP16, alloc); } +// SpectralFilm Method Definitions +SpectralFilm::SpectralFilm(FilmBaseParameters p, Float lambdaMin, Float lambdaMax, + int nBuckets, const RGBColorSpace *colorSpace, + Float maxComponentValue, bool writeFP16, Allocator alloc) + : FilmBase(p), + colorSpace(colorSpace), + lambdaMin(lambdaMin), + lambdaMax(lambdaMax), + nBuckets(nBuckets), + maxComponentValue(maxComponentValue), + writeFP16(writeFP16), + pixels(p.pixelBounds, alloc) { + // Compute _outputRGBFromSensorRGB_ matrix + outputRGBFromSensorRGB = colorSpace->RGBFromXYZ * sensor->XYZFromSensorRGB; + + filterIntegral = filter.Integral(); + CHECK(!pixelBounds.IsEmpty()); + filmPixelMemory += pixelBounds.Area() * (sizeof(Pixel) + 3 * nBuckets * sizeof(double)); + + // Allocate memory for the pixel buffers in big arrays. Note that it's + // wasteful (but convenient) to be storing three pointers in each + // SpectralFilm::Pixel structure since the addresses could be computed + // based on the base pointers and pixel coordinates. + int nPixels = pixelBounds.Area(); + double *bucketWeightBuffer = alloc.allocate_object(2 * nBuckets * nPixels); + std::memset(bucketWeightBuffer, 0, 2 * nBuckets * nPixels * sizeof(double)); + AtomicDouble *splatBuffer = alloc.allocate_object(nBuckets * nPixels); + std::memset(splatBuffer, 0, nBuckets * nPixels * sizeof(double)); + + for (Point2i p : pixelBounds) { + Pixel &pixel = pixels[p]; + pixel.bucketSums = bucketWeightBuffer; + bucketWeightBuffer += NSpectrumSamples; + pixel.weightSums = bucketWeightBuffer; + bucketWeightBuffer += NSpectrumSamples; + pixel.bucketSplats = splatBuffer; + splatBuffer += NSpectrumSamples; + } +} + +RGB SpectralFilm::GetPixelRGB(Point2i p, Float splatScale) const { + // Note: this is effectively the same as RGBFilm::GetPixelRGB + + const Pixel &pixel = pixels[p]; + RGB rgb(pixel.rgbSum[0], pixel.rgbSum[1], pixel.rgbSum[2]); + // Normalize _rgb_ with weight sum + Float weightSum = pixel.rgbWeightSum; + if (weightSum != 0) + rgb /= weightSum; + + // Add splat value at pixel + for (int c = 0; c < 3; ++c) + rgb[c] += splatScale * pixel.rgbSplat[c] / filterIntegral; + + // Convert _rgb_ to output RGB color space + rgb = outputRGBFromSensorRGB * rgb; + + return rgb; +} + +void SpectralFilm::AddSplat(Point2f p, SampledSpectrum L, const SampledWavelengths &lambda) { + // This, too, is similar to RGBFilm::AddSplat(), with additions for + // spectra. + + CHECK(!L.HasNaNs()); + + // Convert sample radiance to _PixelSensor_ RGB + RGB rgb = sensor->ToSensorRGB(L, lambda); + + // Optionally clamp sensor RGB value + Float m = std::max({rgb.r, rgb.g, rgb.b}); + if (m > maxComponentValue) + rgb *= maxComponentValue / m; + + // Spectral clamping and normalization. + Float lm = L.MaxComponentValue(); + if (lm > maxComponentValue) + L *= maxComponentValue / lm; + L = SafeDiv(L, lambda.PDF()) / NSpectrumSamples; + + // Compute bounds of affected pixels for splat, _splatBounds_ + Point2f pDiscrete = p + Vector2f(0.5, 0.5); + Vector2f radius = filter.Radius(); + Bounds2i splatBounds(Point2i(Floor(pDiscrete - radius)), + Point2i(Floor(pDiscrete + radius)) + Vector2i(1, 1)); + splatBounds = Intersect(splatBounds, pixelBounds); + + // Splat both RGB and spectral bucket contributions. + for (Point2i pi : splatBounds) { + // Evaluate filter at _pi_ and add splat contribution + Float wt = filter.Evaluate(Point2f(p - pi - Vector2f(0.5, 0.5))); + if (wt != 0) { + Pixel &pixel = pixels[pi]; + + for (int i = 0; i < 3; ++i) + pixel.rgbSplat[i].Add(wt * rgb[i]); + + for (int i = 0; i < NSpectrumSamples; ++i) { + int b = LambdaToBucket(lambda[i]); + pixel.bucketSplats[b].Add(wt * L[i]); + } + } + } +} + +void SpectralFilm::WriteImage(ImageMetadata metadata, Float splatScale) { + Image image = GetImage(&metadata, splatScale); + LOG_VERBOSE("Writing image %s with bounds %s", filename, pixelBounds); + image.Write(filename, metadata); +} + +Image SpectralFilm::GetImage(ImageMetadata *metadata, Float splatScale) { + // Convert image to RGB and compute final pixel values + LOG_VERBOSE("Computing final weighted pixel values"); + PixelFormat format = writeFP16 ? PixelFormat::Half : PixelFormat::Float; + + std::vector imageChannels{{"R", "G", "B"}}; + for (int i = 0; i < nBuckets; ++i) { + // The OpenEXR spectral layout takes the bucket center (and then + // determines bucket widths based on the neighbor wavelengths). + std::string lambda = StringPrintf("%.3fnm", + Lerp((i + 0.5f) / nBuckets, lambdaMin, lambdaMax)); + // Convert any '.' to ',' in the number since OpenEXR uses '.' for + // separating layers. + std::replace(lambda.begin(), lambda.end(), '.', ','); + + imageChannels.push_back("S0." + lambda); + } + Image image(format, Point2i(pixelBounds.Diagonal()), imageChannels); + + std::atomic nClamped{0}; + ParallelFor2D(pixelBounds, [&](Point2i p) { + Pixel &pixel = pixels[p]; + + RGB rgb = GetPixelRGB(p, splatScale); + + // Clamp to max representable fp16 to avoid Infs + if (writeFP16) { + for (int c = 0; c < 3; ++c) { + if (rgb[c] > 65504) { + rgb[c] = 65504; + ++nClamped; + } + } + } + + Point2i pOffset(p.x - pixelBounds.pMin.x, p.y - pixelBounds.pMin.y); + image.SetChannels(pOffset, {rgb[0], rgb[1], rgb[2]}); + + // Set spectral channels. Hardcoded assuming that they come + // immediately after RGB, as is currently specified above. + for (int i = 0; i < nBuckets; ++i) { + Float c = 0; + if (pixel.weightSums[i] > 0) { + c = pixel.bucketSums[i] / pixel.weightSums[i] + + splatScale * pixel.bucketSplats[i] / filterIntegral; + if (writeFP16 && c > 65504) { + c = 65504; + ++nClamped; + } + } + image.SetChannel(pOffset, 3 + i, c); + } + }); + + if (nClamped.load() > 0) + Warning("%d pixel values clamped to maximum fp16 value.", nClamped.load()); + + metadata->pixelBounds = pixelBounds; + metadata->fullResolution = fullResolution; + metadata->colorSpace = colorSpace; + metadata->strings["spectralLayoutVersion"] = "1.0"; + // FIXME: if the RealisticCamera is being used, then we're actually + // storing "J.m^-2", but that isn't a supported value for + // "emissiveUnits" in the spec. + metadata->strings["emissiveUnits"] = "W.m^-2.sr^-1"; + + return image; +} + +std::string SpectralFilm::ToString() const { + return StringPrintf( + "[ SpectralFilm %s lambdaMin: %f lambdaMax: %f nBuckets: %d writeFP16: %s maxComponentValue: %f ]", + BaseToString(), lambdaMin, lambdaMax, nBuckets, writeFP16, maxComponentValue); +} + +SpectralFilm *SpectralFilm::Create(const ParameterDictionary ¶meters, Float exposureTime, + Filter filter, const RGBColorSpace *colorSpace, + const FileLoc *loc, Allocator alloc) { + PixelSensor *sensor = + PixelSensor::Create(parameters, colorSpace, exposureTime, loc, alloc); + FilmBaseParameters filmBaseParameters(parameters, filter, sensor, loc); + bool writeFP16 = parameters.GetOneBool("savefp16", true); + + if (!HasExtension(filmBaseParameters.filename, "exr")) + ErrorExit(loc, "%s: EXR is the only output format supported by the SpectralFilm.", + filmBaseParameters.filename); + + int nBuckets = parameters.GetOneInt("nbuckets", 16); + Float lambdaMin = parameters.GetOneFloat("lambdamin", Lambda_min); + Float lambdaMax = parameters.GetOneFloat("lambdamax", Lambda_max); + Float maxComponentValue = parameters.GetOneFloat("maxcomponentvalue", Infinity); + + return alloc.new_object(filmBaseParameters, lambdaMin, lambdaMax, nBuckets, + colorSpace, maxComponentValue, writeFP16, alloc); +} + Film Film::Create(const std::string &name, const ParameterDictionary ¶meters, Float exposureTime, const CameraTransform &cameraTransform, Filter filter, const FileLoc *loc, Allocator alloc) { @@ -845,6 +1053,9 @@ Film Film::Create(const std::string &name, const ParameterDictionary ¶meters else if (name == "gbuffer") film = GBufferFilm::Create(parameters, exposureTime, cameraTransform, filter, parameters.ColorSpace(), loc, alloc); + else if (name == "spectral") + film = SpectralFilm::Create(parameters, exposureTime, filter, + parameters.ColorSpace(), loc, alloc); else ErrorExit(loc, "%s: film type unknown.", name); diff --git a/src/pbrt/film.h b/src/pbrt/film.h index a874550c4..a220dbb08 100644 --- a/src/pbrt/film.h +++ b/src/pbrt/film.h @@ -393,6 +393,127 @@ class GBufferFilm : public FilmBase { SquareMatrix<3> outputRGBFromSensorRGB; }; +// SpectralFilm Definition +class SpectralFilm : public FilmBase { + public: + // SpectralFilm Public Methods + PBRT_CPU_GPU + bool UsesVisibleSurface() const { return false; } + + PBRT_CPU_GPU + SampledWavelengths SampleWavelengths(Float u) const { + return SampledWavelengths::SampleUniform(u, lambdaMin, lambdaMax); + } + + PBRT_CPU_GPU + void AddSample(Point2i pFilm, SampledSpectrum L, const SampledWavelengths &lambda, + const VisibleSurface *, Float weight) { + // Start by doing more or less what RGBFilm::AddSample() does so + // that we can maintain accurate RGB values. + + // Convert sample radiance to _PixelSensor_ RGB + RGB rgb = sensor->ToSensorRGB(L, lambda); + + // Optionally clamp sensor RGB value + Float m = std::max({rgb.r, rgb.g, rgb.b}); + if (m > maxComponentValue) + rgb *= maxComponentValue / m; + + DCHECK(InsideExclusive(pFilm, pixelBounds)); + // Update RGB fields in Pixel structure. + Pixel &pixel = pixels[pFilm]; + for (int c = 0; c < 3; ++c) + pixel.rgbSum[c] += weight * rgb[c]; + pixel.rgbWeightSum += weight; + + // Spectral processing starts here. + // Optionally clamp spectral value. (TODO: for spectral should we + // just clamp channels individually?) + Float lm = L.MaxComponentValue(); + if (lm > maxComponentValue) + L *= maxComponentValue / lm; + + // The CIE_Y_integral factor effectively cancels out the effect of + // the conversion of light sources to use photometric units for + // specification. We then do *not* divide by the PDF in |lambda| + // but take advantage of the fact that we know that it is uniform + // in SampleWavelengths(), the fact that the buckets all have the + // same extend, and can then just average radiance in buckets + // below. + L *= weight * CIE_Y_integral; + + // Accumulate contributions in spectral buckets. + for (int i = 0; i < NSpectrumSamples; ++i) { + int b = LambdaToBucket(lambda[i]); + pixel.bucketSums[b] += L[i]; + pixel.weightSums[b] += weight; + } + } + + PBRT_CPU_GPU + RGB GetPixelRGB(Point2i p, Float splatScale = 1) const; + + SpectralFilm(FilmBaseParameters p, Float lambdaMin, Float lambdaMax, + int nBuckets, const RGBColorSpace *colorSpace, + Float maxComponentValue = Infinity, bool writeFP16 = true, + Allocator alloc = {}); + + static SpectralFilm *Create(const ParameterDictionary ¶meters, Float exposureTime, + Filter filter, const RGBColorSpace *colorSpace, + const FileLoc *loc, Allocator alloc); + + PBRT_CPU_GPU + void AddSplat(Point2f p, SampledSpectrum v, const SampledWavelengths &lambda); + + void WriteImage(ImageMetadata metadata, Float splatScale = 1); + + // Returns an image with both RGB and spectral components, following + // the layout proposed in "An OpenEXR Layout for Sepctral Images" by + // Fichet et al., https://jcgt.org/published/0010/03/01/. + Image GetImage(ImageMetadata *metadata, Float splatScale = 1); + + std::string ToString() const; + + PBRT_CPU_GPU + RGB ToOutputRGB(SampledSpectrum L, const SampledWavelengths &lambda) const { + LOG_FATAL("ToOutputRGB() is unimplemented. But that's ok since it's only used " + "in the SPPM integrator, which is inherently very much based on " + "RGB output."); + return {}; + } + + private: + PBRT_CPU_GPU + int LambdaToBucket(Float lambda) const { + DCHECK_RARE(1e6f, lambda < lambdaMin || lambda > lambdaMax); + int bucket = nBuckets * (lambda - lambdaMin) / (lambdaMax - lambdaMin); + return Clamp(bucket, 0, nBuckets - 1); + } + + // SpectralFilm::Pixel Definition + struct Pixel { + Pixel() = default; + // Continue to store RGB, both to include in the final image as + // well as for previews during rendering. + double rgbSum[3] = {0., 0., 0.}; + double rgbWeightSum = 0.; + AtomicDouble rgbSplat[3]; + // The following will all have nBuckets entries. + double *bucketSums, *weightSums; + AtomicDouble *bucketSplats; + }; + + // SpectralFilm Private Members + const RGBColorSpace *colorSpace; + Float lambdaMin, lambdaMax; + int nBuckets; + Float maxComponentValue; + bool writeFP16; + Float filterIntegral; + Array2D pixels; + SquareMatrix<3> outputRGBFromSensorRGB; +}; + PBRT_CPU_GPU inline SampledWavelengths Film::SampleWavelengths(Float u) const { auto sample = [&](auto ptr) { return ptr->SampleWavelengths(u); }; From fd3c25bf1062ab9a790a9ab5fbd4e84d813c2316 Mon Sep 17 00:00:00 2001 From: Alban <7930348+afichet@users.noreply.github.com> Date: Wed, 2 Mar 2022 18:50:24 +0000 Subject: [PATCH 013/149] Bugfix: wrong stride (#230) --- src/pbrt/film.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/film.cpp b/src/pbrt/film.cpp index 277e750d8..1e28313cc 100644 --- a/src/pbrt/film.cpp +++ b/src/pbrt/film.cpp @@ -868,9 +868,9 @@ SpectralFilm::SpectralFilm(FilmBaseParameters p, Float lambdaMin, Float lambdaMa for (Point2i p : pixelBounds) { Pixel &pixel = pixels[p]; pixel.bucketSums = bucketWeightBuffer; - bucketWeightBuffer += NSpectrumSamples; + bucketWeightBuffer += nBuckets; pixel.weightSums = bucketWeightBuffer; - bucketWeightBuffer += NSpectrumSamples; + bucketWeightBuffer += nBuckets; pixel.bucketSplats = splatBuffer; splatBuffer += NSpectrumSamples; } From 9afc099ec9631a5c26217b6381986010347bd1c2 Mon Sep 17 00:00:00 2001 From: Daniel Cousens <413395+dcousens@users.noreply.github.com> Date: Sat, 19 Mar 2022 04:02:07 +1100 Subject: [PATCH 014/149] Fix small typo (#231) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 35f769137..c9794fc37 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ book.) We are making this code available for hardy adventurers; it's not yet extensively documented, but if you are familiar with previous versions of -pbrt, you should be able to make your away around it. Our hope is that the +pbrt, you should be able to make your way around it. Our hope is that the system will be useful to some people in its current form and that any bugs in the current implementation might be found now, allowing us to correct them before the book is final. @@ -193,7 +193,7 @@ These requirements are effectively what makes it possible to bring pbrt to the GPU with limited changes to the core system. As a practical matter, these capabilities are only available via CUDA and OptiX on NVIDIA GPUs today, though we'd be happy to see pbrt running on any other GPUs that -provided those capabilities. +provide those capabilities. pbrt's GPU path currently requires CUDA 11.0 or later and OptiX 7.1 or later. Both Linux and Windows are supported. From 3d7692233e3004fdb021d9b681c7ba41aa1bf89d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 21 Mar 2022 08:20:11 -0700 Subject: [PATCH 015/149] WavefrontPathIntegrator: move GPU alloc prefetch to separate method (Trying to clean up Render() and make it easier to understand.) --- src/pbrt/wavefront/integrator.cpp | 75 ++++++++++++++++--------------- src/pbrt/wavefront/integrator.h | 4 ++ 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index eff406f81..e4bae6e8f 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -289,41 +289,8 @@ Float WavefrontPathIntegrator::Render() { Timer timer; // Prefetch allocations to GPU memory #ifdef PBRT_BUILD_GPU_RENDERER - if (Options->useGPU) { - int deviceIndex; - CUDA_CHECK(cudaGetDevice(&deviceIndex)); - int hasConcurrentManagedAccess; - CUDA_CHECK(cudaDeviceGetAttribute(&hasConcurrentManagedAccess, - cudaDevAttrConcurrentManagedAccess, - deviceIndex)); - - // Copy all of the scene data structures over to GPU memory. This - // ensures that there isn't a big performance hitch for the first batch - // of rays as that stuff is copied over on demand. - if (hasConcurrentManagedAccess) { - // Set things up so that we can still have read from the - // WavefrontPathIntegrator struct on the CPU without hurting - // performance. (This makes it possible to use the values of things - // like WavefrontPathIntegrator::haveSubsurface to conditionally launch - // kernels according to what's in the scene...) - CUDA_CHECK(cudaMemAdvise(this, sizeof(*this), cudaMemAdviseSetReadMostly, - /* ignored argument */ 0)); - CUDA_CHECK(cudaMemAdvise(this, sizeof(*this), - cudaMemAdviseSetPreferredLocation, deviceIndex)); - - // Copy all of the scene data structures over to GPU memory. This - // ensures that there isn't a big performance hitch for the first batch - // of rays as that stuff is copied over on demand. - CUDATrackedMemoryResource *mr = - dynamic_cast(memoryResource); - CHECK(mr); - mr->PrefetchToGPU(); - } else { - // TODO: on systems with basic unified memory, just launching a - // kernel should cause everything to be copied over. Is an empty - // kernel sufficient? - } - } + if (Options->useGPU) + PrefetchGPUAllocations(); #endif // PBRT_BUILD_GPU_RENDERER // Launch thread to copy image for display server, if enabled @@ -666,4 +633,42 @@ std::string WavefrontPathIntegrator::Stats::Print() const { return s; } +#ifdef PBRT_BUILD_GPU_RENDERER +void WavefrontPathIntegrator::PrefetchGPUAllocations() { + int deviceIndex; + CUDA_CHECK(cudaGetDevice(&deviceIndex)); + int hasConcurrentManagedAccess; + CUDA_CHECK(cudaDeviceGetAttribute(&hasConcurrentManagedAccess, + cudaDevAttrConcurrentManagedAccess, + deviceIndex)); + + // Copy all of the scene data structures over to GPU memory. This + // ensures that there isn't a big performance hitch for the first batch + // of rays as that stuff is copied over on demand. + if (hasConcurrentManagedAccess) { + // Set things up so that we can still have read from the + // WavefrontPathIntegrator struct on the CPU without hurting + // performance. (This makes it possible to use the values of things + // like WavefrontPathIntegrator::haveSubsurface to conditionally launch + // kernels according to what's in the scene...) + CUDA_CHECK(cudaMemAdvise(this, sizeof(*this), cudaMemAdviseSetReadMostly, + /* ignored argument */ 0)); + CUDA_CHECK(cudaMemAdvise(this, sizeof(*this), + cudaMemAdviseSetPreferredLocation, deviceIndex)); + + // Copy all of the scene data structures over to GPU memory. This + // ensures that there isn't a big performance hitch for the first batch + // of rays as that stuff is copied over on demand. + CUDATrackedMemoryResource *mr = + dynamic_cast(memoryResource); + CHECK(mr); + mr->PrefetchToGPU(); + } else { + // TODO: on systems with basic unified memory, just launching a + // kernel should cause everything to be copied over. Is an empty + // kernel sufficient? + } +} +#endif // PBRT_BUILD_GPU_RENDERER + } // namespace pbrt diff --git a/src/pbrt/wavefront/integrator.h b/src/pbrt/wavefront/integrator.h index ce481bb90..884d4320e 100644 --- a/src/pbrt/wavefront/integrator.h +++ b/src/pbrt/wavefront/integrator.h @@ -117,6 +117,10 @@ class WavefrontPathIntegrator { return rayQueues[(wavefrontDepth + 1) & 1]; } +#ifdef PBRT_BUILD_GPU_RENDERER + void PrefetchGPUAllocations(); +#endif // PBRT_BUILD_GPU_RENDERER + // WavefrontPathIntegrator Member Variables bool initializeVisibleSurface; bool haveSubsurface; From 83c3fa92218f308e88611f6dab61f277dd63d058 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 21 Mar 2022 08:32:27 -0700 Subject: [PATCH 016/149] WavefrontPathIntegrator: move display server logic out of this Render() method Ongoing work making Render() simpler and moving secondary functionality into separate methods... --- src/pbrt/wavefront/integrator.cpp | 224 ++++++++++++++++-------------- src/pbrt/wavefront/integrator.h | 8 ++ 2 files changed, 126 insertions(+), 106 deletions(-) diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index e4bae6e8f..ca5184e84 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -294,85 +294,8 @@ Float WavefrontPathIntegrator::Render() { #endif // PBRT_BUILD_GPU_RENDERER // Launch thread to copy image for display server, if enabled - RGB *displayRGB = nullptr, *displayRGBHost = nullptr; - std::atomic exitCopyThread{false}; - std::thread copyThread; - - if (!Options->displayServer.empty()) { -#ifdef PBRT_BUILD_GPU_RENDERER - if (Options->useGPU) { - // Allocate staging memory on the GPU to store the current WIP - // image. - CUDA_CHECK( - cudaMalloc(&displayRGB, resolution.x * resolution.y * sizeof(RGB))); - CUDA_CHECK( - cudaMemset(displayRGB, 0, resolution.x * resolution.y * sizeof(RGB))); - - // Host-side memory for the WIP Image. We'll just let this leak so - // that the lambda passed to DisplayDynamic below doesn't access - // freed memory after Render() returns... - displayRGBHost = new RGB[resolution.x * resolution.y]; - - copyThread = std::thread([&]() { - GPURegisterThread("DISPLAY_SERVER_COPY_THREAD"); - - // Copy back to the CPU using a separate stream so that we can - // periodically but asynchronously pick up the latest results - // from the GPU. - cudaStream_t memcpyStream; - CUDA_CHECK(cudaStreamCreate(&memcpyStream)); - GPUNameStream(memcpyStream, "DISPLAY_SERVER_COPY_STREAM"); - - // Copy back to the host from the GPU buffer, without any - // synthronization. - while (!exitCopyThread) { - CUDA_CHECK(cudaMemcpyAsync(displayRGBHost, displayRGB, - resolution.x * resolution.y * sizeof(RGB), - cudaMemcpyDeviceToHost, memcpyStream)); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - CUDA_CHECK(cudaStreamSynchronize(memcpyStream)); - } - - // Copy one more time to get the final image before exiting. - CUDA_CHECK(cudaMemcpy(displayRGBHost, displayRGB, - resolution.x * resolution.y * sizeof(RGB), - cudaMemcpyDeviceToHost)); - CUDA_CHECK(cudaDeviceSynchronize()); - }); - - // Now on the CPU side, give the display system a lambda that - // copies values from |displayRGBHost| into its buffers used for - // sending messages to the display program (i.e., tev). - DisplayDynamic(film.GetFilename(), {resolution.x, resolution.y}, - {"R", "G", "B"}, - [resolution, displayRGBHost]( - Bounds2i b, pstd::span> displayValue) { - int index = 0; - for (Point2i p : b) { - RGB rgb = displayRGBHost[p.x + p.y * resolution.x]; - displayValue[0][index] = rgb.r; - displayValue[1][index] = rgb.g; - displayValue[2][index] = rgb.b; - ++index; - } - }); - } else -#endif // PBRT_BUILD_GPU_RENDERER - DisplayDynamic( - film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, - [pixelBounds, this](Bounds2i b, - pstd::span> displayValue) { - int index = 0; - for (Point2i p : b) { - RGB rgb = - film.GetPixelRGB(pixelBounds.pMin + p, 1.f /* splat scale */); - for (int c = 0; c < 3; ++c) - displayValue[c][index] = rgb[c]; - ++index; - } - }); - } + if (!Options->displayServer.empty()) + StartDisplayThread(); // Loop over sample indices and evaluate pixel samples int firstSampleIndex = 0, lastSampleIndex = samplesPerPixel; @@ -483,19 +406,7 @@ Float WavefrontPathIntegrator::Render() { UpdateFilm(); // Copy updated film pixels to buffer for display -#ifdef PBRT_BUILD_GPU_RENDERER - if (Options->useGPU && !Options->displayServer.empty()) - GPUParallelFor( - "Update Display RGB Buffer", maxQueueSize, - PBRT_CPU_GPU_LAMBDA(int pixelIndex) { - Point2i pPixel = pixelSampleState.pPixel[pixelIndex]; - if (!InsideExclusive(pPixel, film.PixelBounds())) - return; - - Point2i p(pPixel - film.PixelBounds().pMin); - displayRGB[p.x + p.y * resolution.x] = film.GetPixelRGB(pPixel); - }); -#endif // PBRT_BUILD_GPU_RENDERER + UpdateDisplay(resolution); } progress.Update(); @@ -507,21 +418,9 @@ Float WavefrontPathIntegrator::Render() { GPUWait(); #endif // PBRT_BUILD_GPU_RENDERER Float seconds = timer.ElapsedSeconds(); - // Shut down display server thread, if active -#ifdef PBRT_BUILD_GPU_RENDERER - if (Options->useGPU) { - // Wait until rendering is all done before we start to shut down the - // display stuff.. - if (!Options->displayServer.empty()) { - exitCopyThread = true; - copyThread.join(); - } - // Another synchronization to make sure no kernels are running on the - // GPU so that we can safely access unified memory from the CPU. - GPUWait(); - } -#endif // PBRT_BUILD_GPU_RENDERER + // Shut down display server thread, if active + StopDisplayThread(); return seconds; } @@ -671,4 +570,117 @@ void WavefrontPathIntegrator::PrefetchGPUAllocations() { } #endif // PBRT_BUILD_GPU_RENDERER +void WavefrontPathIntegrator::StartDisplayThread() { + Bounds2i pixelBounds = film.PixelBounds(); + Vector2i resolution = pixelBounds.Diagonal(); + +#ifdef PBRT_BUILD_GPU_RENDERER + if (Options->useGPU) { + // Allocate staging memory on the GPU to store the current WIP + // image. + CUDA_CHECK(cudaMalloc(&displayRGB, resolution.x * resolution.y * sizeof(RGB))); + CUDA_CHECK(cudaMemset(displayRGB, 0, resolution.x * resolution.y * sizeof(RGB))); + + // Host-side memory for the WIP Image. We'll just let this leak so + // that the lambda passed to DisplayDynamic below doesn't access + // freed memory after Render() returns... + displayRGBHost = new RGB[resolution.x * resolution.y]; + + // Note that we can't just capture |this| for the member variables + // below because with managed memory on Windows, the CPU and GPU + // can't be accessing the same memory concurrently... + copyThread = std::thread([&exitCopyThread = this->exitCopyThread, + displayRGBHost = this->displayRGBHost, + displayRGB = this->displayRGB, resolution]() { + GPURegisterThread("DISPLAY_SERVER_COPY_THREAD"); + + // Copy back to the CPU using a separate stream so that we can + // periodically but asynchronously pick up the latest results + // from the GPU. + cudaStream_t memcpyStream; + CUDA_CHECK(cudaStreamCreate(&memcpyStream)); + GPUNameStream(memcpyStream, "DISPLAY_SERVER_COPY_STREAM"); + + // Copy back to the host from the GPU buffer, without any + // synthronization. + while (!exitCopyThread) { + CUDA_CHECK(cudaMemcpyAsync(displayRGBHost, displayRGB, + resolution.x * resolution.y * sizeof(RGB), + cudaMemcpyDeviceToHost, memcpyStream)); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + CUDA_CHECK(cudaStreamSynchronize(memcpyStream)); + } + + // Copy one more time to get the final image before exiting. + CUDA_CHECK(cudaMemcpy(displayRGBHost, displayRGB, + resolution.x * resolution.y * sizeof(RGB), + cudaMemcpyDeviceToHost)); + CUDA_CHECK(cudaDeviceSynchronize()); + }); + + // Now on the CPU side, give the display system a lambda that + // copies values from |displayRGBHost| into its buffers used for + // sending messages to the display program (i.e., tev). + DisplayDynamic(film.GetFilename(), {resolution.x, resolution.y}, + {"R", "G", "B"}, + [resolution, this](Bounds2i b, pstd::span> displayValue) { + int index = 0; + for (Point2i p : b) { + RGB rgb = displayRGBHost[p.x + p.y * resolution.x]; + displayValue[0][index] = rgb.r; + displayValue[1][index] = rgb.g; + displayValue[2][index] = rgb.b; + ++index; + } + }); + } else +#endif // PBRT_BUILD_GPU_RENDERER + DisplayDynamic(film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, + [pixelBounds, this](Bounds2i b, + pstd::span> displayValue) { + int index = 0; + for (Point2i p : b) { + RGB rgb = + film.GetPixelRGB(pixelBounds.pMin + p, 1.f /* splat scale */); + for (int c = 0; c < 3; ++c) + displayValue[c][index] = rgb[c]; + ++index; + } + }); +} + +void WavefrontPathIntegrator::UpdateDisplay(Vector2i resolution) { +#ifdef PBRT_BUILD_GPU_RENDERER + if (Options->useGPU && !Options->displayServer.empty()) + GPUParallelFor( + "Update Display RGB Buffer", maxQueueSize, + PBRT_CPU_GPU_LAMBDA(int pixelIndex) { + Point2i pPixel = pixelSampleState.pPixel[pixelIndex]; + if (!InsideExclusive(pPixel, film.PixelBounds())) + return; + + Point2i p(pPixel - film.PixelBounds().pMin); + displayRGB[p.x + p.y * resolution.x] = film.GetPixelRGB(pPixel); + }); +#endif // PBRT_BUILD_GPU_RENDERER +} + +void WavefrontPathIntegrator::StopDisplayThread() { +#ifdef PBRT_BUILD_GPU_RENDERER + if (Options->useGPU) { + // Wait until rendering is all done before we start to shut down the + // display stuff.. + if (!Options->displayServer.empty()) { + exitCopyThread = true; + copyThread.join(); + } + + // Another synchronization to make sure no kernels are running on the + // GPU so that we can safely access unified memory from the CPU. + GPUWait(); + } +#endif // PBRT_BUILD_GPU_RENDERER +} + } // namespace pbrt diff --git a/src/pbrt/wavefront/integrator.h b/src/pbrt/wavefront/integrator.h index 884d4320e..ee104ca47 100644 --- a/src/pbrt/wavefront/integrator.h +++ b/src/pbrt/wavefront/integrator.h @@ -121,6 +121,10 @@ class WavefrontPathIntegrator { void PrefetchGPUAllocations(); #endif // PBRT_BUILD_GPU_RENDERER + void StartDisplayThread(); + void UpdateDisplay(Vector2i resolution); + void StopDisplayThread(); + // WavefrontPathIntegrator Member Variables bool initializeVisibleSurface; bool haveSubsurface; @@ -173,6 +177,10 @@ class WavefrontPathIntegrator { GetBSSRDFAndProbeRayQueue *bssrdfEvalQueue = nullptr; SubsurfaceScatterQueue *subsurfaceScatterQueue = nullptr; + + RGB *displayRGB = nullptr, *displayRGBHost = nullptr; + std::atomic exitCopyThread{false}; + std::thread copyThread; }; } // namespace pbrt From 3e9c29b42e34bdc907114b63bc992f54a2f35ee0 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 21 Mar 2022 13:31:06 -0700 Subject: [PATCH 017/149] Fix Windows build --- src/pbrt/bxdfs.h | 3 +++ src/pbrt/wavefront/integrator.cpp | 16 +++++++++------- src/pbrt/wavefront/integrator.h | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/pbrt/bxdfs.h b/src/pbrt/bxdfs.h index 34dab08db..c14ba07af 100644 --- a/src/pbrt/bxdfs.h +++ b/src/pbrt/bxdfs.h @@ -738,6 +738,9 @@ class LayeredBxDF { f *= Tr(thickness, w); } // Initialize _interface_ for current interface surface +#ifdef interface // That's enough out of you, Windows. +#undef interface +#endif TopOrBottomBxDF interface; if (z == 0) interface = ⊥ diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index ca5184e84..da2c72ddc 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -78,7 +78,7 @@ static void updateMaterialNeeds( WavefrontPathIntegrator::WavefrontPathIntegrator( pstd::pmr::memory_resource *memoryResource, BasicScene &scene) - : memoryResource(memoryResource) { + : memoryResource(memoryResource), exitCopyThread(new std::atomic(false)) { ThreadLocal threadAllocators( [memoryResource]() { return Allocator(memoryResource); }); @@ -589,9 +589,9 @@ void WavefrontPathIntegrator::StartDisplayThread() { // Note that we can't just capture |this| for the member variables // below because with managed memory on Windows, the CPU and GPU // can't be accessing the same memory concurrently... - copyThread = std::thread([&exitCopyThread = this->exitCopyThread, - displayRGBHost = this->displayRGBHost, - displayRGB = this->displayRGB, resolution]() { + copyThread = new std::thread([exitCopyThread = this->exitCopyThread, + displayRGBHost = this->displayRGBHost, + displayRGB = this->displayRGB, resolution]() { GPURegisterThread("DISPLAY_SERVER_COPY_THREAD"); // Copy back to the CPU using a separate stream so that we can @@ -603,7 +603,7 @@ void WavefrontPathIntegrator::StartDisplayThread() { // Copy back to the host from the GPU buffer, without any // synthronization. - while (!exitCopyThread) { + while (!*exitCopyThread) { CUDA_CHECK(cudaMemcpyAsync(displayRGBHost, displayRGB, resolution.x * resolution.y * sizeof(RGB), cudaMemcpyDeviceToHost, memcpyStream)); @@ -672,8 +672,10 @@ void WavefrontPathIntegrator::StopDisplayThread() { // Wait until rendering is all done before we start to shut down the // display stuff.. if (!Options->displayServer.empty()) { - exitCopyThread = true; - copyThread.join(); + *exitCopyThread = true; + copyThread->join(); + delete copyThread; + copyThread = nullptr; } // Another synchronization to make sure no kernels are running on the diff --git a/src/pbrt/wavefront/integrator.h b/src/pbrt/wavefront/integrator.h index ee104ca47..46267e202 100644 --- a/src/pbrt/wavefront/integrator.h +++ b/src/pbrt/wavefront/integrator.h @@ -179,8 +179,8 @@ class WavefrontPathIntegrator { SubsurfaceScatterQueue *subsurfaceScatterQueue = nullptr; RGB *displayRGB = nullptr, *displayRGBHost = nullptr; - std::atomic exitCopyThread{false}; - std::thread copyThread; + std::atomic *exitCopyThread; + std::thread *copyThread; }; } // namespace pbrt From 81c2a8135b95175c8c422a397509df358f1919ac Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 23 Mar 2022 05:52:02 -0700 Subject: [PATCH 018/149] Disable clang-12 build in github actions. Workaround multi-day github actions flakiness: E: Failed to fetch http://azure.archive.ubuntu.com/ubuntu/pool/universe/l/llvm-toolchain-12/libclang-12-dev_12.0.0-3ubuntu1~20.04.4_amd64.deb 404 Not Found [IP: 52.252.75.106 80] et al. --- .github/workflows/ci-cpu-linux.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-cpu-linux.yml b/.github/workflows/ci-cpu-linux.yml index 0199250f1..0a535549a 100644 --- a/.github/workflows/ci-cpu-linux.yml +++ b/.github/workflows/ci-cpu-linux.yml @@ -32,10 +32,11 @@ jobs: cc: "clang-11", cxx: "clang++-11", } - - { - cc: "clang-12", - cxx: "clang++-12", - } +# WAR github actions flakiness +# - { +# cc: "clang-12", +# cxx: "clang++-12", +# } fail-fast: false From 87dcc6ab903b8b58aaabce20f1f4e746f6a681e2 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 23 Mar 2022 10:47:59 -0700 Subject: [PATCH 019/149] Windows: set console mode so colored text output works --- src/pbrt/util/log.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pbrt/util/log.cpp b/src/pbrt/util/log.cpp index 62750b31c..442f57ab1 100644 --- a/src/pbrt/util/log.cpp +++ b/src/pbrt/util/log.cpp @@ -109,6 +109,14 @@ void InitLogging(LogLevel level, std::string logFile, bool logUtilization, bool logging::logLevel = LogLevel::Verbose; } +#ifdef PBRT_IS_WINDOWS + HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD consoleMode; + GetConsoleMode(hStdout, &consoleMode); + consoleMode |= 0xc; // virtual terminal processing, disable newline auto return + SetConsoleMode(hStdout, consoleMode); +#endif // PBRT_IS_WINDOWS + if (level == LogLevel::Invalid) ErrorExit("Invalid --log-level specified."); From d24b33cc43be5a8828d14e88032fee9d1a2c6341 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 23 Mar 2022 10:59:26 -0700 Subject: [PATCH 020/149] Windows: check return value of CreateFileW() correctly On failure, it doesn't return NULL, but returns INVALID_HANDLE_VALUE... This was causing pbrt to cryptically report "The parameter is incorrect" when it should have been saying that a file was not found. --- src/pbrt/parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/parser.cpp b/src/pbrt/parser.cpp index 159c13fd2..9a18a595d 100644 --- a/src/pbrt/parser.cpp +++ b/src/pbrt/parser.cpp @@ -195,7 +195,7 @@ std::unique_ptr Tokenizer::CreateFromFile( HANDLE fileHandle = CreateFileW(WStringFromUTF8(filename).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - if (!fileHandle) + if (fileHandle == INVALID_HANDLE_VALUE) return errorReportLambda(); size_t len = GetFileSize(fileHandle, 0); From ab56d388f8c0df9cc35899c14122ca66a88af477 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 7 Apr 2022 17:17:15 -0700 Subject: [PATCH 021/149] Delete blender exporter README (centeralizing this stuff on the website) --- exporters/Blender/Readme.md | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 exporters/Blender/Readme.md diff --git a/exporters/Blender/Readme.md b/exporters/Blender/Readme.md deleted file mode 100644 index 23780fdb2..000000000 --- a/exporters/Blender/Readme.md +++ /dev/null @@ -1,8 +0,0 @@ -Pbrt-v4 exporter for blender can be found here: -https://github.com/stig-atle/io_scene_pbrt/tree/Pbrt-v4-support - -Either clone the Pbrt-v4-support branch and place it in the blender addon folder, -or download as zip and install through the addon menu from the following url: -https://github.com/stig-atle/io_scene_pbrt/archive/refs/heads/Pbrt-v4-support.zip - -For more information about the exporter and how to use it - visit the repository. \ No newline at end of file From b99d83727564f2d69d18cea2c119844591c4aa12 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 18 Apr 2022 09:41:50 -0700 Subject: [PATCH 022/149] imgtool convert: only convert to fp32 when useful (Thus, for example, imgtool convert foo.png --outfile bar.png now always gives a pixel-identical result; before the dithering in the reverse conversion would very occasionally give a different pixel value.) --- src/pbrt/cmd/imgtool.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 9b64c9b6f..89f0ce83e 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -1736,7 +1736,8 @@ int convert(std::vector args) { } if (hasAOVs && !HasExtension(outFile, "exr")) { - Warning("%s: image has non-RGB channels but converting to an image format that can't store them. Converting RGB only.", + Warning("%s: image has non-RGBA channels but converting to an image format " + "that can't store them. Converting RGB only.", inFile); channelNames = "R,G,B"; } @@ -1797,9 +1798,14 @@ int convert(std::vector args) { res = image.Resolution(); } - // Convert to a 32-bit format for maximum accuracy in the following - // processing. - if (!Is32Bit(image.Format())) + // Count how many of the following operations modify pixel values + // rather than copying existing ones. (Takes heavy advantage of + // implicit bool->int conversions.) + int nModifyingOps = (!colorspace.empty() + (scale != 1) + (gamma != 1) + tonemap + + preserveColors + acesFilmic); + // Convert to a 32-bit format for maximum accuracy if we're applying + // multiple operations to the pixel values. + if (nModifyingOps > 1 && !Is32Bit(image.Format())) image = image.ConvertToFormat(PixelFormat::Float); if (clamp < Infinity) { From 5677b5ad62b965bf65f5addbc2a5e722b1ede8a1 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 18 Apr 2022 09:45:10 -0700 Subject: [PATCH 023/149] Fix Image::Write() so that RGBA images don't lose their alpha channel Also, slightly simplify Image::WritePNG() --- src/pbrt/util/image.cpp | 101 +++++++++++++++++++++++----------------- src/pbrt/util/image.h | 3 ++ 2 files changed, 60 insertions(+), 44 deletions(-) diff --git a/src/pbrt/util/image.cpp b/src/pbrt/util/image.cpp index b4c8536b1..d43678580 100644 --- a/src/pbrt/util/image.cpp +++ b/src/pbrt/util/image.cpp @@ -942,6 +942,18 @@ bool Image::Write(std::string name, const ImageMetadata &metadata) const { outImage = outImage.SelectChannels(desc); break; } + case 4: { + ImageChannelDesc desc = outImage.GetChannelDesc({"R", "G", "B", "A"}); + if (!desc) + // Still go for it. + Warning("%s: image has 4 channels but they are not R, G, B, and A. Image may be " + "garbled.", + name); + else + // Reorder them as RGBA. + outImage = outImage.SelectChannels(desc); + break; + } default: { ImageChannelDesc desc = outImage.GetChannelDesc({"R", "G", "B"}); if (!desc) { @@ -963,10 +975,11 @@ bool Image::Write(std::string name, const ImageMetadata &metadata) const { break; } } - CHECK(outImage.NChannels() == 1 || outImage.NChannels() == 3); + CHECK(outImage.NChannels() == 1 || outImage.NChannels() == 3 || + outImage.NChannels() == 4); ImageMetadata outMetadata = metadata; - if (outImage.NChannels() == 3 && *metadata.GetColorSpace() != *RGBColorSpace::sRGB) { + if (outImage.NChannels() != 1 && *metadata.GetColorSpace() != *RGBColorSpace::sRGB) { Warning("%s: converting pixel colors to sRGB to match output image format.", name); SquareMatrix<3> m = @@ -1404,6 +1417,20 @@ std::string Image::ToString() const { encoding ? encoding.ToString().c_str() : "(nullptr)"); } +std::unique_ptr Image::QuantizePixelsToU256(int *nOutOfGamut) const { + std::unique_ptr u256 = std::make_unique(NChannels() * resolution.x * resolution.y); + for (int y = 0; y < resolution.y; ++y) + for (int x = 0; x < resolution.x; ++x) + for (int c = 0; c < NChannels(); ++c) { + Float dither = -.5f + BlueNoise(c, {x, y}); + Float v = GetChannel({x, y}, c); + if (v < 0 || v > 1) + ++(*nOutOfGamut); + u256[NChannels() * (y * resolution.x + x) + c] = LinearToSRGB8(v, dither); + } + return u256; +} + bool Image::WritePNG(const std::string &filename, const ImageMetadata &metadata) const { unsigned int error = 0; int nOutOfGamut = 0; @@ -1411,48 +1438,29 @@ bool Image::WritePNG(const std::string &filename, const ImageMetadata &metadata) unsigned char *png; size_t pngSize; - if (format == PixelFormat::U256) { - if (NChannels() == 1) - error = lodepng_encode_memory(&png, &pngSize, p8.data(), resolution.x, - resolution.y, LCT_GREY, 8 /* bitdepth */); - else if (NChannels() == 3) - // TODO: it would be nice to store the color encoding used in the - // PNG metadata... - error = lodepng_encode_memory(&png, &pngSize, p8.data(), resolution.x, - resolution.y, LCT_RGB, 8); - else - LOG_FATAL("Unhandled channel count in WritePNG(): %d", NChannels()); - } else if (NChannels() == 3) { - // It may not actually be RGB, but that's what PNG's going to - // assume.. - std::unique_ptr rgb8 = - std::make_unique(3 * resolution.x * resolution.y); - for (int y = 0; y < resolution.y; ++y) - for (int x = 0; x < resolution.x; ++x) - for (int c = 0; c < 3; ++c) { - Float dither = -.5f + BlueNoise(c, {x, y}); - Float v = GetChannel({x, y}, c); - if (v < 0 || v > 1) - ++nOutOfGamut; - rgb8[3 * (y * resolution.x + x) + c] = LinearToSRGB8(v, dither); - } - - error = lodepng_encode_memory(&png, &pngSize, rgb8.get(), resolution.x, - resolution.y, LCT_RGB, 8); - } else if (NChannels() == 1) { - std::unique_ptr y8 = - std::make_unique(resolution.x * resolution.y); - for (int y = 0; y < resolution.y; ++y) - for (int x = 0; x < resolution.x; ++x) { - Float dither = -.5f + BlueNoise(0, {x, y}); - Float v = GetChannel({x, y}, 0); - if (v < 0 || v > 1) - ++nOutOfGamut; - y8[y * resolution.x + x] = LinearToSRGB8(v, dither); - } + LodePNGColorType pngColor; + switch (NChannels()) { + case 1: + pngColor = LCT_GREY; + break; + case 3: + // TODO: it would be nice to store the color encoding used in the PNG metadata... + pngColor = LCT_RGB; + break; + case 4: + pngColor = LCT_RGBA; + break; + default: + LOG_FATAL("Unexpected number of channels in WritePNG()"); + } - error = lodepng_encode_memory(&png, &pngSize, y8.get(), resolution.x, - resolution.y, LCT_GREY, 8 /* bitdepth */); + if (format == PixelFormat::U256) { + error = lodepng_encode_memory(&png, &pngSize, p8.data(), resolution.x, + resolution.y, pngColor, 8 /* bitdepth */); + } else { + std::unique_ptr pix8 = QuantizePixelsToU256(&nOutOfGamut); + error = lodepng_encode_memory(&png, &pngSize, pix8.get(), resolution.x, + resolution.y, pngColor, 8 /* bitdepth */); } if (nOutOfGamut > 0) @@ -1655,7 +1663,12 @@ static ImageAndMetadata ReadHDR(const std::string &filename, Allocator alloc) { bool Image::WritePFM(const std::string &filename, const ImageMetadata &metadata) const { FILE *fp = FOpenWrite(filename); if (!fp) { - Error("Unable to open output PFM file \"%s\"", filename); + Error("%s: unable to open output PFM file.", filename); + return false; + } + + if (NChannels() != 3) { + Error("%s: only 3-channel images are supported for PFM."); return false; } diff --git a/src/pbrt/util/image.h b/src/pbrt/util/image.h index b2621edf4..4ba99e5ec 100644 --- a/src/pbrt/util/image.h +++ b/src/pbrt/util/image.h @@ -19,6 +19,7 @@ #include #include #include +#include #include namespace pbrt { @@ -407,6 +408,8 @@ class Image { bool WritePFM(const std::string &name, const ImageMetadata &metadata) const; bool WritePNG(const std::string &name, const ImageMetadata &metadata) const; + std::unique_ptr QuantizePixelsToU256(int *nOutOfGamut) const; + // Image Private Members PixelFormat format; Point2i resolution; From 60e95c27965756c709eea54a29cd2bba2323bf7e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 18 Apr 2022 12:52:28 -0700 Subject: [PATCH 024/149] ImageIO tests: generate u8 reference data for PNG tests (Allows cleaning up some unnecessary complexity in checking that round trips come out the same.) --- src/pbrt/util/image_test.cpp | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/pbrt/util/image_test.cpp b/src/pbrt/util/image_test.cpp index 9f96678b2..d2cad161b 100644 --- a/src/pbrt/util/image_test.cpp +++ b/src/pbrt/util/image_test.cpp @@ -79,6 +79,18 @@ static pstd::vector GetFloatPixels(Point2i res, int nc) { return p; } +static pstd::vector GetU8Pixels(Point2i res, int nc) { + pstd::vector p; + for (int y = 0; y < res[1]; ++y) + for (int x = 0; x < res[0]; ++x) + for (int c = 0; c < nc; ++c) + if (c == 0) + p.push_back(x + res[0] * y); + else + p.push_back(x * y + c * (x - y)); + return p; +} + static Float modelQuantization(Float value, PixelFormat format) { switch (format) { case PixelFormat::U256: @@ -456,9 +468,9 @@ TEST(Image, ExrMetadata) { TEST(Image, PngYIO) { Point2i res(11, 50); - pstd::vector rgbPixels = GetFloatPixels(res, 1); + pstd::vector rgbPixels = GetU8Pixels(res, 1); - Image image(rgbPixels, res, {"Y"}); + Image image(rgbPixels, res, {"Y"}, ColorEncoding::sRGB); EXPECT_TRUE(image.Write("test.png")); ImageAndMetadata read = Image::Read("test.png"); @@ -467,23 +479,19 @@ TEST(Image, PngYIO) { ASSERT_TRUE(read.image.Encoding() != nullptr); for (int y = 0; y < res[1]; ++y) - for (int x = 0; x < res[0]; ++x) { - EXPECT_LE(sRGBRoundTrip(image.GetChannel({x, y}, 0), -.5f), - read.image.GetChannel({x, y}, 0)) - << " x " << x << ", y " << y << ", orig " << rgbPixels[y * res[0] + x]; - EXPECT_LE(read.image.GetChannel({x, y}, 0), - sRGBRoundTrip(image.GetChannel({x, y}, 0), 0.5f)) + for (int x = 0; x < res[0]; ++x) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[y * res[0] + x]), + read.image.GetChannel({x, y}, 0)) << " x " << x << ", y " << y << ", orig " << rgbPixels[y * res[0] + x]; - } EXPECT_TRUE(RemoveFile("test.png")); } TEST(Image, PngRgbIO) { Point2i res(11, 50); - pstd::vector rgbPixels = GetFloatPixels(res, 3); + pstd::vector rgbPixels = GetU8Pixels(res, 3); - Image image(rgbPixels, res, {"R", "G", "B"}); + Image image(rgbPixels, res, {"R", "G", "B"}, ColorEncoding::sRGB); EXPECT_TRUE(image.Write("test.png")); ImageAndMetadata read = Image::Read("test.png"); @@ -498,12 +506,8 @@ TEST(Image, PngRgbIO) { for (int y = 0; y < res[1]; ++y) for (int x = 0; x < res[0]; ++x) for (int c = 0; c < 3; ++c) { - EXPECT_LE(sRGBRoundTrip(image.GetChannel({x, y}, c), -.5f), - read.image.GetChannel({x, y}, c)) - << " x " << x << ", y " << y << ", c " << c << ", orig " - << rgbPixels[3 * y * res[0] + 3 * x + c]; - EXPECT_LE(read.image.GetChannel({x, y}, c), - sRGBRoundTrip(image.GetChannel({x, y}, c), 0.5f)) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), + image.GetChannel({x, y}, c)) << " x " << x << ", y " << y << ", c " << c << ", orig " << rgbPixels[3 * y * res[0] + 3 * x + c]; } @@ -513,9 +517,9 @@ TEST(Image, PngRgbIO) { TEST(Image, PngEmojiIO) { Point2i res(11, 50); - pstd::vector rgbPixels = GetFloatPixels(res, 3); + pstd::vector rgbPixels = GetU8Pixels(res, 3); - Image image(rgbPixels, res, {"R", "G", "B"}); + Image image(rgbPixels, res, {"R", "G", "B"}, ColorEncoding::sRGB); // trex.png const uint8_t fn[] = {0xF0, 0x9F, 0xA6, 0x96, '.', 'p', 'n', 'g', '\0'}; std::string filename((char *)fn, strlen((char *)fn)); @@ -533,12 +537,8 @@ TEST(Image, PngEmojiIO) { for (int y = 0; y < res[1]; ++y) for (int x = 0; x < res[0]; ++x) for (int c = 0; c < 3; ++c) { - EXPECT_LE(sRGBRoundTrip(image.GetChannel({x, y}, c), -.5f), - read.image.GetChannel({x, y}, c)) - << " x " << x << ", y " << y << ", c " << c << ", orig " - << rgbPixels[3 * y * res[0] + 3 * x + c]; - EXPECT_LE(read.image.GetChannel({x, y}, c), - sRGBRoundTrip(image.GetChannel({x, y}, c), 0.5f)) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), + image.GetChannel({x, y}, c)) << " x " << x << ", y " << y << ", c " << c << ", orig " << rgbPixels[3 * y * res[0] + 3 * x + c]; } From cacd50aa4248d095c27c4788f691ba1a80e7740a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 18 Apr 2022 13:06:43 -0700 Subject: [PATCH 025/149] Add support for qoi format images https://qoiformat.org --- .gitmodules | 3 ++ CMakeLists.txt | 2 + src/ext/CMakeLists.txt | 6 +++ src/ext/qoi | 1 + src/pbrt/util/image.cpp | 89 ++++++++++++++++++++++++++++++++++++ src/pbrt/util/image.h | 1 + src/pbrt/util/image_test.cpp | 64 ++++++++++++++++++++++++++ 7 files changed, 166 insertions(+) create mode 160000 src/ext/qoi diff --git a/.gitmodules b/.gitmodules index ba41f6b2f..1381a3521 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,3 +30,6 @@ [submodule "src/ext/utf8proc"] path = src/ext/utf8proc url = https://github.com/JuliaStrings/utf8proc.git +[submodule "src/ext/qoi"] + path = src/ext/qoi + url = https://github.com/phoboslab/qoi.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 1619858f8..b7af2eefe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ check_ext ("double-conversion" "double-conversion/cmake" cc1f75a114aca8d2af69f73 check_ext ("filesystem" "filesystem/filesystem" c5f9de30142453eb3c6fe991e82dfc2583373116) check_ext ("libdeflate" "libdeflate/common" 1fd0bea6ca2073c68493632dafc4b1ddda1bcbc3) check_ext ("lodepng" "lodepng/examples" 8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a) +check_ext ("qoi" "qoi" 028c75fd26e5e0758c7c711216c00404994c1ad3) check_ext ("stb" "stb/tools" af1a5bc352164740c1cc1354942b1c6b72eacb8a) check_ext ("utf8proc" "utf8proc/bench" 2484e2ed5e1d9c19edcccf392a7d9920ad90dfaf) check_ext ("zlib" "zlib/doc" 54d591eabf9fe0e84c725638f8d5d8d202a093fa) @@ -829,6 +830,7 @@ target_include_directories (pbrt_lib PUBLIC src src/ext ${STB_INCLUDE} + ${QOI_INCLUDE} ${OPENEXR_INCLUDE} ${ZLIB_INCLUDE_DIRS} ${LIBDEFLATE_INCLUDE_DIRS} diff --git a/src/ext/CMakeLists.txt b/src/ext/CMakeLists.txt index 3968d18f3..4aac438cb 100644 --- a/src/ext/CMakeLists.txt +++ b/src/ext/CMakeLists.txt @@ -146,3 +146,9 @@ set_property (TARGET flip_lib PROPERTY FOLDER "ext") set (UTF8PROC_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/utf8proc PARENT_SCOPE) add_subdirectory (utf8proc) + +########################################################################### +# qoi + +set (QOI_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/qoi PARENT_SCOPE) + diff --git a/src/ext/qoi b/src/ext/qoi new file mode 160000 index 000000000..028c75fd2 --- /dev/null +++ b/src/ext/qoi @@ -0,0 +1 @@ +Subproject commit 028c75fd26e5e0758c7c711216c00404994c1ad3 diff --git a/src/pbrt/util/image.cpp b/src/pbrt/util/image.cpp index d43678580..9146d11e1 100644 --- a/src/pbrt/util/image.cpp +++ b/src/pbrt/util/image.cpp @@ -46,6 +46,10 @@ #define STBI_WINDOWS_UTF8 #include +#define QOI_NO_STDIO +#define QOI_IMPLEMENTATION +#include + namespace pbrt { std::string ToString(PixelFormat format) { @@ -867,6 +871,7 @@ static ImageAndMetadata ReadPNG(const std::string &name, Allocator alloc, ColorEncoding encoding); static ImageAndMetadata ReadPFM(const std::string &filename, Allocator alloc); static ImageAndMetadata ReadHDR(const std::string &filename, Allocator alloc); +static ImageAndMetadata ReadQOI(const std::string &filename, Allocator alloc); // ImageIO Function Definitions ImageAndMetadata Image::Read(std::string name, Allocator alloc, ColorEncoding encoding) { @@ -878,6 +883,8 @@ ImageAndMetadata Image::Read(std::string name, Allocator alloc, ColorEncoding en return ReadPFM(name, alloc); else if (HasExtension(name, "hdr")) return ReadHDR(name, alloc); + else if (HasExtension(name, "qoi")) + return ReadQOI(name, alloc); else { int x, y, n; unsigned char *data = stbi_load(name.c_str(), &x, &y, &n, 0); @@ -1001,6 +1008,8 @@ bool Image::Write(std::string name, const ImageMetadata &metadata) const { return outImage.WritePFM(name, outMetadata); else if (HasExtension(name, "png")) return outImage.WritePNG(name, outMetadata); + else if (HasExtension(name, "qoi")) + return outImage.WriteQOI(name, outMetadata); else { Error("%s: no support for writing images with this extension", name); return false; @@ -1483,6 +1492,58 @@ bool Image::WritePNG(const std::string &filename, const ImageMetadata &metadata) return true; } +bool Image::WriteQOI(const std::string &filename, const ImageMetadata &metadata) const { + Image image = *this; + void *qoiPixels = nullptr; + int qoiSize = 0; + + qoi_desc desc; + desc.width = resolution.x; + desc.height = resolution.y; + desc.channels = NChannels(); + if (Encoding() && !Encoding().Is() && + !Encoding().Is()) { + Error("%s: only linear and sRGB encodings are supported by QOI.", Encoding().ToString()); //filename); + return false; + } + desc.colorspace = Encoding().Is() ? QOI_LINEAR : QOI_SRGB; + + if (NChannels() == 4) { + // Try to order it as QOI expects. Though continue on if we don't + // find these particular channel names.a + ImageChannelDesc desc = GetChannelDesc({"R", "G", "B", "A"}); + if (desc) + image = SelectChannels(desc); + } else if (NChannels() == 3) { + // Similarly try to get the channels in order.. + ImageChannelDesc desc = GetChannelDesc({"R", "G", "B"}); + if (desc) + image = SelectChannels(desc); + } else { + Error("%s: only 3 and 4 channel images are supported for QOI", filename); + return false; + } + + if (format == PixelFormat::U256) + qoiPixels = qoi_encode(image.RawPointer({0, 0}), &desc, &qoiSize); + else { + int nOutOfGamut = 0; + std::unique_ptr rgba8 = QuantizePixelsToU256(&nOutOfGamut); + if (nOutOfGamut > 0) + Warning("%s: %d out of gamut pixel channels clamped to [0,1].", filename, + nOutOfGamut); + + qoiPixels = qoi_encode(rgba8.get(), &desc, &qoiSize); + } + + bool success = WriteFileContents(filename, std::string((const char *)qoiPixels, qoiSize)); + if (!success) + Error("%s: error writing QOI file.", filename); + + free(qoiPixels); + return success; +} + /////////////////////////////////////////////////////////////////////////// // PFM Function Definitions @@ -1660,6 +1721,34 @@ static ImageAndMetadata ReadHDR(const std::string &filename, Allocator alloc) { } } +static ImageAndMetadata ReadQOI(const std::string &filename, Allocator alloc) { + std::string contents = ReadFileContents(filename); + qoi_desc desc; + void *pixels = qoi_decode(contents.data(), contents.size(), &desc, 0 /* channels */); + CHECK(pixels != nullptr); // qoi failure + + ImageMetadata metadata; + metadata.colorSpace = RGBColorSpace::sRGB; + + std::vector channelNames{"R", "G", "B"}; + if (desc.channels == 4) + channelNames.push_back("A"); + else + CHECK_EQ(3, desc.channels); + + CHECK(desc.colorspace == QOI_SRGB || desc.colorspace == QOI_LINEAR); + ColorEncoding encoding = (desc.colorspace == QOI_SRGB) ? ColorEncoding::sRGB : + ColorEncoding::Linear; + + Image image(PixelFormat::U256, Point2i(desc.width, desc.height), channelNames, encoding, alloc); + std::memcpy(image.RawPointer({0, 0}), pixels, desc.width * desc.height * desc.channels); + + free(pixels); + + return ImageAndMetadata{image, metadata}; +} + + bool Image::WritePFM(const std::string &filename, const ImageMetadata &metadata) const { FILE *fp = FOpenWrite(filename); if (!fp) { diff --git a/src/pbrt/util/image.h b/src/pbrt/util/image.h index 4ba99e5ec..6771eeb9a 100644 --- a/src/pbrt/util/image.h +++ b/src/pbrt/util/image.h @@ -407,6 +407,7 @@ class Image { bool WriteEXR(const std::string &name, const ImageMetadata &metadata) const; bool WritePFM(const std::string &name, const ImageMetadata &metadata) const; bool WritePNG(const std::string &name, const ImageMetadata &metadata) const; + bool WriteQOI(const std::string &name, const ImageMetadata &metadata) const; std::unique_ptr QuantizePixelsToU256(int *nOutOfGamut) const; diff --git a/src/pbrt/util/image_test.cpp b/src/pbrt/util/image_test.cpp index d2cad161b..370750abd 100644 --- a/src/pbrt/util/image_test.cpp +++ b/src/pbrt/util/image_test.cpp @@ -546,6 +546,66 @@ TEST(Image, PngEmojiIO) { EXPECT_TRUE(RemoveFile(filename.c_str())); } +TEST(Image, QoiRgbIO) { + Point2i res(11, 50); + pstd::vector rgbPixels = GetU8Pixels(res, 3); + + Image image(rgbPixels, res, {"R", "G", "B"}, ColorEncoding::sRGB); + EXPECT_TRUE(image.Write("test.qoi")); + ImageAndMetadata read = Image::Read("test.qoi"); + + EXPECT_EQ(image.Resolution(), read.image.Resolution()); + EXPECT_EQ(read.image.Format(), PixelFormat::U256); + ASSERT_TRUE(read.image.Encoding() != nullptr); + // EXPECT_EQ(*read.image.Encoding(), *ColorEncoding::sRGB); + ASSERT_TRUE((bool)read.metadata.colorSpace); + ASSERT_TRUE(*read.metadata.colorSpace != nullptr); + EXPECT_EQ(*RGBColorSpace::sRGB, *read.metadata.GetColorSpace()); + + for (int y = 0; y < res[1]; ++y) + for (int x = 0; x < res[0]; ++x) + for (int c = 0; c < 3; ++c) { + EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), + image.GetChannel({x, y}, c)) + << " x " << x << ", y " << y << ", c " << c << ", orig " + << rgbPixels[3 * y * res[0] + 3 * x + c]; + } + + EXPECT_TRUE(RemoveFile("test.qoi")); +} + +TEST(Image, QoiRgbaIO) { + Point2i res(11, 50); + pstd::vector rgbPixels = GetU8Pixels(res, 4); + + // Intentionally out of normal order... + Image image(rgbPixels, res, {"A", "R", "G", "B"}, ColorEncoding::sRGB); + EXPECT_TRUE(image.Write("test-rgba.qoi")); + ImageAndMetadata read = Image::Read("test-rgba.qoi"); + + EXPECT_EQ(image.Resolution(), read.image.Resolution()); + EXPECT_EQ(read.image.Format(), PixelFormat::U256); + ASSERT_TRUE(read.image.Encoding() != nullptr); + // EXPECT_EQ(*read.image.Encoding(), *ColorEncoding::sRGB); + ASSERT_TRUE((bool)read.metadata.colorSpace); + ASSERT_TRUE(*read.metadata.colorSpace != nullptr); + EXPECT_EQ(*RGBColorSpace::sRGB, *read.metadata.GetColorSpace()); + + ImageChannelDesc desc = image.GetChannelDesc({"A", "R", "G", "B"}); + ASSERT_TRUE((bool)desc); + + for (int y = 0; y < res[1]; ++y) + for (int x = 0; x < res[0]; ++x) { + ImageChannelValues v = image.GetChannels({x, y}, desc); + for (int c = 0; c < 4; ++c) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 4 * (y * res[0] + x)]), v[c]) + << " x " << x << ", y " << y << ", c " << c << ", orig " + << rgbPixels[c + 4 * (y * res[0] + x)]; + } + + EXPECT_TRUE(RemoveFile("test-rgba.qoi")); +} + TEST(Image, SampleSimple) { pstd::vector texels = {Float(0), Float(1), Float(0), Float(0)}; Image zeroOne(texels, {2, 2}, {"Y"}); @@ -751,3 +811,7 @@ TEST(ImageIO, RoundTripPFM) { TEST(ImageIO, RoundTripPNG) { TestRoundTrip("out.png"); } + +TEST(ImageIO, RoundTripQOI) { + TestRoundTrip("out.qoi"); +} From a4f48c69aaef8c5125df8b1b0e791a29c475f965 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 25 Apr 2022 17:53:15 -0700 Subject: [PATCH 026/149] cmd/imgtool: refactor OptiX denoiser use into gpu/denoiser.* --- CMakeLists.txt | 2 + src/pbrt/cmd/imgtool.cpp | 164 ++++++++------------------------------ src/pbrt/gpu/denoiser.cpp | 133 +++++++++++++++++++++++++++++++ src/pbrt/gpu/denoiser.h | 35 ++++++++ src/pbrt/gpu/util.cpp | 4 + src/pbrt/gpu/util.h | 2 + 6 files changed, 211 insertions(+), 129 deletions(-) create mode 100644 src/pbrt/gpu/denoiser.cpp create mode 100644 src/pbrt/gpu/denoiser.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b7af2eefe..2a6ffee48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -672,11 +672,13 @@ SET (PBRT_UTIL_SOURCE_HEADERS if (PBRT_CUDA_ENABLED) set (PBRT_GPU_SOURCE src/pbrt/gpu/aggregate.cpp + src/pbrt/gpu/denoiser.cpp src/pbrt/gpu/memory.cpp src/pbrt/gpu/util.cpp ) set (PBRT_GPU_SOURCE_HEADERS src/pbrt/gpu/aggregate.h + src/pbrt/gpu/denoiser.h src/pbrt/gpu/memory.h src/pbrt/gpu/optix.h src/pbrt/gpu/util.h diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 89f0ce83e..a5c2e4cf9 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef PBRT_BUILD_GPU_RENDERER +#include +#include +#endif // PBRT_BUILD_GPU_RENDERER #include #include #include @@ -39,31 +43,6 @@ extern "C" { #include -#ifdef PBRT_BUILD_GPU_RENDERER - -#include -#include - -#include -#include - -#include -#include - -#define OPTIX_CHECK(EXPR) \ - do { \ - OptixResult res = EXPR; \ - if (res != OPTIX_SUCCESS) \ - LOG_FATAL("OptiX call " #EXPR " failed with code %d: \"%s\"", int(res), \ - optixGetErrorString(res)); \ - } while (false) /* eat semicolon */ -#endif - -// Stop that, Windows. -#ifdef RGB -#undef RGB -#endif - using namespace pbrt; struct CommandUsage { @@ -2504,19 +2483,11 @@ int denoise_optix(std::vector args) { if (outFilename.empty()) usage("denoise-optix", "output image filename must be provided."); - CUDA_CHECK(cudaFree(nullptr)); - - CUcontext cudaContext; - CU_CHECK(cuCtxGetCurrent(&cudaContext)); - CHECK(cudaContext != nullptr); - - OPTIX_CHECK(optixInit()); - OptixDeviceContext optixContext; - OPTIX_CHECK(optixDeviceContextCreate(cudaContext, 0, &optixContext)); - ImageAndMetadata im = Image::Read(inFilename); Image &image = im.image; + CUDA_CHECK(cudaFree(nullptr)); + int nLayers = 3; ImageChannelDesc desc[3] = { image.GetChannelDesc({"R", "G", "B"}), @@ -2537,114 +2508,49 @@ int denoise_optix(std::vector args) { nLayers = 1; } - OptixDenoiserOptions options = {}; -#if (OPTIX_VERSION >= 70300) - if (nLayers == 3) - options.guideAlbedo = options.guideNormal = 1; - - OptixDenoiser denoiserHandle; - OPTIX_CHECK(optixDenoiserCreate(optixContext, OPTIX_DENOISER_MODEL_KIND_HDR, &options, - &denoiserHandle)); -#else - options.inputKind = (nLayers == 3) ? OPTIX_DENOISER_INPUT_RGB_ALBEDO_NORMAL - : OPTIX_DENOISER_INPUT_RGB; - - OptixDenoiser denoiserHandle; - OPTIX_CHECK(optixDenoiserCreate(optixContext, &options, &denoiserHandle)); - - OPTIX_CHECK( - optixDenoiserSetModel(denoiserHandle, OPTIX_DENOISER_MODEL_KIND_HDR, nullptr, 0)); -#endif + Denoiser denoiser((Vector2i)image.Resolution(), nLayers == 3); - OptixDenoiserSizes memorySizes; - OPTIX_CHECK(optixDenoiserComputeMemoryResources(denoiserHandle, image.Resolution().x, - image.Resolution().y, &memorySizes)); - - void *denoiserState; - CUDA_CHECK(cudaMalloc(&denoiserState, memorySizes.stateSizeInBytes)); - void *scratchBuffer; - CUDA_CHECK(cudaMalloc(&scratchBuffer, memorySizes.withoutOverlapScratchSizeInBytes)); + size_t imageBytes = 3 * image.Resolution().x * image.Resolution().y * sizeof(float); - OPTIX_CHECK(optixDenoiserSetup( - denoiserHandle, 0 /* stream */, image.Resolution().x, image.Resolution().y, - CUdeviceptr(denoiserState), memorySizes.stateSizeInBytes, - CUdeviceptr(scratchBuffer), memorySizes.withoutOverlapScratchSizeInBytes)); + auto copyChannelsToGPU = [&](std::array ch, + bool flipZ = false) { + void *bufGPU; + CUDA_CHECK(cudaMalloc(&bufGPU, imageBytes)); + std::vector hostStaging(imageBytes / sizeof(float)); - size_t imageBytes = 3 * image.Resolution().x * image.Resolution().y * sizeof(float); - std::vector inputLayers(nLayers); - for (int i = 0; i < nLayers; ++i) { - inputLayers[i].width = image.Resolution().x; - inputLayers[i].height = image.Resolution().y; - inputLayers[i].rowStrideInBytes = image.Resolution().x * 3 * sizeof(float); - inputLayers[i].pixelStrideInBytes = 0; - inputLayers[i].format = OPTIX_PIXEL_FORMAT_FLOAT3; - - size_t sz = 3 * image.Resolution().x * image.Resolution().y; - std::vector bufHost(sz); + ImageChannelDesc desc = image.GetChannelDesc(ch); + CHECK(desc); int offset = 0; for (int y = 0; y < image.Resolution().y; ++y) for (int x = 0; x < image.Resolution().x; ++x) { - ImageChannelValues v = image.GetChannels({x, y}, desc[i]); - if (i == 2) - v[2] *= -1; // flip z--right handed... + ImageChannelValues v = image.GetChannels({x, y}, desc); + if (flipZ) + v[2] *= -1; // flip normal's z--right handed... for (int c = 0; c < 3; ++c) - bufHost[offset++] = v[c]; + hostStaging[offset++] = v[c]; } + CUDA_CHECK(cudaMemcpy(bufGPU, hostStaging.data(), imageBytes, + cudaMemcpyHostToDevice)); + return bufGPU; + }; + RGB *rgbGPU = (RGB *)copyChannelsToGPU({"R", "G", "B"}); - void *bufGPU; - CUDA_CHECK(cudaMalloc(&bufGPU, imageBytes)); - CUDA_CHECK( - cudaMemcpy(bufGPU, bufHost.data(), imageBytes, cudaMemcpyHostToDevice)); - inputLayers[i].data = CUdeviceptr(bufGPU); - } - - OptixImage2D outputImage; - outputImage.width = image.Resolution().x; - outputImage.height = image.Resolution().y; - outputImage.rowStrideInBytes = image.Resolution().x * 3 * sizeof(float); - outputImage.pixelStrideInBytes = 0; - outputImage.format = OPTIX_PIXEL_FORMAT_FLOAT3; - CUDA_CHECK(cudaMalloc((void **)&outputImage.data, imageBytes)); - - void *intensity; - CUDA_CHECK(cudaMalloc(&intensity, sizeof(float))); - OPTIX_CHECK(optixDenoiserComputeIntensity( - denoiserHandle, 0 /* stream */, &inputLayers[0], CUdeviceptr(intensity), - CUdeviceptr(scratchBuffer), memorySizes.withoutOverlapScratchSizeInBytes)); - - OptixDenoiserParams params = {}; - params.denoiseAlpha = 0; - params.hdrIntensity = CUdeviceptr(intensity); - params.blendFactor = 0; // TODO what should this be?? - -#if (OPTIX_VERSION >= 70300) - OptixDenoiserGuideLayer guideLayer; + RGB *albedoGPU = nullptr; + Normal3f *normalGPU = nullptr; if (nLayers == 3) { - guideLayer.albedo = inputLayers[1]; - guideLayer.normal = inputLayers[2]; - } - - OptixDenoiserLayer layers; - layers.input = inputLayers[0]; - layers.output = outputImage; - - OPTIX_CHECK(optixDenoiserInvoke( - denoiserHandle, 0 /* stream */, ¶ms, CUdeviceptr(denoiserState), - memorySizes.stateSizeInBytes, &guideLayer, &layers, 1 /* # layers to denoise */, - 0 /* offset x */, 0 /* offset y */, CUdeviceptr(scratchBuffer), - memorySizes.withoutOverlapScratchSizeInBytes)); -#else - OPTIX_CHECK(optixDenoiserInvoke( - denoiserHandle, 0 /* stream */, ¶ms, CUdeviceptr(denoiserState), - memorySizes.stateSizeInBytes, inputLayers.data(), nLayers, 0 /* offset x */, - 0 /* offset y */, &outputImage, CUdeviceptr(scratchBuffer), - memorySizes.withoutOverlapScratchSizeInBytes)); -#endif + albedoGPU = (RGB *)copyChannelsToGPU({"Albedo.R", "Albedo.G", "Albedo.B"}); + normalGPU = (Normal3f *)copyChannelsToGPU({"Nsx", "Nsy", "Nsz"}, true); + } + + RGB *rgbResultGPU; + CUDA_CHECK(cudaMalloc(&rgbResultGPU, imageBytes)); + + denoiser.Denoise(rgbGPU, normalGPU, albedoGPU, rgbResultGPU); CUDA_CHECK(cudaDeviceSynchronize()); Image result(PixelFormat::Float, image.Resolution(), {"R", "G", "B"}); - CUDA_CHECK(cudaMemcpy(result.RawPointer({0, 0}), (const void *)outputImage.data, + CUDA_CHECK(cudaMemcpy(result.RawPointer({0, 0}), (const void *)rgbResultGPU, imageBytes, cudaMemcpyDeviceToHost)); ImageMetadata outMetadata; diff --git a/src/pbrt/gpu/denoiser.cpp b/src/pbrt/gpu/denoiser.cpp new file mode 100644 index 000000000..20b42c5a4 --- /dev/null +++ b/src/pbrt/gpu/denoiser.cpp @@ -0,0 +1,133 @@ +// 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 + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#define OPTIX_CHECK(EXPR) \ + do { \ + OptixResult res = EXPR; \ + if (res != OPTIX_SUCCESS) \ + LOG_FATAL("OptiX call " #EXPR " failed with code %d: \"%s\"", int(res), \ + optixGetErrorString(res)); \ + } while (false) /* eat semicolon */ + +// Stop that, Windows. +#ifdef RGB +#undef RGB +#endif + +namespace pbrt { + +Denoiser::Denoiser(Vector2i resolution, bool haveAlbedoAndNormal) + : resolution(resolution), haveAlbedoAndNormal(haveAlbedoAndNormal) { + CUcontext cudaContext; + CU_CHECK(cuCtxGetCurrent(&cudaContext)); + CHECK(cudaContext != nullptr); + + OPTIX_CHECK(optixInit()); + OptixDeviceContext optixContext; + OPTIX_CHECK(optixDeviceContextCreate(cudaContext, 0, &optixContext)); + + OptixDenoiserOptions options = {}; +#if (OPTIX_VERSION >= 70300) + if (haveAlbedoAndNormal) + options.guideAlbedo = options.guideNormal = 1; + + OPTIX_CHECK(optixDenoiserCreate(optixContext, OPTIX_DENOISER_MODEL_KIND_HDR, &options, + &denoiserHandle)); +#else + options.inputKind = haveAlbedoAndNormal ? OPTIX_DENOISER_INPUT_RGB_ALBEDO_NORMAL + : OPTIX_DENOISER_INPUT_RGB; + + OPTIX_CHECK(optixDenoiserCreate(optixContext, &options, &denoiserHandle)); + + OPTIX_CHECK( + optixDenoiserSetModel(denoiserHandle, OPTIX_DENOISER_MODEL_KIND_HDR, nullptr, 0)); +#endif + + OPTIX_CHECK(optixDenoiserComputeMemoryResources(denoiserHandle, resolution.x, + resolution.y, &memorySizes)); + + CUDA_CHECK(cudaMalloc(&denoiserState, memorySizes.stateSizeInBytes)); + CUDA_CHECK(cudaMalloc(&scratchBuffer, memorySizes.withoutOverlapScratchSizeInBytes)); + + OPTIX_CHECK(optixDenoiserSetup( + denoiserHandle, 0 /* stream */, resolution.x, resolution.y, + CUdeviceptr(denoiserState), memorySizes.stateSizeInBytes, + CUdeviceptr(scratchBuffer), memorySizes.withoutOverlapScratchSizeInBytes)); + + CUDA_CHECK(cudaMalloc(&intensity, sizeof(float))); +} + +void Denoiser::Denoise(RGB *rgb, Normal3f *n, RGB *albedo, RGB *result) { + std::array inputLayers; + int nLayers = haveAlbedoAndNormal ? 3 : 1; + for (int i = 0; i < nLayers; ++i) { + inputLayers[i].width = resolution.x; + inputLayers[i].height = resolution.y; + inputLayers[i].rowStrideInBytes = resolution.x * 3 * sizeof(float); + inputLayers[i].pixelStrideInBytes = 0; + inputLayers[i].format = OPTIX_PIXEL_FORMAT_FLOAT3; + } + inputLayers[0].data = CUdeviceptr(rgb); + if (haveAlbedoAndNormal) { + CHECK(n != nullptr && albedo != nullptr); + inputLayers[1].data = CUdeviceptr(albedo); + inputLayers[2].data = CUdeviceptr(n); + } else + CHECK(n == nullptr && albedo == nullptr); + + OptixImage2D outputImage; + outputImage.width = resolution.x; + outputImage.height = resolution.y; + outputImage.rowStrideInBytes = resolution.x * 3 * sizeof(float); + outputImage.pixelStrideInBytes = 0; + outputImage.format = OPTIX_PIXEL_FORMAT_FLOAT3; + outputImage.data = CUdeviceptr(result); + + OPTIX_CHECK(optixDenoiserComputeIntensity( + denoiserHandle, 0 /* stream */, &inputLayers[0], CUdeviceptr(intensity), + CUdeviceptr(scratchBuffer), memorySizes.withoutOverlapScratchSizeInBytes)); + + OptixDenoiserParams params = {}; + params.denoiseAlpha = 0; + params.hdrIntensity = CUdeviceptr(intensity); + params.blendFactor = 0; // TODO what should this be?? + +#if (OPTIX_VERSION >= 70300) + OptixDenoiserGuideLayer guideLayer; + if (haveAlbedoAndNormal) { + guideLayer.albedo = inputLayers[1]; + guideLayer.normal = inputLayers[2]; + } + + OptixDenoiserLayer layers; + layers.input = inputLayers[0]; + layers.output = outputImage; + + OPTIX_CHECK(optixDenoiserInvoke( + denoiserHandle, 0 /* stream */, ¶ms, CUdeviceptr(denoiserState), + memorySizes.stateSizeInBytes, &guideLayer, &layers, 1 /* # layers to denoise */, + 0 /* offset x */, 0 /* offset y */, CUdeviceptr(scratchBuffer), + memorySizes.withoutOverlapScratchSizeInBytes)); +#else + OPTIX_CHECK(optixDenoiserInvoke( + denoiserHandle, 0 /* stream */, ¶ms, CUdeviceptr(denoiserState), + memorySizes.stateSizeInBytes, inputLayers.data(), nLayers, 0 /* offset x */, + 0 /* offset y */, &outputImage, CUdeviceptr(scratchBuffer), + memorySizes.withoutOverlapScratchSizeInBytes)); +#endif +} + +} // namespace pbrt diff --git a/src/pbrt/gpu/denoiser.h b/src/pbrt/gpu/denoiser.h new file mode 100644 index 000000000..fbe8b81ef --- /dev/null +++ b/src/pbrt/gpu/denoiser.h @@ -0,0 +1,35 @@ +// 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 + +#ifndef PBRT_GPU_DENOISER_H +#define PBRT_GPU_DENOISER_H + +#include + +#include +#include + +#include + +namespace pbrt { + +class Denoiser { + public: + Denoiser(Vector2i resolution, bool haveAlbedoAndNormal); + + // All pointers should be to GPU memory. + // |n| and |albedo| should be nullptr iff \haveAlbedoAndNormal| is false. + void Denoise(RGB *rgb, Normal3f *n, RGB *albedo, RGB *result); + + private: + Vector2i resolution; + bool haveAlbedoAndNormal; + OptixDenoiser denoiserHandle; + OptixDenoiserSizes memorySizes; + void *denoiserState, *scratchBuffer, *intensity; +}; + +} // namespace pbrt + +#endif // PBRT_GPU_DENOISER_H diff --git a/src/pbrt/gpu/util.cpp b/src/pbrt/gpu/util.cpp index e44339322..aa89707c7 100644 --- a/src/pbrt/gpu/util.cpp +++ b/src/pbrt/gpu/util.cpp @@ -204,6 +204,10 @@ void GPUWait() { CUDA_CHECK(cudaDeviceSynchronize()); } +void GPUMemset(void *ptr, int byte, size_t bytes) { + CUDA_CHECK(cudaMemset(ptr, byte, bytes)); +} + void ReportKernelStats() { CUDA_CHECK(cudaDeviceSynchronize()); diff --git a/src/pbrt/gpu/util.h b/src/pbrt/gpu/util.h index 54adf15cf..72b8cc4cc 100644 --- a/src/pbrt/gpu/util.h +++ b/src/pbrt/gpu/util.h @@ -123,6 +123,8 @@ void ReportKernelStats(); void GPUInit(); void GPUThreadInit(); +void GPUMemset(void *ptr, int byte, size_t bytes); + void GPURegisterThread(const char *name); void GPUNameStream(cudaStream_t stream, const char *name); From 134eb78d189eb9628bac3c36b8eabe436c2eac58 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 25 Apr 2022 17:54:32 -0700 Subject: [PATCH 027/149] Add Film::ResetPixel() method --- src/pbrt/base/film.h | 3 +++ src/pbrt/film.h | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/pbrt/base/film.h b/src/pbrt/base/film.h index 8063802f1..129ba737b 100644 --- a/src/pbrt/base/film.h +++ b/src/pbrt/base/film.h @@ -50,6 +50,7 @@ class Film : public TaggedPointer { const SampledWavelengths &lambda) const; Image GetImage(ImageMetadata *metadata, Float splatScale = 1); + PBRT_CPU_GPU RGB GetPixelRGB(Point2i p, Float splatScale = 1) const; @@ -64,6 +65,8 @@ class Film : public TaggedPointer { Filter filter, const FileLoc *loc, Allocator alloc); std::string ToString() const; + + PBRT_CPU_GPU inline void ResetPixel(Point2i p); }; } // namespace pbrt diff --git a/src/pbrt/film.h b/src/pbrt/film.h index a220dbb08..5b3bf37be 100644 --- a/src/pbrt/film.h +++ b/src/pbrt/film.h @@ -295,6 +295,10 @@ class RGBFilm : public FilmBase { return outputRGBFromSensorRGB * sensorRGB; } + PBRT_CPU_GPU void ResetPixel(Point2i p) { + std::memset(&pixels[p], 0, sizeof(Pixel)); + } + private: // RGBFilm::Pixel Definition struct Pixel { @@ -367,6 +371,10 @@ class GBufferFilm : public FilmBase { std::string ToString() const; + PBRT_CPU_GPU void ResetPixel(Point2i p) { + std::memset(&pixels[p], 0, sizeof(Pixel)); + } + private: // GBufferFilm::Pixel Definition struct Pixel { @@ -482,6 +490,16 @@ class SpectralFilm : public FilmBase { return {}; } + PBRT_CPU_GPU void ResetPixel(Point2i p) { + Pixel &pix = pixels[p]; + pix.rgbSum[0] = pix.rgbSum[1] = pix.rgbSum[2] = 0.; + pix.rgbWeightSum = 0.; + pix.rgbSplat[0] = pix.rgbSplat[1] = pix.rgbSplat[2] = 0.; + std::memset(pix.bucketSums, 0, nBuckets *sizeof(double)); + std::memset(pix.weightSums, 0, nBuckets *sizeof(double)); + std::memset(pix.bucketSplats, 0, nBuckets * sizeof(AtomicDouble)); + } + private: PBRT_CPU_GPU int LambdaToBucket(Float lambda) const { @@ -584,6 +602,12 @@ inline const PixelSensor *Film::GetPixelSensor() const { return Dispatch(filter); } +PBRT_CPU_GPU +inline void Film::ResetPixel(Point2i p) { + auto rp = [&](auto ptr) { ptr->ResetPixel(p); }; + return Dispatch(rp); +} + } // namespace pbrt #endif // PBRT_FILM_H From fc86eb47c18fbec83520c71d08d6499056bb9b61 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 25 Apr 2022 17:55:55 -0700 Subject: [PATCH 028/149] Add GLAD and GLFW dependencies --- .gitmodules | 4 + CMakeLists.txt | 1 + src/ext/CMakeLists.txt | 17 + src/ext/glad/CMakeLists.txt | 6 + src/ext/glad/include/KHR/khrplatform.h | 311 ++ src/ext/glad/include/glad/glad.h | 3611 ++++++++++++++++++++++++ src/ext/glad/src/glad.c | 1840 ++++++++++++ 7 files changed, 5790 insertions(+) create mode 100644 src/ext/glad/CMakeLists.txt create mode 100644 src/ext/glad/include/KHR/khrplatform.h create mode 100644 src/ext/glad/include/glad/glad.h create mode 100644 src/ext/glad/src/glad.c diff --git a/.gitmodules b/.gitmodules index 1381a3521..12d960c41 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,3 +33,7 @@ [submodule "src/ext/qoi"] path = src/ext/qoi url = https://github.com/phoboslab/qoi.git +[submodule "src/ext/glfw"] + path = src/ext/glfw + url = https://github.com/glfw/glfw.git + diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a6ffee48..d6fa9dd4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ check_ext ("OpenVDB" "openvdb/nanovdb" 414bed84c2fc22e188eac7b611aa85c7edd7a5a9) check_ext ("Ptex" "ptex/src" 4cd8e9a6db2b06e478dfbbd8c26eb6df97f84483) check_ext ("double-conversion" "double-conversion/cmake" cc1f75a114aca8d2af69f73a5a959aecbab0e87a) check_ext ("filesystem" "filesystem/filesystem" c5f9de30142453eb3c6fe991e82dfc2583373116) +check_ext ("glfw" "glfw/docs" 9cc252a406b79c31ab82648a21b715e2d3fc7ece) check_ext ("libdeflate" "libdeflate/common" 1fd0bea6ca2073c68493632dafc4b1ddda1bcbc3) check_ext ("lodepng" "lodepng/examples" 8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a) check_ext ("qoi" "qoi" 028c75fd26e5e0758c7c711216c00404994c1ad3) diff --git a/src/ext/CMakeLists.txt b/src/ext/CMakeLists.txt index 4aac438cb..f2d4a7500 100644 --- a/src/ext/CMakeLists.txt +++ b/src/ext/CMakeLists.txt @@ -152,3 +152,20 @@ add_subdirectory (utf8proc) set (QOI_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/qoi PARENT_SCOPE) +########################################################################### +# glfw / glad + +set (GLFW_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/glfw/include PARENT_SCOPE) +set (GLAD_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/glad/include PARENT_SCOPE) + +set (GLFW_LIBRARY_TYPE STATIC CACHE STRING "" FORCE) +set (GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) +set (GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) +set (GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) + +add_subdirectory (glfw) +add_subdirectory (glad) + +set_property (TARGET glfw PROPERTY FOLDER "ext") +set_property (TARGET glad PROPERTY FOLDER "ext") + diff --git a/src/ext/glad/CMakeLists.txt b/src/ext/glad/CMakeLists.txt new file mode 100644 index 000000000..72ea5bac0 --- /dev/null +++ b/src/ext/glad/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_library (glad STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/glad.c) + +target_include_directories(glad PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + +set_property (TARGET glad PROPERTY FOLDER "ext") diff --git a/src/ext/glad/include/KHR/khrplatform.h b/src/ext/glad/include/KHR/khrplatform.h new file mode 100644 index 000000000..01646449c --- /dev/null +++ b/src/ext/glad/include/KHR/khrplatform.h @@ -0,0 +1,311 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 +/* + * To support platform where unsigned long cannot be used interchangeably with + * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. + * Ideally, we could just use (u)intptr_t everywhere, but this could result in + * ABI breakage if khronos_uintptr_t is changed from unsigned long to + * unsigned long long or similar (this results in different C++ name mangling). + * To avoid changes for existing platforms, we restrict usage of intptr_t to + * platforms where the size of a pointer is larger than the size of long. + */ +#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) +#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ +#define KHRONOS_USE_INTPTR_T +#endif +#endif + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef KHRONOS_USE_INTPTR_T +typedef intptr_t khronos_intptr_t; +typedef uintptr_t khronos_uintptr_t; +#elif defined(_WIN64) +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +#endif + +#if defined(_WIN64) +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/src/ext/glad/include/glad/glad.h b/src/ext/glad/include/glad/glad.h new file mode 100644 index 000000000..7dd498801 --- /dev/null +++ b/src/ext/glad/include/glad/glad.h @@ -0,0 +1,3611 @@ +/* + + OpenGL loader generated by glad 0.1.35 on Fri Mar 18 22:50:35 2022. + + Language/Generator: C/C++ + Specification: gl + APIs: gl=3.3 + Profile: compatibility + Extensions: + + Loader: True + Local files: False + Omit khrplatform: False + Reproducible: False + + Commandline: + --profile="compatibility" --api="gl=3.3" --generator="c" --spec="gl" --extensions="" + Online: + https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D3.3 +*/ + + +#ifndef __glad_h_ +#define __glad_h_ + +#ifdef __gl_h_ +#error OpenGL header already included, remove this include, glad already provides it +#endif +#define __gl_h_ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define APIENTRY __stdcall +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY APIENTRY +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct gladGLversionStruct { + int major; + int minor; +}; + +typedef void* (* GLADloadproc)(const char *name); + +#ifndef GLAPI +# if defined(GLAD_GLAPI_EXPORT) +# if defined(_WIN32) || defined(__CYGWIN__) +# if defined(GLAD_GLAPI_EXPORT_BUILD) +# if defined(__GNUC__) +# define GLAPI __attribute__ ((dllexport)) extern +# else +# define GLAPI __declspec(dllexport) extern +# endif +# else +# if defined(__GNUC__) +# define GLAPI __attribute__ ((dllimport)) extern +# else +# define GLAPI __declspec(dllimport) extern +# endif +# endif +# elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD) +# define GLAPI __attribute__ ((visibility ("default"))) extern +# else +# define GLAPI extern +# endif +# else +# define GLAPI extern +# endif +#endif + +GLAPI struct gladGLversionStruct GLVersion; + +GLAPI int gladLoadGL(void); + +GLAPI int gladLoadGLLoader(GLADloadproc); + +#include +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef khronos_int8_t GLbyte; +typedef khronos_uint8_t GLubyte; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef int GLint; +typedef unsigned int GLuint; +typedef khronos_int32_t GLclampx; +typedef int GLsizei; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef double GLdouble; +typedef double GLclampd; +typedef void *GLeglClientBufferEXT; +typedef void *GLeglImageOES; +typedef char GLchar; +typedef char GLcharARB; +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef khronos_uint16_t GLhalf; +typedef khronos_uint16_t GLhalfARB; +typedef khronos_int32_t GLfixed; +typedef khronos_intptr_t GLintptr; +typedef khronos_intptr_t GLintptrARB; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_ssize_t GLsizeiptrARB; +typedef khronos_int64_t GLint64; +typedef khronos_int64_t GLint64EXT; +typedef khronos_uint64_t GLuint64; +typedef khronos_uint64_t GLuint64EXT; +typedef struct __GLsync *GLsync; +struct _cl_context; +struct _cl_event; +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +typedef unsigned short GLhalfNV; +typedef GLintptr GLvdpauSurfaceNV; +typedef void (APIENTRY *GLVULKANPROCNV)(void); +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_VIEWPORT 0x0BA2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F +#define GL_TEXTURE 0x1702 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_REPEAT 0x2901 +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 +#define GL_ACCUM 0x0100 +#define GL_LOAD 0x0101 +#define GL_RETURN 0x0102 +#define GL_MULT 0x0103 +#define GL_ADD 0x0104 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_POINT_SMOOTH 0x0B10 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LIST_MODE 0x0B30 +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_SHADE_MODEL 0x0B54 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_FOG 0x0B60 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_COLOR 0x0B66 +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_NORMALIZE 0x0BA1 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_LOGIC_OP 0x0BF1 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_INDEX_MODE 0x0C30 +#define GL_RGBA_MODE 0x0C31 +#define GL_RENDER_MODE 0x0C40 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_FOG_HINT 0x0C54 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_INDEX_BITS 0x0D51 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_COLOR_INDEX 0x1900 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_BITMAP 0x1A00 +#define GL_RENDER 0x1C00 +#define GL_FEEDBACK 0x1C01 +#define GL_SELECT 0x1C02 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_ENV 0x2300 +#define GL_EYE_LINEAR 0x2400 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_SPHERE_MAP 0x2402 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_PLANE 0x2502 +#define GL_CLAMP 0x2900 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_DOUBLE 0x140A +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFF +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +#ifndef GL_VERSION_1_0 +#define GL_VERSION_1_0 1 +GLAPI int GLAD_GL_VERSION_1_0; +typedef void (APIENTRYP PFNGLCULLFACEPROC)(GLenum mode); +GLAPI PFNGLCULLFACEPROC glad_glCullFace; +#define glCullFace glad_glCullFace +typedef void (APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode); +GLAPI PFNGLFRONTFACEPROC glad_glFrontFace; +#define glFrontFace glad_glFrontFace +typedef void (APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode); +GLAPI PFNGLHINTPROC glad_glHint; +#define glHint glad_glHint +typedef void (APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width); +GLAPI PFNGLLINEWIDTHPROC glad_glLineWidth; +#define glLineWidth glad_glLineWidth +typedef void (APIENTRYP PFNGLPOINTSIZEPROC)(GLfloat size); +GLAPI PFNGLPOINTSIZEPROC glad_glPointSize; +#define glPointSize glad_glPointSize +typedef void (APIENTRYP PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode); +GLAPI PFNGLPOLYGONMODEPROC glad_glPolygonMode; +#define glPolygonMode glad_glPolygonMode +typedef void (APIENTRYP PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI PFNGLSCISSORPROC glad_glScissor; +#define glScissor glad_glScissor +typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param); +GLAPI PFNGLTEXPARAMETERFPROC glad_glTexParameterf; +#define glTexParameterf glad_glTexParameterf +typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat *params); +GLAPI PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv; +#define glTexParameterfv glad_glTexParameterfv +typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); +GLAPI PFNGLTEXPARAMETERIPROC glad_glTexParameteri; +#define glTexParameteri glad_glTexParameteri +typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint *params); +GLAPI PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv; +#define glTexParameteriv glad_glTexParameteriv +typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI PFNGLTEXIMAGE1DPROC glad_glTexImage1D; +#define glTexImage1D glad_glTexImage1D +typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI PFNGLTEXIMAGE2DPROC glad_glTexImage2D; +#define glTexImage2D glad_glTexImage2D +typedef void (APIENTRYP PFNGLDRAWBUFFERPROC)(GLenum buf); +GLAPI PFNGLDRAWBUFFERPROC glad_glDrawBuffer; +#define glDrawBuffer glad_glDrawBuffer +typedef void (APIENTRYP PFNGLCLEARPROC)(GLbitfield mask); +GLAPI PFNGLCLEARPROC glad_glClear; +#define glClear glad_glClear +typedef void (APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI PFNGLCLEARCOLORPROC glad_glClearColor; +#define glClearColor glad_glClearColor +typedef void (APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s); +GLAPI PFNGLCLEARSTENCILPROC glad_glClearStencil; +#define glClearStencil glad_glClearStencil +typedef void (APIENTRYP PFNGLCLEARDEPTHPROC)(GLdouble depth); +GLAPI PFNGLCLEARDEPTHPROC glad_glClearDepth; +#define glClearDepth glad_glClearDepth +typedef void (APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask); +GLAPI PFNGLSTENCILMASKPROC glad_glStencilMask; +#define glStencilMask glad_glStencilMask +typedef void (APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GLAPI PFNGLCOLORMASKPROC glad_glColorMask; +#define glColorMask glad_glColorMask +typedef void (APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag); +GLAPI PFNGLDEPTHMASKPROC glad_glDepthMask; +#define glDepthMask glad_glDepthMask +typedef void (APIENTRYP PFNGLDISABLEPROC)(GLenum cap); +GLAPI PFNGLDISABLEPROC glad_glDisable; +#define glDisable glad_glDisable +typedef void (APIENTRYP PFNGLENABLEPROC)(GLenum cap); +GLAPI PFNGLENABLEPROC glad_glEnable; +#define glEnable glad_glEnable +typedef void (APIENTRYP PFNGLFINISHPROC)(void); +GLAPI PFNGLFINISHPROC glad_glFinish; +#define glFinish glad_glFinish +typedef void (APIENTRYP PFNGLFLUSHPROC)(void); +GLAPI PFNGLFLUSHPROC glad_glFlush; +#define glFlush glad_glFlush +typedef void (APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); +GLAPI PFNGLBLENDFUNCPROC glad_glBlendFunc; +#define glBlendFunc glad_glBlendFunc +typedef void (APIENTRYP PFNGLLOGICOPPROC)(GLenum opcode); +GLAPI PFNGLLOGICOPPROC glad_glLogicOp; +#define glLogicOp glad_glLogicOp +typedef void (APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask); +GLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc; +#define glStencilFunc glad_glStencilFunc +typedef void (APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass); +GLAPI PFNGLSTENCILOPPROC glad_glStencilOp; +#define glStencilOp glad_glStencilOp +typedef void (APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func); +GLAPI PFNGLDEPTHFUNCPROC glad_glDepthFunc; +#define glDepthFunc glad_glDepthFunc +typedef void (APIENTRYP PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param); +GLAPI PFNGLPIXELSTOREFPROC glad_glPixelStoref; +#define glPixelStoref glad_glPixelStoref +typedef void (APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); +GLAPI PFNGLPIXELSTOREIPROC glad_glPixelStorei; +#define glPixelStorei glad_glPixelStorei +typedef void (APIENTRYP PFNGLREADBUFFERPROC)(GLenum src); +GLAPI PFNGLREADBUFFERPROC glad_glReadBuffer; +#define glReadBuffer glad_glReadBuffer +typedef void (APIENTRYP PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GLAPI PFNGLREADPIXELSPROC glad_glReadPixels; +#define glReadPixels glad_glReadPixels +typedef void (APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean *data); +GLAPI PFNGLGETBOOLEANVPROC glad_glGetBooleanv; +#define glGetBooleanv glad_glGetBooleanv +typedef void (APIENTRYP PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble *data); +GLAPI PFNGLGETDOUBLEVPROC glad_glGetDoublev; +#define glGetDoublev glad_glGetDoublev +typedef GLenum (APIENTRYP PFNGLGETERRORPROC)(void); +GLAPI PFNGLGETERRORPROC glad_glGetError; +#define glGetError glad_glGetError +typedef void (APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat *data); +GLAPI PFNGLGETFLOATVPROC glad_glGetFloatv; +#define glGetFloatv glad_glGetFloatv +typedef void (APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint *data); +GLAPI PFNGLGETINTEGERVPROC glad_glGetIntegerv; +#define glGetIntegerv glad_glGetIntegerv +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC)(GLenum name); +GLAPI PFNGLGETSTRINGPROC glad_glGetString; +#define glGetString glad_glGetString +typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI PFNGLGETTEXIMAGEPROC glad_glGetTexImage; +#define glGetTexImage glad_glGetTexImage +typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat *params); +GLAPI PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv; +#define glGetTexParameterfv glad_glGetTexParameterfv +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +GLAPI PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv; +#define glGetTexParameteriv glad_glGetTexParameteriv +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv; +#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv; +#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv +typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); +GLAPI PFNGLISENABLEDPROC glad_glIsEnabled; +#define glIsEnabled glad_glIsEnabled +typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); +GLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange; +#define glDepthRange glad_glDepthRange +typedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI PFNGLVIEWPORTPROC glad_glViewport; +#define glViewport glad_glViewport +typedef void (APIENTRYP PFNGLNEWLISTPROC)(GLuint list, GLenum mode); +GLAPI PFNGLNEWLISTPROC glad_glNewList; +#define glNewList glad_glNewList +typedef void (APIENTRYP PFNGLENDLISTPROC)(void); +GLAPI PFNGLENDLISTPROC glad_glEndList; +#define glEndList glad_glEndList +typedef void (APIENTRYP PFNGLCALLLISTPROC)(GLuint list); +GLAPI PFNGLCALLLISTPROC glad_glCallList; +#define glCallList glad_glCallList +typedef void (APIENTRYP PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, const void *lists); +GLAPI PFNGLCALLLISTSPROC glad_glCallLists; +#define glCallLists glad_glCallLists +typedef void (APIENTRYP PFNGLDELETELISTSPROC)(GLuint list, GLsizei range); +GLAPI PFNGLDELETELISTSPROC glad_glDeleteLists; +#define glDeleteLists glad_glDeleteLists +typedef GLuint (APIENTRYP PFNGLGENLISTSPROC)(GLsizei range); +GLAPI PFNGLGENLISTSPROC glad_glGenLists; +#define glGenLists glad_glGenLists +typedef void (APIENTRYP PFNGLLISTBASEPROC)(GLuint base); +GLAPI PFNGLLISTBASEPROC glad_glListBase; +#define glListBase glad_glListBase +typedef void (APIENTRYP PFNGLBEGINPROC)(GLenum mode); +GLAPI PFNGLBEGINPROC glad_glBegin; +#define glBegin glad_glBegin +typedef void (APIENTRYP PFNGLBITMAPPROC)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +GLAPI PFNGLBITMAPPROC glad_glBitmap; +#define glBitmap glad_glBitmap +typedef void (APIENTRYP PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +GLAPI PFNGLCOLOR3BPROC glad_glColor3b; +#define glColor3b glad_glColor3b +typedef void (APIENTRYP PFNGLCOLOR3BVPROC)(const GLbyte *v); +GLAPI PFNGLCOLOR3BVPROC glad_glColor3bv; +#define glColor3bv glad_glColor3bv +typedef void (APIENTRYP PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +GLAPI PFNGLCOLOR3DPROC glad_glColor3d; +#define glColor3d glad_glColor3d +typedef void (APIENTRYP PFNGLCOLOR3DVPROC)(const GLdouble *v); +GLAPI PFNGLCOLOR3DVPROC glad_glColor3dv; +#define glColor3dv glad_glColor3dv +typedef void (APIENTRYP PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +GLAPI PFNGLCOLOR3FPROC glad_glColor3f; +#define glColor3f glad_glColor3f +typedef void (APIENTRYP PFNGLCOLOR3FVPROC)(const GLfloat *v); +GLAPI PFNGLCOLOR3FVPROC glad_glColor3fv; +#define glColor3fv glad_glColor3fv +typedef void (APIENTRYP PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue); +GLAPI PFNGLCOLOR3IPROC glad_glColor3i; +#define glColor3i glad_glColor3i +typedef void (APIENTRYP PFNGLCOLOR3IVPROC)(const GLint *v); +GLAPI PFNGLCOLOR3IVPROC glad_glColor3iv; +#define glColor3iv glad_glColor3iv +typedef void (APIENTRYP PFNGLCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +GLAPI PFNGLCOLOR3SPROC glad_glColor3s; +#define glColor3s glad_glColor3s +typedef void (APIENTRYP PFNGLCOLOR3SVPROC)(const GLshort *v); +GLAPI PFNGLCOLOR3SVPROC glad_glColor3sv; +#define glColor3sv glad_glColor3sv +typedef void (APIENTRYP PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +GLAPI PFNGLCOLOR3UBPROC glad_glColor3ub; +#define glColor3ub glad_glColor3ub +typedef void (APIENTRYP PFNGLCOLOR3UBVPROC)(const GLubyte *v); +GLAPI PFNGLCOLOR3UBVPROC glad_glColor3ubv; +#define glColor3ubv glad_glColor3ubv +typedef void (APIENTRYP PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +GLAPI PFNGLCOLOR3UIPROC glad_glColor3ui; +#define glColor3ui glad_glColor3ui +typedef void (APIENTRYP PFNGLCOLOR3UIVPROC)(const GLuint *v); +GLAPI PFNGLCOLOR3UIVPROC glad_glColor3uiv; +#define glColor3uiv glad_glColor3uiv +typedef void (APIENTRYP PFNGLCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +GLAPI PFNGLCOLOR3USPROC glad_glColor3us; +#define glColor3us glad_glColor3us +typedef void (APIENTRYP PFNGLCOLOR3USVPROC)(const GLushort *v); +GLAPI PFNGLCOLOR3USVPROC glad_glColor3usv; +#define glColor3usv glad_glColor3usv +typedef void (APIENTRYP PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +GLAPI PFNGLCOLOR4BPROC glad_glColor4b; +#define glColor4b glad_glColor4b +typedef void (APIENTRYP PFNGLCOLOR4BVPROC)(const GLbyte *v); +GLAPI PFNGLCOLOR4BVPROC glad_glColor4bv; +#define glColor4bv glad_glColor4bv +typedef void (APIENTRYP PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +GLAPI PFNGLCOLOR4DPROC glad_glColor4d; +#define glColor4d glad_glColor4d +typedef void (APIENTRYP PFNGLCOLOR4DVPROC)(const GLdouble *v); +GLAPI PFNGLCOLOR4DVPROC glad_glColor4dv; +#define glColor4dv glad_glColor4dv +typedef void (APIENTRYP PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI PFNGLCOLOR4FPROC glad_glColor4f; +#define glColor4f glad_glColor4f +typedef void (APIENTRYP PFNGLCOLOR4FVPROC)(const GLfloat *v); +GLAPI PFNGLCOLOR4FVPROC glad_glColor4fv; +#define glColor4fv glad_glColor4fv +typedef void (APIENTRYP PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, GLint alpha); +GLAPI PFNGLCOLOR4IPROC glad_glColor4i; +#define glColor4i glad_glColor4i +typedef void (APIENTRYP PFNGLCOLOR4IVPROC)(const GLint *v); +GLAPI PFNGLCOLOR4IVPROC glad_glColor4iv; +#define glColor4iv glad_glColor4iv +typedef void (APIENTRYP PFNGLCOLOR4SPROC)(GLshort red, GLshort green, GLshort blue, GLshort alpha); +GLAPI PFNGLCOLOR4SPROC glad_glColor4s; +#define glColor4s glad_glColor4s +typedef void (APIENTRYP PFNGLCOLOR4SVPROC)(const GLshort *v); +GLAPI PFNGLCOLOR4SVPROC glad_glColor4sv; +#define glColor4sv glad_glColor4sv +typedef void (APIENTRYP PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +GLAPI PFNGLCOLOR4UBPROC glad_glColor4ub; +#define glColor4ub glad_glColor4ub +typedef void (APIENTRYP PFNGLCOLOR4UBVPROC)(const GLubyte *v); +GLAPI PFNGLCOLOR4UBVPROC glad_glColor4ubv; +#define glColor4ubv glad_glColor4ubv +typedef void (APIENTRYP PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, GLuint alpha); +GLAPI PFNGLCOLOR4UIPROC glad_glColor4ui; +#define glColor4ui glad_glColor4ui +typedef void (APIENTRYP PFNGLCOLOR4UIVPROC)(const GLuint *v); +GLAPI PFNGLCOLOR4UIVPROC glad_glColor4uiv; +#define glColor4uiv glad_glColor4uiv +typedef void (APIENTRYP PFNGLCOLOR4USPROC)(GLushort red, GLushort green, GLushort blue, GLushort alpha); +GLAPI PFNGLCOLOR4USPROC glad_glColor4us; +#define glColor4us glad_glColor4us +typedef void (APIENTRYP PFNGLCOLOR4USVPROC)(const GLushort *v); +GLAPI PFNGLCOLOR4USVPROC glad_glColor4usv; +#define glColor4usv glad_glColor4usv +typedef void (APIENTRYP PFNGLEDGEFLAGPROC)(GLboolean flag); +GLAPI PFNGLEDGEFLAGPROC glad_glEdgeFlag; +#define glEdgeFlag glad_glEdgeFlag +typedef void (APIENTRYP PFNGLEDGEFLAGVPROC)(const GLboolean *flag); +GLAPI PFNGLEDGEFLAGVPROC glad_glEdgeFlagv; +#define glEdgeFlagv glad_glEdgeFlagv +typedef void (APIENTRYP PFNGLENDPROC)(void); +GLAPI PFNGLENDPROC glad_glEnd; +#define glEnd glad_glEnd +typedef void (APIENTRYP PFNGLINDEXDPROC)(GLdouble c); +GLAPI PFNGLINDEXDPROC glad_glIndexd; +#define glIndexd glad_glIndexd +typedef void (APIENTRYP PFNGLINDEXDVPROC)(const GLdouble *c); +GLAPI PFNGLINDEXDVPROC glad_glIndexdv; +#define glIndexdv glad_glIndexdv +typedef void (APIENTRYP PFNGLINDEXFPROC)(GLfloat c); +GLAPI PFNGLINDEXFPROC glad_glIndexf; +#define glIndexf glad_glIndexf +typedef void (APIENTRYP PFNGLINDEXFVPROC)(const GLfloat *c); +GLAPI PFNGLINDEXFVPROC glad_glIndexfv; +#define glIndexfv glad_glIndexfv +typedef void (APIENTRYP PFNGLINDEXIPROC)(GLint c); +GLAPI PFNGLINDEXIPROC glad_glIndexi; +#define glIndexi glad_glIndexi +typedef void (APIENTRYP PFNGLINDEXIVPROC)(const GLint *c); +GLAPI PFNGLINDEXIVPROC glad_glIndexiv; +#define glIndexiv glad_glIndexiv +typedef void (APIENTRYP PFNGLINDEXSPROC)(GLshort c); +GLAPI PFNGLINDEXSPROC glad_glIndexs; +#define glIndexs glad_glIndexs +typedef void (APIENTRYP PFNGLINDEXSVPROC)(const GLshort *c); +GLAPI PFNGLINDEXSVPROC glad_glIndexsv; +#define glIndexsv glad_glIndexsv +typedef void (APIENTRYP PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI PFNGLNORMAL3BPROC glad_glNormal3b; +#define glNormal3b glad_glNormal3b +typedef void (APIENTRYP PFNGLNORMAL3BVPROC)(const GLbyte *v); +GLAPI PFNGLNORMAL3BVPROC glad_glNormal3bv; +#define glNormal3bv glad_glNormal3bv +typedef void (APIENTRYP PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI PFNGLNORMAL3DPROC glad_glNormal3d; +#define glNormal3d glad_glNormal3d +typedef void (APIENTRYP PFNGLNORMAL3DVPROC)(const GLdouble *v); +GLAPI PFNGLNORMAL3DVPROC glad_glNormal3dv; +#define glNormal3dv glad_glNormal3dv +typedef void (APIENTRYP PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI PFNGLNORMAL3FPROC glad_glNormal3f; +#define glNormal3f glad_glNormal3f +typedef void (APIENTRYP PFNGLNORMAL3FVPROC)(const GLfloat *v); +GLAPI PFNGLNORMAL3FVPROC glad_glNormal3fv; +#define glNormal3fv glad_glNormal3fv +typedef void (APIENTRYP PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz); +GLAPI PFNGLNORMAL3IPROC glad_glNormal3i; +#define glNormal3i glad_glNormal3i +typedef void (APIENTRYP PFNGLNORMAL3IVPROC)(const GLint *v); +GLAPI PFNGLNORMAL3IVPROC glad_glNormal3iv; +#define glNormal3iv glad_glNormal3iv +typedef void (APIENTRYP PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz); +GLAPI PFNGLNORMAL3SPROC glad_glNormal3s; +#define glNormal3s glad_glNormal3s +typedef void (APIENTRYP PFNGLNORMAL3SVPROC)(const GLshort *v); +GLAPI PFNGLNORMAL3SVPROC glad_glNormal3sv; +#define glNormal3sv glad_glNormal3sv +typedef void (APIENTRYP PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y); +GLAPI PFNGLRASTERPOS2DPROC glad_glRasterPos2d; +#define glRasterPos2d glad_glRasterPos2d +typedef void (APIENTRYP PFNGLRASTERPOS2DVPROC)(const GLdouble *v); +GLAPI PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv; +#define glRasterPos2dv glad_glRasterPos2dv +typedef void (APIENTRYP PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y); +GLAPI PFNGLRASTERPOS2FPROC glad_glRasterPos2f; +#define glRasterPos2f glad_glRasterPos2f +typedef void (APIENTRYP PFNGLRASTERPOS2FVPROC)(const GLfloat *v); +GLAPI PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv; +#define glRasterPos2fv glad_glRasterPos2fv +typedef void (APIENTRYP PFNGLRASTERPOS2IPROC)(GLint x, GLint y); +GLAPI PFNGLRASTERPOS2IPROC glad_glRasterPos2i; +#define glRasterPos2i glad_glRasterPos2i +typedef void (APIENTRYP PFNGLRASTERPOS2IVPROC)(const GLint *v); +GLAPI PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv; +#define glRasterPos2iv glad_glRasterPos2iv +typedef void (APIENTRYP PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y); +GLAPI PFNGLRASTERPOS2SPROC glad_glRasterPos2s; +#define glRasterPos2s glad_glRasterPos2s +typedef void (APIENTRYP PFNGLRASTERPOS2SVPROC)(const GLshort *v); +GLAPI PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv; +#define glRasterPos2sv glad_glRasterPos2sv +typedef void (APIENTRYP PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +GLAPI PFNGLRASTERPOS3DPROC glad_glRasterPos3d; +#define glRasterPos3d glad_glRasterPos3d +typedef void (APIENTRYP PFNGLRASTERPOS3DVPROC)(const GLdouble *v); +GLAPI PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv; +#define glRasterPos3dv glad_glRasterPos3dv +typedef void (APIENTRYP PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +GLAPI PFNGLRASTERPOS3FPROC glad_glRasterPos3f; +#define glRasterPos3f glad_glRasterPos3f +typedef void (APIENTRYP PFNGLRASTERPOS3FVPROC)(const GLfloat *v); +GLAPI PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv; +#define glRasterPos3fv glad_glRasterPos3fv +typedef void (APIENTRYP PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z); +GLAPI PFNGLRASTERPOS3IPROC glad_glRasterPos3i; +#define glRasterPos3i glad_glRasterPos3i +typedef void (APIENTRYP PFNGLRASTERPOS3IVPROC)(const GLint *v); +GLAPI PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv; +#define glRasterPos3iv glad_glRasterPos3iv +typedef void (APIENTRYP PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z); +GLAPI PFNGLRASTERPOS3SPROC glad_glRasterPos3s; +#define glRasterPos3s glad_glRasterPos3s +typedef void (APIENTRYP PFNGLRASTERPOS3SVPROC)(const GLshort *v); +GLAPI PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv; +#define glRasterPos3sv glad_glRasterPos3sv +typedef void (APIENTRYP PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI PFNGLRASTERPOS4DPROC glad_glRasterPos4d; +#define glRasterPos4d glad_glRasterPos4d +typedef void (APIENTRYP PFNGLRASTERPOS4DVPROC)(const GLdouble *v); +GLAPI PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv; +#define glRasterPos4dv glad_glRasterPos4dv +typedef void (APIENTRYP PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI PFNGLRASTERPOS4FPROC glad_glRasterPos4f; +#define glRasterPos4f glad_glRasterPos4f +typedef void (APIENTRYP PFNGLRASTERPOS4FVPROC)(const GLfloat *v); +GLAPI PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv; +#define glRasterPos4fv glad_glRasterPos4fv +typedef void (APIENTRYP PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, GLint w); +GLAPI PFNGLRASTERPOS4IPROC glad_glRasterPos4i; +#define glRasterPos4i glad_glRasterPos4i +typedef void (APIENTRYP PFNGLRASTERPOS4IVPROC)(const GLint *v); +GLAPI PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv; +#define glRasterPos4iv glad_glRasterPos4iv +typedef void (APIENTRYP PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI PFNGLRASTERPOS4SPROC glad_glRasterPos4s; +#define glRasterPos4s glad_glRasterPos4s +typedef void (APIENTRYP PFNGLRASTERPOS4SVPROC)(const GLshort *v); +GLAPI PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv; +#define glRasterPos4sv glad_glRasterPos4sv +typedef void (APIENTRYP PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +GLAPI PFNGLRECTDPROC glad_glRectd; +#define glRectd glad_glRectd +typedef void (APIENTRYP PFNGLRECTDVPROC)(const GLdouble *v1, const GLdouble *v2); +GLAPI PFNGLRECTDVPROC glad_glRectdv; +#define glRectdv glad_glRectdv +typedef void (APIENTRYP PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +GLAPI PFNGLRECTFPROC glad_glRectf; +#define glRectf glad_glRectf +typedef void (APIENTRYP PFNGLRECTFVPROC)(const GLfloat *v1, const GLfloat *v2); +GLAPI PFNGLRECTFVPROC glad_glRectfv; +#define glRectfv glad_glRectfv +typedef void (APIENTRYP PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2); +GLAPI PFNGLRECTIPROC glad_glRecti; +#define glRecti glad_glRecti +typedef void (APIENTRYP PFNGLRECTIVPROC)(const GLint *v1, const GLint *v2); +GLAPI PFNGLRECTIVPROC glad_glRectiv; +#define glRectiv glad_glRectiv +typedef void (APIENTRYP PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +GLAPI PFNGLRECTSPROC glad_glRects; +#define glRects glad_glRects +typedef void (APIENTRYP PFNGLRECTSVPROC)(const GLshort *v1, const GLshort *v2); +GLAPI PFNGLRECTSVPROC glad_glRectsv; +#define glRectsv glad_glRectsv +typedef void (APIENTRYP PFNGLTEXCOORD1DPROC)(GLdouble s); +GLAPI PFNGLTEXCOORD1DPROC glad_glTexCoord1d; +#define glTexCoord1d glad_glTexCoord1d +typedef void (APIENTRYP PFNGLTEXCOORD1DVPROC)(const GLdouble *v); +GLAPI PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv; +#define glTexCoord1dv glad_glTexCoord1dv +typedef void (APIENTRYP PFNGLTEXCOORD1FPROC)(GLfloat s); +GLAPI PFNGLTEXCOORD1FPROC glad_glTexCoord1f; +#define glTexCoord1f glad_glTexCoord1f +typedef void (APIENTRYP PFNGLTEXCOORD1FVPROC)(const GLfloat *v); +GLAPI PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv; +#define glTexCoord1fv glad_glTexCoord1fv +typedef void (APIENTRYP PFNGLTEXCOORD1IPROC)(GLint s); +GLAPI PFNGLTEXCOORD1IPROC glad_glTexCoord1i; +#define glTexCoord1i glad_glTexCoord1i +typedef void (APIENTRYP PFNGLTEXCOORD1IVPROC)(const GLint *v); +GLAPI PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv; +#define glTexCoord1iv glad_glTexCoord1iv +typedef void (APIENTRYP PFNGLTEXCOORD1SPROC)(GLshort s); +GLAPI PFNGLTEXCOORD1SPROC glad_glTexCoord1s; +#define glTexCoord1s glad_glTexCoord1s +typedef void (APIENTRYP PFNGLTEXCOORD1SVPROC)(const GLshort *v); +GLAPI PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv; +#define glTexCoord1sv glad_glTexCoord1sv +typedef void (APIENTRYP PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t); +GLAPI PFNGLTEXCOORD2DPROC glad_glTexCoord2d; +#define glTexCoord2d glad_glTexCoord2d +typedef void (APIENTRYP PFNGLTEXCOORD2DVPROC)(const GLdouble *v); +GLAPI PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv; +#define glTexCoord2dv glad_glTexCoord2dv +typedef void (APIENTRYP PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t); +GLAPI PFNGLTEXCOORD2FPROC glad_glTexCoord2f; +#define glTexCoord2f glad_glTexCoord2f +typedef void (APIENTRYP PFNGLTEXCOORD2FVPROC)(const GLfloat *v); +GLAPI PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv; +#define glTexCoord2fv glad_glTexCoord2fv +typedef void (APIENTRYP PFNGLTEXCOORD2IPROC)(GLint s, GLint t); +GLAPI PFNGLTEXCOORD2IPROC glad_glTexCoord2i; +#define glTexCoord2i glad_glTexCoord2i +typedef void (APIENTRYP PFNGLTEXCOORD2IVPROC)(const GLint *v); +GLAPI PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv; +#define glTexCoord2iv glad_glTexCoord2iv +typedef void (APIENTRYP PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t); +GLAPI PFNGLTEXCOORD2SPROC glad_glTexCoord2s; +#define glTexCoord2s glad_glTexCoord2s +typedef void (APIENTRYP PFNGLTEXCOORD2SVPROC)(const GLshort *v); +GLAPI PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv; +#define glTexCoord2sv glad_glTexCoord2sv +typedef void (APIENTRYP PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r); +GLAPI PFNGLTEXCOORD3DPROC glad_glTexCoord3d; +#define glTexCoord3d glad_glTexCoord3d +typedef void (APIENTRYP PFNGLTEXCOORD3DVPROC)(const GLdouble *v); +GLAPI PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv; +#define glTexCoord3dv glad_glTexCoord3dv +typedef void (APIENTRYP PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r); +GLAPI PFNGLTEXCOORD3FPROC glad_glTexCoord3f; +#define glTexCoord3f glad_glTexCoord3f +typedef void (APIENTRYP PFNGLTEXCOORD3FVPROC)(const GLfloat *v); +GLAPI PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv; +#define glTexCoord3fv glad_glTexCoord3fv +typedef void (APIENTRYP PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r); +GLAPI PFNGLTEXCOORD3IPROC glad_glTexCoord3i; +#define glTexCoord3i glad_glTexCoord3i +typedef void (APIENTRYP PFNGLTEXCOORD3IVPROC)(const GLint *v); +GLAPI PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv; +#define glTexCoord3iv glad_glTexCoord3iv +typedef void (APIENTRYP PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r); +GLAPI PFNGLTEXCOORD3SPROC glad_glTexCoord3s; +#define glTexCoord3s glad_glTexCoord3s +typedef void (APIENTRYP PFNGLTEXCOORD3SVPROC)(const GLshort *v); +GLAPI PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv; +#define glTexCoord3sv glad_glTexCoord3sv +typedef void (APIENTRYP PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI PFNGLTEXCOORD4DPROC glad_glTexCoord4d; +#define glTexCoord4d glad_glTexCoord4d +typedef void (APIENTRYP PFNGLTEXCOORD4DVPROC)(const GLdouble *v); +GLAPI PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv; +#define glTexCoord4dv glad_glTexCoord4dv +typedef void (APIENTRYP PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI PFNGLTEXCOORD4FPROC glad_glTexCoord4f; +#define glTexCoord4f glad_glTexCoord4f +typedef void (APIENTRYP PFNGLTEXCOORD4FVPROC)(const GLfloat *v); +GLAPI PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv; +#define glTexCoord4fv glad_glTexCoord4fv +typedef void (APIENTRYP PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q); +GLAPI PFNGLTEXCOORD4IPROC glad_glTexCoord4i; +#define glTexCoord4i glad_glTexCoord4i +typedef void (APIENTRYP PFNGLTEXCOORD4IVPROC)(const GLint *v); +GLAPI PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv; +#define glTexCoord4iv glad_glTexCoord4iv +typedef void (APIENTRYP PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI PFNGLTEXCOORD4SPROC glad_glTexCoord4s; +#define glTexCoord4s glad_glTexCoord4s +typedef void (APIENTRYP PFNGLTEXCOORD4SVPROC)(const GLshort *v); +GLAPI PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv; +#define glTexCoord4sv glad_glTexCoord4sv +typedef void (APIENTRYP PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y); +GLAPI PFNGLVERTEX2DPROC glad_glVertex2d; +#define glVertex2d glad_glVertex2d +typedef void (APIENTRYP PFNGLVERTEX2DVPROC)(const GLdouble *v); +GLAPI PFNGLVERTEX2DVPROC glad_glVertex2dv; +#define glVertex2dv glad_glVertex2dv +typedef void (APIENTRYP PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y); +GLAPI PFNGLVERTEX2FPROC glad_glVertex2f; +#define glVertex2f glad_glVertex2f +typedef void (APIENTRYP PFNGLVERTEX2FVPROC)(const GLfloat *v); +GLAPI PFNGLVERTEX2FVPROC glad_glVertex2fv; +#define glVertex2fv glad_glVertex2fv +typedef void (APIENTRYP PFNGLVERTEX2IPROC)(GLint x, GLint y); +GLAPI PFNGLVERTEX2IPROC glad_glVertex2i; +#define glVertex2i glad_glVertex2i +typedef void (APIENTRYP PFNGLVERTEX2IVPROC)(const GLint *v); +GLAPI PFNGLVERTEX2IVPROC glad_glVertex2iv; +#define glVertex2iv glad_glVertex2iv +typedef void (APIENTRYP PFNGLVERTEX2SPROC)(GLshort x, GLshort y); +GLAPI PFNGLVERTEX2SPROC glad_glVertex2s; +#define glVertex2s glad_glVertex2s +typedef void (APIENTRYP PFNGLVERTEX2SVPROC)(const GLshort *v); +GLAPI PFNGLVERTEX2SVPROC glad_glVertex2sv; +#define glVertex2sv glad_glVertex2sv +typedef void (APIENTRYP PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z); +GLAPI PFNGLVERTEX3DPROC glad_glVertex3d; +#define glVertex3d glad_glVertex3d +typedef void (APIENTRYP PFNGLVERTEX3DVPROC)(const GLdouble *v); +GLAPI PFNGLVERTEX3DVPROC glad_glVertex3dv; +#define glVertex3dv glad_glVertex3dv +typedef void (APIENTRYP PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z); +GLAPI PFNGLVERTEX3FPROC glad_glVertex3f; +#define glVertex3f glad_glVertex3f +typedef void (APIENTRYP PFNGLVERTEX3FVPROC)(const GLfloat *v); +GLAPI PFNGLVERTEX3FVPROC glad_glVertex3fv; +#define glVertex3fv glad_glVertex3fv +typedef void (APIENTRYP PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z); +GLAPI PFNGLVERTEX3IPROC glad_glVertex3i; +#define glVertex3i glad_glVertex3i +typedef void (APIENTRYP PFNGLVERTEX3IVPROC)(const GLint *v); +GLAPI PFNGLVERTEX3IVPROC glad_glVertex3iv; +#define glVertex3iv glad_glVertex3iv +typedef void (APIENTRYP PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z); +GLAPI PFNGLVERTEX3SPROC glad_glVertex3s; +#define glVertex3s glad_glVertex3s +typedef void (APIENTRYP PFNGLVERTEX3SVPROC)(const GLshort *v); +GLAPI PFNGLVERTEX3SVPROC glad_glVertex3sv; +#define glVertex3sv glad_glVertex3sv +typedef void (APIENTRYP PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI PFNGLVERTEX4DPROC glad_glVertex4d; +#define glVertex4d glad_glVertex4d +typedef void (APIENTRYP PFNGLVERTEX4DVPROC)(const GLdouble *v); +GLAPI PFNGLVERTEX4DVPROC glad_glVertex4dv; +#define glVertex4dv glad_glVertex4dv +typedef void (APIENTRYP PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI PFNGLVERTEX4FPROC glad_glVertex4f; +#define glVertex4f glad_glVertex4f +typedef void (APIENTRYP PFNGLVERTEX4FVPROC)(const GLfloat *v); +GLAPI PFNGLVERTEX4FVPROC glad_glVertex4fv; +#define glVertex4fv glad_glVertex4fv +typedef void (APIENTRYP PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w); +GLAPI PFNGLVERTEX4IPROC glad_glVertex4i; +#define glVertex4i glad_glVertex4i +typedef void (APIENTRYP PFNGLVERTEX4IVPROC)(const GLint *v); +GLAPI PFNGLVERTEX4IVPROC glad_glVertex4iv; +#define glVertex4iv glad_glVertex4iv +typedef void (APIENTRYP PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI PFNGLVERTEX4SPROC glad_glVertex4s; +#define glVertex4s glad_glVertex4s +typedef void (APIENTRYP PFNGLVERTEX4SVPROC)(const GLshort *v); +GLAPI PFNGLVERTEX4SVPROC glad_glVertex4sv; +#define glVertex4sv glad_glVertex4sv +typedef void (APIENTRYP PFNGLCLIPPLANEPROC)(GLenum plane, const GLdouble *equation); +GLAPI PFNGLCLIPPLANEPROC glad_glClipPlane; +#define glClipPlane glad_glClipPlane +typedef void (APIENTRYP PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode); +GLAPI PFNGLCOLORMATERIALPROC glad_glColorMaterial; +#define glColorMaterial glad_glColorMaterial +typedef void (APIENTRYP PFNGLFOGFPROC)(GLenum pname, GLfloat param); +GLAPI PFNGLFOGFPROC glad_glFogf; +#define glFogf glad_glFogf +typedef void (APIENTRYP PFNGLFOGFVPROC)(GLenum pname, const GLfloat *params); +GLAPI PFNGLFOGFVPROC glad_glFogfv; +#define glFogfv glad_glFogfv +typedef void (APIENTRYP PFNGLFOGIPROC)(GLenum pname, GLint param); +GLAPI PFNGLFOGIPROC glad_glFogi; +#define glFogi glad_glFogi +typedef void (APIENTRYP PFNGLFOGIVPROC)(GLenum pname, const GLint *params); +GLAPI PFNGLFOGIVPROC glad_glFogiv; +#define glFogiv glad_glFogiv +typedef void (APIENTRYP PFNGLLIGHTFPROC)(GLenum light, GLenum pname, GLfloat param); +GLAPI PFNGLLIGHTFPROC glad_glLightf; +#define glLightf glad_glLightf +typedef void (APIENTRYP PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, const GLfloat *params); +GLAPI PFNGLLIGHTFVPROC glad_glLightfv; +#define glLightfv glad_glLightfv +typedef void (APIENTRYP PFNGLLIGHTIPROC)(GLenum light, GLenum pname, GLint param); +GLAPI PFNGLLIGHTIPROC glad_glLighti; +#define glLighti glad_glLighti +typedef void (APIENTRYP PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, const GLint *params); +GLAPI PFNGLLIGHTIVPROC glad_glLightiv; +#define glLightiv glad_glLightiv +typedef void (APIENTRYP PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param); +GLAPI PFNGLLIGHTMODELFPROC glad_glLightModelf; +#define glLightModelf glad_glLightModelf +typedef void (APIENTRYP PFNGLLIGHTMODELFVPROC)(GLenum pname, const GLfloat *params); +GLAPI PFNGLLIGHTMODELFVPROC glad_glLightModelfv; +#define glLightModelfv glad_glLightModelfv +typedef void (APIENTRYP PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param); +GLAPI PFNGLLIGHTMODELIPROC glad_glLightModeli; +#define glLightModeli glad_glLightModeli +typedef void (APIENTRYP PFNGLLIGHTMODELIVPROC)(GLenum pname, const GLint *params); +GLAPI PFNGLLIGHTMODELIVPROC glad_glLightModeliv; +#define glLightModeliv glad_glLightModeliv +typedef void (APIENTRYP PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern); +GLAPI PFNGLLINESTIPPLEPROC glad_glLineStipple; +#define glLineStipple glad_glLineStipple +typedef void (APIENTRYP PFNGLMATERIALFPROC)(GLenum face, GLenum pname, GLfloat param); +GLAPI PFNGLMATERIALFPROC glad_glMaterialf; +#define glMaterialf glad_glMaterialf +typedef void (APIENTRYP PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, const GLfloat *params); +GLAPI PFNGLMATERIALFVPROC glad_glMaterialfv; +#define glMaterialfv glad_glMaterialfv +typedef void (APIENTRYP PFNGLMATERIALIPROC)(GLenum face, GLenum pname, GLint param); +GLAPI PFNGLMATERIALIPROC glad_glMateriali; +#define glMateriali glad_glMateriali +typedef void (APIENTRYP PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, const GLint *params); +GLAPI PFNGLMATERIALIVPROC glad_glMaterialiv; +#define glMaterialiv glad_glMaterialiv +typedef void (APIENTRYP PFNGLPOLYGONSTIPPLEPROC)(const GLubyte *mask); +GLAPI PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple; +#define glPolygonStipple glad_glPolygonStipple +typedef void (APIENTRYP PFNGLSHADEMODELPROC)(GLenum mode); +GLAPI PFNGLSHADEMODELPROC glad_glShadeModel; +#define glShadeModel glad_glShadeModel +typedef void (APIENTRYP PFNGLTEXENVFPROC)(GLenum target, GLenum pname, GLfloat param); +GLAPI PFNGLTEXENVFPROC glad_glTexEnvf; +#define glTexEnvf glad_glTexEnvf +typedef void (APIENTRYP PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, const GLfloat *params); +GLAPI PFNGLTEXENVFVPROC glad_glTexEnvfv; +#define glTexEnvfv glad_glTexEnvfv +typedef void (APIENTRYP PFNGLTEXENVIPROC)(GLenum target, GLenum pname, GLint param); +GLAPI PFNGLTEXENVIPROC glad_glTexEnvi; +#define glTexEnvi glad_glTexEnvi +typedef void (APIENTRYP PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, const GLint *params); +GLAPI PFNGLTEXENVIVPROC glad_glTexEnviv; +#define glTexEnviv glad_glTexEnviv +typedef void (APIENTRYP PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, GLdouble param); +GLAPI PFNGLTEXGENDPROC glad_glTexGend; +#define glTexGend glad_glTexGend +typedef void (APIENTRYP PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, const GLdouble *params); +GLAPI PFNGLTEXGENDVPROC glad_glTexGendv; +#define glTexGendv glad_glTexGendv +typedef void (APIENTRYP PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, GLfloat param); +GLAPI PFNGLTEXGENFPROC glad_glTexGenf; +#define glTexGenf glad_glTexGenf +typedef void (APIENTRYP PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, const GLfloat *params); +GLAPI PFNGLTEXGENFVPROC glad_glTexGenfv; +#define glTexGenfv glad_glTexGenfv +typedef void (APIENTRYP PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, GLint param); +GLAPI PFNGLTEXGENIPROC glad_glTexGeni; +#define glTexGeni glad_glTexGeni +typedef void (APIENTRYP PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, const GLint *params); +GLAPI PFNGLTEXGENIVPROC glad_glTexGeniv; +#define glTexGeniv glad_glTexGeniv +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, GLfloat *buffer); +GLAPI PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer; +#define glFeedbackBuffer glad_glFeedbackBuffer +typedef void (APIENTRYP PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint *buffer); +GLAPI PFNGLSELECTBUFFERPROC glad_glSelectBuffer; +#define glSelectBuffer glad_glSelectBuffer +typedef GLint (APIENTRYP PFNGLRENDERMODEPROC)(GLenum mode); +GLAPI PFNGLRENDERMODEPROC glad_glRenderMode; +#define glRenderMode glad_glRenderMode +typedef void (APIENTRYP PFNGLINITNAMESPROC)(void); +GLAPI PFNGLINITNAMESPROC glad_glInitNames; +#define glInitNames glad_glInitNames +typedef void (APIENTRYP PFNGLLOADNAMEPROC)(GLuint name); +GLAPI PFNGLLOADNAMEPROC glad_glLoadName; +#define glLoadName glad_glLoadName +typedef void (APIENTRYP PFNGLPASSTHROUGHPROC)(GLfloat token); +GLAPI PFNGLPASSTHROUGHPROC glad_glPassThrough; +#define glPassThrough glad_glPassThrough +typedef void (APIENTRYP PFNGLPOPNAMEPROC)(void); +GLAPI PFNGLPOPNAMEPROC glad_glPopName; +#define glPopName glad_glPopName +typedef void (APIENTRYP PFNGLPUSHNAMEPROC)(GLuint name); +GLAPI PFNGLPUSHNAMEPROC glad_glPushName; +#define glPushName glad_glPushName +typedef void (APIENTRYP PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI PFNGLCLEARACCUMPROC glad_glClearAccum; +#define glClearAccum glad_glClearAccum +typedef void (APIENTRYP PFNGLCLEARINDEXPROC)(GLfloat c); +GLAPI PFNGLCLEARINDEXPROC glad_glClearIndex; +#define glClearIndex glad_glClearIndex +typedef void (APIENTRYP PFNGLINDEXMASKPROC)(GLuint mask); +GLAPI PFNGLINDEXMASKPROC glad_glIndexMask; +#define glIndexMask glad_glIndexMask +typedef void (APIENTRYP PFNGLACCUMPROC)(GLenum op, GLfloat value); +GLAPI PFNGLACCUMPROC glad_glAccum; +#define glAccum glad_glAccum +typedef void (APIENTRYP PFNGLPOPATTRIBPROC)(void); +GLAPI PFNGLPOPATTRIBPROC glad_glPopAttrib; +#define glPopAttrib glad_glPopAttrib +typedef void (APIENTRYP PFNGLPUSHATTRIBPROC)(GLbitfield mask); +GLAPI PFNGLPUSHATTRIBPROC glad_glPushAttrib; +#define glPushAttrib glad_glPushAttrib +typedef void (APIENTRYP PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI PFNGLMAP1DPROC glad_glMap1d; +#define glMap1d glad_glMap1d +typedef void (APIENTRYP PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI PFNGLMAP1FPROC glad_glMap1f; +#define glMap1f glad_glMap1f +typedef void (APIENTRYP PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI PFNGLMAP2DPROC glad_glMap2d; +#define glMap2d glad_glMap2d +typedef void (APIENTRYP PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +GLAPI PFNGLMAP2FPROC glad_glMap2f; +#define glMap2f glad_glMap2f +typedef void (APIENTRYP PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2); +GLAPI PFNGLMAPGRID1DPROC glad_glMapGrid1d; +#define glMapGrid1d glad_glMapGrid1d +typedef void (APIENTRYP PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2); +GLAPI PFNGLMAPGRID1FPROC glad_glMapGrid1f; +#define glMapGrid1f glad_glMapGrid1f +typedef void (APIENTRYP PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +GLAPI PFNGLMAPGRID2DPROC glad_glMapGrid2d; +#define glMapGrid2d glad_glMapGrid2d +typedef void (APIENTRYP PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +GLAPI PFNGLMAPGRID2FPROC glad_glMapGrid2f; +#define glMapGrid2f glad_glMapGrid2f +typedef void (APIENTRYP PFNGLEVALCOORD1DPROC)(GLdouble u); +GLAPI PFNGLEVALCOORD1DPROC glad_glEvalCoord1d; +#define glEvalCoord1d glad_glEvalCoord1d +typedef void (APIENTRYP PFNGLEVALCOORD1DVPROC)(const GLdouble *u); +GLAPI PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv; +#define glEvalCoord1dv glad_glEvalCoord1dv +typedef void (APIENTRYP PFNGLEVALCOORD1FPROC)(GLfloat u); +GLAPI PFNGLEVALCOORD1FPROC glad_glEvalCoord1f; +#define glEvalCoord1f glad_glEvalCoord1f +typedef void (APIENTRYP PFNGLEVALCOORD1FVPROC)(const GLfloat *u); +GLAPI PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv; +#define glEvalCoord1fv glad_glEvalCoord1fv +typedef void (APIENTRYP PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v); +GLAPI PFNGLEVALCOORD2DPROC glad_glEvalCoord2d; +#define glEvalCoord2d glad_glEvalCoord2d +typedef void (APIENTRYP PFNGLEVALCOORD2DVPROC)(const GLdouble *u); +GLAPI PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv; +#define glEvalCoord2dv glad_glEvalCoord2dv +typedef void (APIENTRYP PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v); +GLAPI PFNGLEVALCOORD2FPROC glad_glEvalCoord2f; +#define glEvalCoord2f glad_glEvalCoord2f +typedef void (APIENTRYP PFNGLEVALCOORD2FVPROC)(const GLfloat *u); +GLAPI PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv; +#define glEvalCoord2fv glad_glEvalCoord2fv +typedef void (APIENTRYP PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2); +GLAPI PFNGLEVALMESH1PROC glad_glEvalMesh1; +#define glEvalMesh1 glad_glEvalMesh1 +typedef void (APIENTRYP PFNGLEVALPOINT1PROC)(GLint i); +GLAPI PFNGLEVALPOINT1PROC glad_glEvalPoint1; +#define glEvalPoint1 glad_glEvalPoint1 +typedef void (APIENTRYP PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +GLAPI PFNGLEVALMESH2PROC glad_glEvalMesh2; +#define glEvalMesh2 glad_glEvalMesh2 +typedef void (APIENTRYP PFNGLEVALPOINT2PROC)(GLint i, GLint j); +GLAPI PFNGLEVALPOINT2PROC glad_glEvalPoint2; +#define glEvalPoint2 glad_glEvalPoint2 +typedef void (APIENTRYP PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref); +GLAPI PFNGLALPHAFUNCPROC glad_glAlphaFunc; +#define glAlphaFunc glad_glAlphaFunc +typedef void (APIENTRYP PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor); +GLAPI PFNGLPIXELZOOMPROC glad_glPixelZoom; +#define glPixelZoom glad_glPixelZoom +typedef void (APIENTRYP PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param); +GLAPI PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf; +#define glPixelTransferf glad_glPixelTransferf +typedef void (APIENTRYP PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param); +GLAPI PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi; +#define glPixelTransferi glad_glPixelTransferi +typedef void (APIENTRYP PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, const GLfloat *values); +GLAPI PFNGLPIXELMAPFVPROC glad_glPixelMapfv; +#define glPixelMapfv glad_glPixelMapfv +typedef void (APIENTRYP PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, const GLuint *values); +GLAPI PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv; +#define glPixelMapuiv glad_glPixelMapuiv +typedef void (APIENTRYP PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, const GLushort *values); +GLAPI PFNGLPIXELMAPUSVPROC glad_glPixelMapusv; +#define glPixelMapusv glad_glPixelMapusv +typedef void (APIENTRYP PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +GLAPI PFNGLCOPYPIXELSPROC glad_glCopyPixels; +#define glCopyPixels glad_glCopyPixels +typedef void (APIENTRYP PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI PFNGLDRAWPIXELSPROC glad_glDrawPixels; +#define glDrawPixels glad_glDrawPixels +typedef void (APIENTRYP PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble *equation); +GLAPI PFNGLGETCLIPPLANEPROC glad_glGetClipPlane; +#define glGetClipPlane glad_glGetClipPlane +typedef void (APIENTRYP PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, GLfloat *params); +GLAPI PFNGLGETLIGHTFVPROC glad_glGetLightfv; +#define glGetLightfv glad_glGetLightfv +typedef void (APIENTRYP PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, GLint *params); +GLAPI PFNGLGETLIGHTIVPROC glad_glGetLightiv; +#define glGetLightiv glad_glGetLightiv +typedef void (APIENTRYP PFNGLGETMAPDVPROC)(GLenum target, GLenum query, GLdouble *v); +GLAPI PFNGLGETMAPDVPROC glad_glGetMapdv; +#define glGetMapdv glad_glGetMapdv +typedef void (APIENTRYP PFNGLGETMAPFVPROC)(GLenum target, GLenum query, GLfloat *v); +GLAPI PFNGLGETMAPFVPROC glad_glGetMapfv; +#define glGetMapfv glad_glGetMapfv +typedef void (APIENTRYP PFNGLGETMAPIVPROC)(GLenum target, GLenum query, GLint *v); +GLAPI PFNGLGETMAPIVPROC glad_glGetMapiv; +#define glGetMapiv glad_glGetMapiv +typedef void (APIENTRYP PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, GLfloat *params); +GLAPI PFNGLGETMATERIALFVPROC glad_glGetMaterialfv; +#define glGetMaterialfv glad_glGetMaterialfv +typedef void (APIENTRYP PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, GLint *params); +GLAPI PFNGLGETMATERIALIVPROC glad_glGetMaterialiv; +#define glGetMaterialiv glad_glGetMaterialiv +typedef void (APIENTRYP PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat *values); +GLAPI PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv; +#define glGetPixelMapfv glad_glGetPixelMapfv +typedef void (APIENTRYP PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint *values); +GLAPI PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv; +#define glGetPixelMapuiv glad_glGetPixelMapuiv +typedef void (APIENTRYP PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort *values); +GLAPI PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv; +#define glGetPixelMapusv glad_glGetPixelMapusv +typedef void (APIENTRYP PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte *mask); +GLAPI PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple; +#define glGetPolygonStipple glad_glGetPolygonStipple +typedef void (APIENTRYP PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, GLfloat *params); +GLAPI PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv; +#define glGetTexEnvfv glad_glGetTexEnvfv +typedef void (APIENTRYP PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, GLint *params); +GLAPI PFNGLGETTEXENVIVPROC glad_glGetTexEnviv; +#define glGetTexEnviv glad_glGetTexEnviv +typedef void (APIENTRYP PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, GLdouble *params); +GLAPI PFNGLGETTEXGENDVPROC glad_glGetTexGendv; +#define glGetTexGendv glad_glGetTexGendv +typedef void (APIENTRYP PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, GLfloat *params); +GLAPI PFNGLGETTEXGENFVPROC glad_glGetTexGenfv; +#define glGetTexGenfv glad_glGetTexGenfv +typedef void (APIENTRYP PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, GLint *params); +GLAPI PFNGLGETTEXGENIVPROC glad_glGetTexGeniv; +#define glGetTexGeniv glad_glGetTexGeniv +typedef GLboolean (APIENTRYP PFNGLISLISTPROC)(GLuint list); +GLAPI PFNGLISLISTPROC glad_glIsList; +#define glIsList glad_glIsList +typedef void (APIENTRYP PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI PFNGLFRUSTUMPROC glad_glFrustum; +#define glFrustum glad_glFrustum +typedef void (APIENTRYP PFNGLLOADIDENTITYPROC)(void); +GLAPI PFNGLLOADIDENTITYPROC glad_glLoadIdentity; +#define glLoadIdentity glad_glLoadIdentity +typedef void (APIENTRYP PFNGLLOADMATRIXFPROC)(const GLfloat *m); +GLAPI PFNGLLOADMATRIXFPROC glad_glLoadMatrixf; +#define glLoadMatrixf glad_glLoadMatrixf +typedef void (APIENTRYP PFNGLLOADMATRIXDPROC)(const GLdouble *m); +GLAPI PFNGLLOADMATRIXDPROC glad_glLoadMatrixd; +#define glLoadMatrixd glad_glLoadMatrixd +typedef void (APIENTRYP PFNGLMATRIXMODEPROC)(GLenum mode); +GLAPI PFNGLMATRIXMODEPROC glad_glMatrixMode; +#define glMatrixMode glad_glMatrixMode +typedef void (APIENTRYP PFNGLMULTMATRIXFPROC)(const GLfloat *m); +GLAPI PFNGLMULTMATRIXFPROC glad_glMultMatrixf; +#define glMultMatrixf glad_glMultMatrixf +typedef void (APIENTRYP PFNGLMULTMATRIXDPROC)(const GLdouble *m); +GLAPI PFNGLMULTMATRIXDPROC glad_glMultMatrixd; +#define glMultMatrixd glad_glMultMatrixd +typedef void (APIENTRYP PFNGLORTHOPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI PFNGLORTHOPROC glad_glOrtho; +#define glOrtho glad_glOrtho +typedef void (APIENTRYP PFNGLPOPMATRIXPROC)(void); +GLAPI PFNGLPOPMATRIXPROC glad_glPopMatrix; +#define glPopMatrix glad_glPopMatrix +typedef void (APIENTRYP PFNGLPUSHMATRIXPROC)(void); +GLAPI PFNGLPUSHMATRIXPROC glad_glPushMatrix; +#define glPushMatrix glad_glPushMatrix +typedef void (APIENTRYP PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI PFNGLROTATEDPROC glad_glRotated; +#define glRotated glad_glRotated +typedef void (APIENTRYP PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI PFNGLROTATEFPROC glad_glRotatef; +#define glRotatef glad_glRotatef +typedef void (APIENTRYP PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z); +GLAPI PFNGLSCALEDPROC glad_glScaled; +#define glScaled glad_glScaled +typedef void (APIENTRYP PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z); +GLAPI PFNGLSCALEFPROC glad_glScalef; +#define glScalef glad_glScalef +typedef void (APIENTRYP PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z); +GLAPI PFNGLTRANSLATEDPROC glad_glTranslated; +#define glTranslated glad_glTranslated +typedef void (APIENTRYP PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z); +GLAPI PFNGLTRANSLATEFPROC glad_glTranslatef; +#define glTranslatef glad_glTranslatef +#endif +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 +GLAPI int GLAD_GL_VERSION_1_1; +typedef void (APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count); +GLAPI PFNGLDRAWARRAYSPROC glad_glDrawArrays; +#define glDrawArrays glad_glDrawArrays +typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices); +GLAPI PFNGLDRAWELEMENTSPROC glad_glDrawElements; +#define glDrawElements glad_glDrawElements +typedef void (APIENTRYP PFNGLGETPOINTERVPROC)(GLenum pname, void **params); +GLAPI PFNGLGETPOINTERVPROC glad_glGetPointerv; +#define glGetPointerv glad_glGetPointerv +typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); +GLAPI PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset; +#define glPolygonOffset glad_glPolygonOffset +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D; +#define glCopyTexImage1D glad_glCopyTexImage1D +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D; +#define glCopyTexImage2D glad_glCopyTexImage2D +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D; +#define glCopyTexSubImage1D glad_glCopyTexSubImage1D +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D; +#define glCopyTexSubImage2D glad_glCopyTexSubImage2D +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D; +#define glTexSubImage1D glad_glTexSubImage1D +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D; +#define glTexSubImage2D glad_glTexSubImage2D +typedef void (APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); +GLAPI PFNGLBINDTEXTUREPROC glad_glBindTexture; +#define glBindTexture glad_glBindTexture +typedef void (APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint *textures); +GLAPI PFNGLDELETETEXTURESPROC glad_glDeleteTextures; +#define glDeleteTextures glad_glDeleteTextures +typedef void (APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint *textures); +GLAPI PFNGLGENTEXTURESPROC glad_glGenTextures; +#define glGenTextures glad_glGenTextures +typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture); +GLAPI PFNGLISTEXTUREPROC glad_glIsTexture; +#define glIsTexture glad_glIsTexture +typedef void (APIENTRYP PFNGLARRAYELEMENTPROC)(GLint i); +GLAPI PFNGLARRAYELEMENTPROC glad_glArrayElement; +#define glArrayElement glad_glArrayElement +typedef void (APIENTRYP PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLCOLORPOINTERPROC glad_glColorPointer; +#define glColorPointer glad_glColorPointer +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEPROC)(GLenum array); +GLAPI PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState; +#define glDisableClientState glad_glDisableClientState +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, const void *pointer); +GLAPI PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer; +#define glEdgeFlagPointer glad_glEdgeFlagPointer +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEPROC)(GLenum array); +GLAPI PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState; +#define glEnableClientState glad_glEnableClientState +typedef void (APIENTRYP PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLINDEXPOINTERPROC glad_glIndexPointer; +#define glIndexPointer glad_glIndexPointer +typedef void (APIENTRYP PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, GLsizei stride, const void *pointer); +GLAPI PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays; +#define glInterleavedArrays glad_glInterleavedArrays +typedef void (APIENTRYP PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLNORMALPOINTERPROC glad_glNormalPointer; +#define glNormalPointer glad_glNormalPointer +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer; +#define glTexCoordPointer glad_glTexCoordPointer +typedef void (APIENTRYP PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLVERTEXPOINTERPROC glad_glVertexPointer; +#define glVertexPointer glad_glVertexPointer +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTPROC)(GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident; +#define glAreTexturesResident glad_glAreTexturesResident +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, const GLuint *textures, const GLfloat *priorities); +GLAPI PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures; +#define glPrioritizeTextures glad_glPrioritizeTextures +typedef void (APIENTRYP PFNGLINDEXUBPROC)(GLubyte c); +GLAPI PFNGLINDEXUBPROC glad_glIndexub; +#define glIndexub glad_glIndexub +typedef void (APIENTRYP PFNGLINDEXUBVPROC)(const GLubyte *c); +GLAPI PFNGLINDEXUBVPROC glad_glIndexubv; +#define glIndexubv glad_glIndexubv +typedef void (APIENTRYP PFNGLPOPCLIENTATTRIBPROC)(void); +GLAPI PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib; +#define glPopClientAttrib glad_glPopClientAttrib +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask); +GLAPI PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib; +#define glPushClientAttrib glad_glPushClientAttrib +#endif +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +GLAPI int GLAD_GL_VERSION_1_2; +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements; +#define glDrawRangeElements glad_glDrawRangeElements +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI PFNGLTEXIMAGE3DPROC glad_glTexImage3D; +#define glTexImage3D glad_glTexImage3D +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D; +#define glTexSubImage3D glad_glTexSubImage3D +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D; +#define glCopyTexSubImage3D glad_glCopyTexSubImage3D +#endif +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +GLAPI int GLAD_GL_VERSION_1_3; +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture); +GLAPI PFNGLACTIVETEXTUREPROC glad_glActiveTexture; +#define glActiveTexture glad_glActiveTexture +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert); +GLAPI PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage; +#define glSampleCoverage glad_glSampleCoverage +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D; +#define glCompressedTexImage3D glad_glCompressedTexImage3D +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D; +#define glCompressedTexImage2D glad_glCompressedTexImage2D +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D; +#define glCompressedTexImage1D glad_glCompressedTexImage1D +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D; +#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D; +#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D; +#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void *img); +GLAPI PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage; +#define glGetCompressedTexImage glad_glGetCompressedTexImage +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture); +GLAPI PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture; +#define glClientActiveTexture glad_glClientActiveTexture +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s); +GLAPI PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d; +#define glMultiTexCoord1d glad_glMultiTexCoord1d +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC)(GLenum target, const GLdouble *v); +GLAPI PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv; +#define glMultiTexCoord1dv glad_glMultiTexCoord1dv +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s); +GLAPI PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f; +#define glMultiTexCoord1f glad_glMultiTexCoord1f +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC)(GLenum target, const GLfloat *v); +GLAPI PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv; +#define glMultiTexCoord1fv glad_glMultiTexCoord1fv +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s); +GLAPI PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i; +#define glMultiTexCoord1i glad_glMultiTexCoord1i +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC)(GLenum target, const GLint *v); +GLAPI PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv; +#define glMultiTexCoord1iv glad_glMultiTexCoord1iv +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s); +GLAPI PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s; +#define glMultiTexCoord1s glad_glMultiTexCoord1s +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC)(GLenum target, const GLshort *v); +GLAPI PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv; +#define glMultiTexCoord1sv glad_glMultiTexCoord1sv +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, GLdouble t); +GLAPI PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d; +#define glMultiTexCoord2d glad_glMultiTexCoord2d +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC)(GLenum target, const GLdouble *v); +GLAPI PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv; +#define glMultiTexCoord2dv glad_glMultiTexCoord2dv +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t); +GLAPI PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f; +#define glMultiTexCoord2f glad_glMultiTexCoord2f +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC)(GLenum target, const GLfloat *v); +GLAPI PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv; +#define glMultiTexCoord2fv glad_glMultiTexCoord2fv +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, GLint t); +GLAPI PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i; +#define glMultiTexCoord2i glad_glMultiTexCoord2i +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC)(GLenum target, const GLint *v); +GLAPI PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv; +#define glMultiTexCoord2iv glad_glMultiTexCoord2iv +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, GLshort t); +GLAPI PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s; +#define glMultiTexCoord2s glad_glMultiTexCoord2s +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC)(GLenum target, const GLshort *v); +GLAPI PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv; +#define glMultiTexCoord2sv glad_glMultiTexCoord2sv +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d; +#define glMultiTexCoord3d glad_glMultiTexCoord3d +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC)(GLenum target, const GLdouble *v); +GLAPI PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv; +#define glMultiTexCoord3dv glad_glMultiTexCoord3dv +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f; +#define glMultiTexCoord3f glad_glMultiTexCoord3f +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC)(GLenum target, const GLfloat *v); +GLAPI PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv; +#define glMultiTexCoord3fv glad_glMultiTexCoord3fv +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, GLint t, GLint r); +GLAPI PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i; +#define glMultiTexCoord3i glad_glMultiTexCoord3i +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC)(GLenum target, const GLint *v); +GLAPI PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv; +#define glMultiTexCoord3iv glad_glMultiTexCoord3iv +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s; +#define glMultiTexCoord3s glad_glMultiTexCoord3s +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC)(GLenum target, const GLshort *v); +GLAPI PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv; +#define glMultiTexCoord3sv glad_glMultiTexCoord3sv +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d; +#define glMultiTexCoord4d glad_glMultiTexCoord4d +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC)(GLenum target, const GLdouble *v); +GLAPI PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv; +#define glMultiTexCoord4dv glad_glMultiTexCoord4dv +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f; +#define glMultiTexCoord4f glad_glMultiTexCoord4f +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC)(GLenum target, const GLfloat *v); +GLAPI PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv; +#define glMultiTexCoord4fv glad_glMultiTexCoord4fv +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i; +#define glMultiTexCoord4i glad_glMultiTexCoord4i +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC)(GLenum target, const GLint *v); +GLAPI PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv; +#define glMultiTexCoord4iv glad_glMultiTexCoord4iv +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s; +#define glMultiTexCoord4s glad_glMultiTexCoord4s +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC)(GLenum target, const GLshort *v); +GLAPI PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv; +#define glMultiTexCoord4sv glad_glMultiTexCoord4sv +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat *m); +GLAPI PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf; +#define glLoadTransposeMatrixf glad_glLoadTransposeMatrixf +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble *m); +GLAPI PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd; +#define glLoadTransposeMatrixd glad_glLoadTransposeMatrixd +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat *m); +GLAPI PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf; +#define glMultTransposeMatrixf glad_glMultTransposeMatrixf +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble *m); +GLAPI PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd; +#define glMultTransposeMatrixd glad_glMultTransposeMatrixd +#endif +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +GLAPI int GLAD_GL_VERSION_1_4; +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate; +#define glBlendFuncSeparate glad_glBlendFuncSeparate +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays; +#define glMultiDrawArrays glad_glMultiDrawArrays +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements; +#define glMultiDrawElements glad_glMultiDrawElements +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param); +GLAPI PFNGLPOINTPARAMETERFPROC glad_glPointParameterf; +#define glPointParameterf glad_glPointParameterf +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat *params); +GLAPI PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv; +#define glPointParameterfv glad_glPointParameterfv +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param); +GLAPI PFNGLPOINTPARAMETERIPROC glad_glPointParameteri; +#define glPointParameteri glad_glPointParameteri +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint *params); +GLAPI PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv; +#define glPointParameteriv glad_glPointParameteriv +typedef void (APIENTRYP PFNGLFOGCOORDFPROC)(GLfloat coord); +GLAPI PFNGLFOGCOORDFPROC glad_glFogCoordf; +#define glFogCoordf glad_glFogCoordf +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC)(const GLfloat *coord); +GLAPI PFNGLFOGCOORDFVPROC glad_glFogCoordfv; +#define glFogCoordfv glad_glFogCoordfv +typedef void (APIENTRYP PFNGLFOGCOORDDPROC)(GLdouble coord); +GLAPI PFNGLFOGCOORDDPROC glad_glFogCoordd; +#define glFogCoordd glad_glFogCoordd +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC)(const GLdouble *coord); +GLAPI PFNGLFOGCOORDDVPROC glad_glFogCoorddv; +#define glFogCoorddv glad_glFogCoorddv +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer; +#define glFogCoordPointer glad_glFogCoordPointer +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +GLAPI PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b; +#define glSecondaryColor3b glad_glSecondaryColor3b +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte *v); +GLAPI PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv; +#define glSecondaryColor3bv glad_glSecondaryColor3bv +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +GLAPI PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d; +#define glSecondaryColor3d glad_glSecondaryColor3d +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble *v); +GLAPI PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv; +#define glSecondaryColor3dv glad_glSecondaryColor3dv +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +GLAPI PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f; +#define glSecondaryColor3f glad_glSecondaryColor3f +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat *v); +GLAPI PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv; +#define glSecondaryColor3fv glad_glSecondaryColor3fv +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, GLint blue); +GLAPI PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i; +#define glSecondaryColor3i glad_glSecondaryColor3i +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC)(const GLint *v); +GLAPI PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv; +#define glSecondaryColor3iv glad_glSecondaryColor3iv +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +GLAPI PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s; +#define glSecondaryColor3s glad_glSecondaryColor3s +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC)(const GLshort *v); +GLAPI PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv; +#define glSecondaryColor3sv glad_glSecondaryColor3sv +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +GLAPI PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub; +#define glSecondaryColor3ub glad_glSecondaryColor3ub +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte *v); +GLAPI PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv; +#define glSecondaryColor3ubv glad_glSecondaryColor3ubv +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +GLAPI PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui; +#define glSecondaryColor3ui glad_glSecondaryColor3ui +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint *v); +GLAPI PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv; +#define glSecondaryColor3uiv glad_glSecondaryColor3uiv +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +GLAPI PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us; +#define glSecondaryColor3us glad_glSecondaryColor3us +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC)(const GLushort *v); +GLAPI PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv; +#define glSecondaryColor3usv glad_glSecondaryColor3usv +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer; +#define glSecondaryColorPointer glad_glSecondaryColorPointer +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y); +GLAPI PFNGLWINDOWPOS2DPROC glad_glWindowPos2d; +#define glWindowPos2d glad_glWindowPos2d +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC)(const GLdouble *v); +GLAPI PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv; +#define glWindowPos2dv glad_glWindowPos2dv +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y); +GLAPI PFNGLWINDOWPOS2FPROC glad_glWindowPos2f; +#define glWindowPos2f glad_glWindowPos2f +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC)(const GLfloat *v); +GLAPI PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv; +#define glWindowPos2fv glad_glWindowPos2fv +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC)(GLint x, GLint y); +GLAPI PFNGLWINDOWPOS2IPROC glad_glWindowPos2i; +#define glWindowPos2i glad_glWindowPos2i +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC)(const GLint *v); +GLAPI PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv; +#define glWindowPos2iv glad_glWindowPos2iv +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y); +GLAPI PFNGLWINDOWPOS2SPROC glad_glWindowPos2s; +#define glWindowPos2s glad_glWindowPos2s +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC)(const GLshort *v); +GLAPI PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv; +#define glWindowPos2sv glad_glWindowPos2sv +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +GLAPI PFNGLWINDOWPOS3DPROC glad_glWindowPos3d; +#define glWindowPos3d glad_glWindowPos3d +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC)(const GLdouble *v); +GLAPI PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv; +#define glWindowPos3dv glad_glWindowPos3dv +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +GLAPI PFNGLWINDOWPOS3FPROC glad_glWindowPos3f; +#define glWindowPos3f glad_glWindowPos3f +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC)(const GLfloat *v); +GLAPI PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv; +#define glWindowPos3fv glad_glWindowPos3fv +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z); +GLAPI PFNGLWINDOWPOS3IPROC glad_glWindowPos3i; +#define glWindowPos3i glad_glWindowPos3i +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC)(const GLint *v); +GLAPI PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv; +#define glWindowPos3iv glad_glWindowPos3iv +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z); +GLAPI PFNGLWINDOWPOS3SPROC glad_glWindowPos3s; +#define glWindowPos3s glad_glWindowPos3s +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC)(const GLshort *v); +GLAPI PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv; +#define glWindowPos3sv glad_glWindowPos3sv +typedef void (APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI PFNGLBLENDCOLORPROC glad_glBlendColor; +#define glBlendColor glad_glBlendColor +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode); +GLAPI PFNGLBLENDEQUATIONPROC glad_glBlendEquation; +#define glBlendEquation glad_glBlendEquation +#endif +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +GLAPI int GLAD_GL_VERSION_1_5; +typedef void (APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint *ids); +GLAPI PFNGLGENQUERIESPROC glad_glGenQueries; +#define glGenQueries glad_glGenQueries +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint *ids); +GLAPI PFNGLDELETEQUERIESPROC glad_glDeleteQueries; +#define glDeleteQueries glad_glDeleteQueries +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC)(GLuint id); +GLAPI PFNGLISQUERYPROC glad_glIsQuery; +#define glIsQuery glad_glIsQuery +typedef void (APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); +GLAPI PFNGLBEGINQUERYPROC glad_glBeginQuery; +#define glBeginQuery glad_glBeginQuery +typedef void (APIENTRYP PFNGLENDQUERYPROC)(GLenum target); +GLAPI PFNGLENDQUERYPROC glad_glEndQuery; +#define glEndQuery glad_glEndQuery +typedef void (APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint *params); +GLAPI PFNGLGETQUERYIVPROC glad_glGetQueryiv; +#define glGetQueryiv glad_glGetQueryiv +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint *params); +GLAPI PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv; +#define glGetQueryObjectiv glad_glGetQueryObjectiv +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint *params); +GLAPI PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv; +#define glGetQueryObjectuiv glad_glGetQueryObjectuiv +typedef void (APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); +GLAPI PFNGLBINDBUFFERPROC glad_glBindBuffer; +#define glBindBuffer glad_glBindBuffer +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint *buffers); +GLAPI PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers; +#define glDeleteBuffers glad_glDeleteBuffers +typedef void (APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint *buffers); +GLAPI PFNGLGENBUFFERSPROC glad_glGenBuffers; +#define glGenBuffers glad_glGenBuffers +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer); +GLAPI PFNGLISBUFFERPROC glad_glIsBuffer; +#define glIsBuffer glad_glIsBuffer +typedef void (APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI PFNGLBUFFERDATAPROC glad_glBufferData; +#define glBufferData glad_glBufferData +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI PFNGLBUFFERSUBDATAPROC glad_glBufferSubData; +#define glBufferSubData glad_glBufferSubData +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData; +#define glGetBufferSubData glad_glGetBufferSubData +typedef void * (APIENTRYP PFNGLMAPBUFFERPROC)(GLenum target, GLenum access); +GLAPI PFNGLMAPBUFFERPROC glad_glMapBuffer; +#define glMapBuffer glad_glMapBuffer +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target); +GLAPI PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer; +#define glUnmapBuffer glad_glUnmapBuffer +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +GLAPI PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv; +#define glGetBufferParameteriv glad_glGetBufferParameteriv +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void **params); +GLAPI PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv; +#define glGetBufferPointerv glad_glGetBufferPointerv +#endif +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +GLAPI int GLAD_GL_VERSION_2_0; +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); +GLAPI PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate; +#define glBlendEquationSeparate glad_glBlendEquationSeparate +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs); +GLAPI PFNGLDRAWBUFFERSPROC glad_glDrawBuffers; +#define glDrawBuffers glad_glDrawBuffers +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate; +#define glStencilOpSeparate glad_glStencilOpSeparate +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate; +#define glStencilFuncSeparate glad_glStencilFuncSeparate +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); +GLAPI PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate; +#define glStencilMaskSeparate glad_glStencilMaskSeparate +typedef void (APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); +GLAPI PFNGLATTACHSHADERPROC glad_glAttachShader; +#define glAttachShader glad_glAttachShader +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar *name); +GLAPI PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation; +#define glBindAttribLocation glad_glBindAttribLocation +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader); +GLAPI PFNGLCOMPILESHADERPROC glad_glCompileShader; +#define glCompileShader glad_glCompileShader +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC)(void); +GLAPI PFNGLCREATEPROGRAMPROC glad_glCreateProgram; +#define glCreateProgram glad_glCreateProgram +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC)(GLenum type); +GLAPI PFNGLCREATESHADERPROC glad_glCreateShader; +#define glCreateShader glad_glCreateShader +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program); +GLAPI PFNGLDELETEPROGRAMPROC glad_glDeleteProgram; +#define glDeleteProgram glad_glDeleteProgram +typedef void (APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader); +GLAPI PFNGLDELETESHADERPROC glad_glDeleteShader; +#define glDeleteShader glad_glDeleteShader +typedef void (APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); +GLAPI PFNGLDETACHSHADERPROC glad_glDetachShader; +#define glDetachShader glad_glDetachShader +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); +GLAPI PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray; +#define glDisableVertexAttribArray glad_glDisableVertexAttribArray +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); +GLAPI PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray; +#define glEnableVertexAttribArray glad_glEnableVertexAttribArray +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib; +#define glGetActiveAttrib glad_glGetActiveAttrib +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform; +#define glGetActiveUniform glad_glGetActiveUniform +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders; +#define glGetAttachedShaders glad_glGetAttachedShaders +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name); +GLAPI PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation; +#define glGetAttribLocation glad_glGetAttribLocation +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params); +GLAPI PFNGLGETPROGRAMIVPROC glad_glGetProgramiv; +#define glGetProgramiv glad_glGetProgramiv +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog; +#define glGetProgramInfoLog glad_glGetProgramInfoLog +typedef void (APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params); +GLAPI PFNGLGETSHADERIVPROC glad_glGetShaderiv; +#define glGetShaderiv glad_glGetShaderiv +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog; +#define glGetShaderInfoLog glad_glGetShaderInfoLog +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource; +#define glGetShaderSource glad_glGetShaderSource +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name); +GLAPI PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation; +#define glGetUniformLocation glad_glGetUniformLocation +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat *params); +GLAPI PFNGLGETUNIFORMFVPROC glad_glGetUniformfv; +#define glGetUniformfv glad_glGetUniformfv +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint *params); +GLAPI PFNGLGETUNIFORMIVPROC glad_glGetUniformiv; +#define glGetUniformiv glad_glGetUniformiv +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble *params); +GLAPI PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv; +#define glGetVertexAttribdv glad_glGetVertexAttribdv +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat *params); +GLAPI PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv; +#define glGetVertexAttribfv glad_glGetVertexAttribfv +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint *params); +GLAPI PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv; +#define glGetVertexAttribiv glad_glGetVertexAttribiv +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void **pointer); +GLAPI PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv; +#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC)(GLuint program); +GLAPI PFNGLISPROGRAMPROC glad_glIsProgram; +#define glIsProgram glad_glIsProgram +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC)(GLuint shader); +GLAPI PFNGLISSHADERPROC glad_glIsShader; +#define glIsShader glad_glIsShader +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program); +GLAPI PFNGLLINKPROGRAMPROC glad_glLinkProgram; +#define glLinkProgram glad_glLinkProgram +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI PFNGLSHADERSOURCEPROC glad_glShaderSource; +#define glShaderSource glad_glShaderSource +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program); +GLAPI PFNGLUSEPROGRAMPROC glad_glUseProgram; +#define glUseProgram glad_glUseProgram +typedef void (APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); +GLAPI PFNGLUNIFORM1FPROC glad_glUniform1f; +#define glUniform1f glad_glUniform1f +typedef void (APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); +GLAPI PFNGLUNIFORM2FPROC glad_glUniform2f; +#define glUniform2f glad_glUniform2f +typedef void (APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI PFNGLUNIFORM3FPROC glad_glUniform3f; +#define glUniform3f glad_glUniform3f +typedef void (APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI PFNGLUNIFORM4FPROC glad_glUniform4f; +#define glUniform4f glad_glUniform4f +typedef void (APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0); +GLAPI PFNGLUNIFORM1IPROC glad_glUniform1i; +#define glUniform1i glad_glUniform1i +typedef void (APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); +GLAPI PFNGLUNIFORM2IPROC glad_glUniform2i; +#define glUniform2i glad_glUniform2i +typedef void (APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); +GLAPI PFNGLUNIFORM3IPROC glad_glUniform3i; +#define glUniform3i glad_glUniform3i +typedef void (APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI PFNGLUNIFORM4IPROC glad_glUniform4i; +#define glUniform4i glad_glUniform4i +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat *value); +GLAPI PFNGLUNIFORM1FVPROC glad_glUniform1fv; +#define glUniform1fv glad_glUniform1fv +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat *value); +GLAPI PFNGLUNIFORM2FVPROC glad_glUniform2fv; +#define glUniform2fv glad_glUniform2fv +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat *value); +GLAPI PFNGLUNIFORM3FVPROC glad_glUniform3fv; +#define glUniform3fv glad_glUniform3fv +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat *value); +GLAPI PFNGLUNIFORM4FVPROC glad_glUniform4fv; +#define glUniform4fv glad_glUniform4fv +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint *value); +GLAPI PFNGLUNIFORM1IVPROC glad_glUniform1iv; +#define glUniform1iv glad_glUniform1iv +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint *value); +GLAPI PFNGLUNIFORM2IVPROC glad_glUniform2iv; +#define glUniform2iv glad_glUniform2iv +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint *value); +GLAPI PFNGLUNIFORM3IVPROC glad_glUniform3iv; +#define glUniform3iv glad_glUniform3iv +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint *value); +GLAPI PFNGLUNIFORM4IVPROC glad_glUniform4iv; +#define glUniform4iv glad_glUniform4iv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv; +#define glUniformMatrix2fv glad_glUniformMatrix2fv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv; +#define glUniformMatrix3fv glad_glUniformMatrix3fv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv; +#define glUniformMatrix4fv glad_glUniformMatrix4fv +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program); +GLAPI PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram; +#define glValidateProgram glad_glValidateProgram +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); +GLAPI PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d; +#define glVertexAttrib1d glad_glVertexAttrib1d +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble *v); +GLAPI PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv; +#define glVertexAttrib1dv glad_glVertexAttrib1dv +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); +GLAPI PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f; +#define glVertexAttrib1f glad_glVertexAttrib1f +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat *v); +GLAPI PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv; +#define glVertexAttrib1fv glad_glVertexAttrib1fv +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x); +GLAPI PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s; +#define glVertexAttrib1s glad_glVertexAttrib1s +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort *v); +GLAPI PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv; +#define glVertexAttrib1sv glad_glVertexAttrib1sv +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); +GLAPI PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d; +#define glVertexAttrib2d glad_glVertexAttrib2d +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble *v); +GLAPI PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv; +#define glVertexAttrib2dv glad_glVertexAttrib2dv +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); +GLAPI PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f; +#define glVertexAttrib2f glad_glVertexAttrib2f +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat *v); +GLAPI PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv; +#define glVertexAttrib2fv glad_glVertexAttrib2fv +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); +GLAPI PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s; +#define glVertexAttrib2s glad_glVertexAttrib2s +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort *v); +GLAPI PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv; +#define glVertexAttrib2sv glad_glVertexAttrib2sv +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d; +#define glVertexAttrib3d glad_glVertexAttrib3d +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble *v); +GLAPI PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv; +#define glVertexAttrib3dv glad_glVertexAttrib3dv +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f; +#define glVertexAttrib3f glad_glVertexAttrib3f +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat *v); +GLAPI PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv; +#define glVertexAttrib3fv glad_glVertexAttrib3fv +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s; +#define glVertexAttrib3s glad_glVertexAttrib3s +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort *v); +GLAPI PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv; +#define glVertexAttrib3sv glad_glVertexAttrib3sv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte *v); +GLAPI PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv; +#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v); +GLAPI PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv; +#define glVertexAttrib4Niv glad_glVertexAttrib4Niv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort *v); +GLAPI PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv; +#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub; +#define glVertexAttrib4Nub glad_glVertexAttrib4Nub +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte *v); +GLAPI PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv; +#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint *v); +GLAPI PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv; +#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort *v); +GLAPI PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv; +#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v); +GLAPI PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv; +#define glVertexAttrib4bv glad_glVertexAttrib4bv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d; +#define glVertexAttrib4d glad_glVertexAttrib4d +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble *v); +GLAPI PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv; +#define glVertexAttrib4dv glad_glVertexAttrib4dv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f; +#define glVertexAttrib4f glad_glVertexAttrib4f +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat *v); +GLAPI PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv; +#define glVertexAttrib4fv glad_glVertexAttrib4fv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v); +GLAPI PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv; +#define glVertexAttrib4iv glad_glVertexAttrib4iv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s; +#define glVertexAttrib4s glad_glVertexAttrib4s +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort *v); +GLAPI PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv; +#define glVertexAttrib4sv glad_glVertexAttrib4sv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte *v); +GLAPI PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv; +#define glVertexAttrib4ubv glad_glVertexAttrib4ubv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint *v); +GLAPI PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv; +#define glVertexAttrib4uiv glad_glVertexAttrib4uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort *v); +GLAPI PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv; +#define glVertexAttrib4usv glad_glVertexAttrib4usv +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer; +#define glVertexAttribPointer glad_glVertexAttribPointer +#endif +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +GLAPI int GLAD_GL_VERSION_2_1; +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv; +#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv; +#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv; +#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv; +#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv; +#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv; +#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv +#endif +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +GLAPI int GLAD_GL_VERSION_3_0; +typedef void (APIENTRYP PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI PFNGLCOLORMASKIPROC glad_glColorMaski; +#define glColorMaski glad_glColorMaski +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean *data); +GLAPI PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v; +#define glGetBooleani_v glad_glGetBooleani_v +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint *data); +GLAPI PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v; +#define glGetIntegeri_v glad_glGetIntegeri_v +typedef void (APIENTRYP PFNGLENABLEIPROC)(GLenum target, GLuint index); +GLAPI PFNGLENABLEIPROC glad_glEnablei; +#define glEnablei glad_glEnablei +typedef void (APIENTRYP PFNGLDISABLEIPROC)(GLenum target, GLuint index); +GLAPI PFNGLDISABLEIPROC glad_glDisablei; +#define glDisablei glad_glDisablei +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC)(GLenum target, GLuint index); +GLAPI PFNGLISENABLEDIPROC glad_glIsEnabledi; +#define glIsEnabledi glad_glIsEnabledi +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode); +GLAPI PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback; +#define glBeginTransformFeedback glad_glBeginTransformFeedback +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)(void); +GLAPI PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback; +#define glEndTransformFeedback glad_glEndTransformFeedback +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange; +#define glBindBufferRange glad_glBindBufferRange +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer); +GLAPI PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase; +#define glBindBufferBase glad_glBindBufferBase +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings; +#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying; +#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp); +GLAPI PFNGLCLAMPCOLORPROC glad_glClampColor; +#define glClampColor glad_glClampColor +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode); +GLAPI PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender; +#define glBeginConditionalRender glad_glBeginConditionalRender +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC)(void); +GLAPI PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender; +#define glEndConditionalRender glad_glEndConditionalRender +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer; +#define glVertexAttribIPointer glad_glVertexAttribIPointer +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint *params); +GLAPI PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv; +#define glGetVertexAttribIiv glad_glGetVertexAttribIiv +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint *params); +GLAPI PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv; +#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x); +GLAPI PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i; +#define glVertexAttribI1i glad_glVertexAttribI1i +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y); +GLAPI PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i; +#define glVertexAttribI2i glad_glVertexAttribI2i +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z); +GLAPI PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i; +#define glVertexAttribI3i glad_glVertexAttribI3i +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i; +#define glVertexAttribI4i glad_glVertexAttribI4i +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x); +GLAPI PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui; +#define glVertexAttribI1ui glad_glVertexAttribI1ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y); +GLAPI PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui; +#define glVertexAttribI2ui glad_glVertexAttribI2ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui; +#define glVertexAttribI3ui glad_glVertexAttribI3ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui; +#define glVertexAttribI4ui glad_glVertexAttribI4ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint *v); +GLAPI PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv; +#define glVertexAttribI1iv glad_glVertexAttribI1iv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint *v); +GLAPI PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv; +#define glVertexAttribI2iv glad_glVertexAttribI2iv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint *v); +GLAPI PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv; +#define glVertexAttribI3iv glad_glVertexAttribI3iv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint *v); +GLAPI PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv; +#define glVertexAttribI4iv glad_glVertexAttribI4iv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint *v); +GLAPI PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv; +#define glVertexAttribI1uiv glad_glVertexAttribI1uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint *v); +GLAPI PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv; +#define glVertexAttribI2uiv glad_glVertexAttribI2uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint *v); +GLAPI PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv; +#define glVertexAttribI3uiv glad_glVertexAttribI3uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint *v); +GLAPI PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv; +#define glVertexAttribI4uiv glad_glVertexAttribI4uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte *v); +GLAPI PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv; +#define glVertexAttribI4bv glad_glVertexAttribI4bv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort *v); +GLAPI PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv; +#define glVertexAttribI4sv glad_glVertexAttribI4sv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte *v); +GLAPI PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv; +#define glVertexAttribI4ubv glad_glVertexAttribI4ubv +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort *v); +GLAPI PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv; +#define glVertexAttribI4usv glad_glVertexAttribI4usv +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint *params); +GLAPI PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv; +#define glGetUniformuiv glad_glGetUniformuiv +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar *name); +GLAPI PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation; +#define glBindFragDataLocation glad_glBindFragDataLocation +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar *name); +GLAPI PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation; +#define glGetFragDataLocation glad_glGetFragDataLocation +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); +GLAPI PFNGLUNIFORM1UIPROC glad_glUniform1ui; +#define glUniform1ui glad_glUniform1ui +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1); +GLAPI PFNGLUNIFORM2UIPROC glad_glUniform2ui; +#define glUniform2ui glad_glUniform2ui +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI PFNGLUNIFORM3UIPROC glad_glUniform3ui; +#define glUniform3ui glad_glUniform3ui +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI PFNGLUNIFORM4UIPROC glad_glUniform4ui; +#define glUniform4ui glad_glUniform4ui +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint *value); +GLAPI PFNGLUNIFORM1UIVPROC glad_glUniform1uiv; +#define glUniform1uiv glad_glUniform1uiv +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint *value); +GLAPI PFNGLUNIFORM2UIVPROC glad_glUniform2uiv; +#define glUniform2uiv glad_glUniform2uiv +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint *value); +GLAPI PFNGLUNIFORM3UIVPROC glad_glUniform3uiv; +#define glUniform3uiv glad_glUniform3uiv +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint *value); +GLAPI PFNGLUNIFORM4UIVPROC glad_glUniform4uiv; +#define glUniform4uiv glad_glUniform4uiv +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint *params); +GLAPI PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv; +#define glTexParameterIiv glad_glTexParameterIiv +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint *params); +GLAPI PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv; +#define glTexParameterIuiv glad_glTexParameterIuiv +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint *params); +GLAPI PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv; +#define glGetTexParameterIiv glad_glGetTexParameterIiv +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint *params); +GLAPI PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv; +#define glGetTexParameterIuiv glad_glGetTexParameterIuiv +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv; +#define glClearBufferiv glad_glClearBufferiv +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv; +#define glClearBufferuiv glad_glClearBufferuiv +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv; +#define glClearBufferfv glad_glClearBufferfv +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi; +#define glClearBufferfi glad_glClearBufferfi +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, GLuint index); +GLAPI PFNGLGETSTRINGIPROC glad_glGetStringi; +#define glGetStringi glad_glGetStringi +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); +GLAPI PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer; +#define glIsRenderbuffer glad_glIsRenderbuffer +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); +GLAPI PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer; +#define glBindRenderbuffer glad_glBindRenderbuffer +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers); +GLAPI PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers; +#define glDeleteRenderbuffers glad_glDeleteRenderbuffers +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); +GLAPI PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers; +#define glGenRenderbuffers glad_glGenRenderbuffers +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage; +#define glRenderbufferStorage glad_glRenderbufferStorage +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +GLAPI PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv; +#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); +GLAPI PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer; +#define glIsFramebuffer glad_glIsFramebuffer +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); +GLAPI PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer; +#define glBindFramebuffer glad_glBindFramebuffer +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers); +GLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers; +#define glDeleteFramebuffers glad_glDeleteFramebuffers +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); +GLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers; +#define glGenFramebuffers glad_glGenFramebuffers +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); +GLAPI PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus; +#define glCheckFramebufferStatus glad_glCheckFramebufferStatus +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D; +#define glFramebufferTexture1D glad_glFramebufferTexture1D +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D; +#define glFramebufferTexture2D glad_glFramebufferTexture2D +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D; +#define glFramebufferTexture3D glad_glFramebufferTexture3D +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer; +#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv; +#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target); +GLAPI PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap; +#define glGenerateMipmap glad_glGenerateMipmap +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer; +#define glBlitFramebuffer glad_glBlitFramebuffer +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample; +#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer; +#define glFramebufferTextureLayer glad_glFramebufferTextureLayer +typedef void * (APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange; +#define glMapBufferRange glad_glMapBufferRange +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange; +#define glFlushMappedBufferRange glad_glFlushMappedBufferRange +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array); +GLAPI PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray; +#define glBindVertexArray glad_glBindVertexArray +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint *arrays); +GLAPI PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays; +#define glDeleteVertexArrays glad_glDeleteVertexArrays +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays); +GLAPI PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays; +#define glGenVertexArrays glad_glGenVertexArrays +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array); +GLAPI PFNGLISVERTEXARRAYPROC glad_glIsVertexArray; +#define glIsVertexArray glad_glIsVertexArray +#endif +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +GLAPI int GLAD_GL_VERSION_3_1; +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced; +#define glDrawArraysInstanced glad_glDrawArraysInstanced +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced; +#define glDrawElementsInstanced glad_glDrawElementsInstanced +typedef void (APIENTRYP PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer); +GLAPI PFNGLTEXBUFFERPROC glad_glTexBuffer; +#define glTexBuffer glad_glTexBuffer +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index); +GLAPI PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex; +#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData; +#define glCopyBufferSubData glad_glCopyBufferSubData +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices; +#define glGetUniformIndices glad_glGetUniformIndices +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv; +#define glGetActiveUniformsiv glad_glGetActiveUniformsiv +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName; +#define glGetActiveUniformName glad_glGetActiveUniformName +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar *uniformBlockName); +GLAPI PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex; +#define glGetUniformBlockIndex glad_glGetUniformBlockIndex +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv; +#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName; +#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GLAPI PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding; +#define glUniformBlockBinding glad_glUniformBlockBinding +#endif +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +GLAPI int GLAD_GL_VERSION_3_2; +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex; +#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex; +#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex; +#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex; +#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC)(GLenum mode); +GLAPI PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex; +#define glProvokingVertex glad_glProvokingVertex +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags); +GLAPI PFNGLFENCESYNCPROC glad_glFenceSync; +#define glFenceSync glad_glFenceSync +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC)(GLsync sync); +GLAPI PFNGLISSYNCPROC glad_glIsSync; +#define glIsSync glad_glIsSync +typedef void (APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync); +GLAPI PFNGLDELETESYNCPROC glad_glDeleteSync; +#define glDeleteSync glad_glDeleteSync +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync; +#define glClientWaitSync glad_glClientWaitSync +typedef void (APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI PFNGLWAITSYNCPROC glad_glWaitSync; +#define glWaitSync glad_glWaitSync +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 *data); +GLAPI PFNGLGETINTEGER64VPROC glad_glGetInteger64v; +#define glGetInteger64v glad_glGetInteger64v +typedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +GLAPI PFNGLGETSYNCIVPROC glad_glGetSynciv; +#define glGetSynciv glad_glGetSynciv +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 *data); +GLAPI PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v; +#define glGetInteger64i_v glad_glGetInteger64i_v +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 *params); +GLAPI PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v; +#define glGetBufferParameteri64v glad_glGetBufferParameteri64v +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture; +#define glFramebufferTexture glad_glFramebufferTexture +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample; +#define glTexImage2DMultisample glad_glTexImage2DMultisample +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample; +#define glTexImage3DMultisample glad_glTexImage3DMultisample +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat *val); +GLAPI PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv; +#define glGetMultisamplefv glad_glGetMultisamplefv +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask); +GLAPI PFNGLSAMPLEMASKIPROC glad_glSampleMaski; +#define glSampleMaski glad_glSampleMaski +#endif +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +GLAPI int GLAD_GL_VERSION_3_3; +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed; +#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar *name); +GLAPI PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex; +#define glGetFragDataIndex glad_glGetFragDataIndex +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint *samplers); +GLAPI PFNGLGENSAMPLERSPROC glad_glGenSamplers; +#define glGenSamplers glad_glGenSamplers +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint *samplers); +GLAPI PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers; +#define glDeleteSamplers glad_glDeleteSamplers +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler); +GLAPI PFNGLISSAMPLERPROC glad_glIsSampler; +#define glIsSampler glad_glIsSampler +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); +GLAPI PFNGLBINDSAMPLERPROC glad_glBindSampler; +#define glBindSampler glad_glBindSampler +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param); +GLAPI PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri; +#define glSamplerParameteri glad_glSamplerParameteri +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint *param); +GLAPI PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv; +#define glSamplerParameteriv glad_glSamplerParameteriv +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param); +GLAPI PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf; +#define glSamplerParameterf glad_glSamplerParameterf +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv; +#define glSamplerParameterfv glad_glSamplerParameterfv +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint *param); +GLAPI PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv; +#define glSamplerParameterIiv glad_glSamplerParameterIiv +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint *param); +GLAPI PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv; +#define glSamplerParameterIuiv glad_glSamplerParameterIuiv +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint *params); +GLAPI PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv; +#define glGetSamplerParameteriv glad_glGetSamplerParameteriv +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint *params); +GLAPI PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv; +#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat *params); +GLAPI PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv; +#define glGetSamplerParameterfv glad_glGetSamplerParameterfv +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint *params); +GLAPI PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv; +#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target); +GLAPI PFNGLQUERYCOUNTERPROC glad_glQueryCounter; +#define glQueryCounter glad_glQueryCounter +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 *params); +GLAPI PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v; +#define glGetQueryObjecti64v glad_glGetQueryObjecti64v +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 *params); +GLAPI PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v; +#define glGetQueryObjectui64v glad_glGetQueryObjectui64v +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor); +GLAPI PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor; +#define glVertexAttribDivisor glad_glVertexAttribDivisor +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui; +#define glVertexAttribP1ui glad_glVertexAttribP1ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv; +#define glVertexAttribP1uiv glad_glVertexAttribP1uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui; +#define glVertexAttribP2ui glad_glVertexAttribP2ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv; +#define glVertexAttribP2uiv glad_glVertexAttribP2uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui; +#define glVertexAttribP3ui glad_glVertexAttribP3ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv; +#define glVertexAttribP3uiv glad_glVertexAttribP3uiv +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui; +#define glVertexAttribP4ui glad_glVertexAttribP4ui +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv; +#define glVertexAttribP4uiv glad_glVertexAttribP4uiv +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value); +GLAPI PFNGLVERTEXP2UIPROC glad_glVertexP2ui; +#define glVertexP2ui glad_glVertexP2ui +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint *value); +GLAPI PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv; +#define glVertexP2uiv glad_glVertexP2uiv +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value); +GLAPI PFNGLVERTEXP3UIPROC glad_glVertexP3ui; +#define glVertexP3ui glad_glVertexP3ui +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint *value); +GLAPI PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv; +#define glVertexP3uiv glad_glVertexP3uiv +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value); +GLAPI PFNGLVERTEXP4UIPROC glad_glVertexP4ui; +#define glVertexP4ui glad_glVertexP4ui +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint *value); +GLAPI PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv; +#define glVertexP4uiv glad_glVertexP4uiv +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords); +GLAPI PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui; +#define glTexCoordP1ui glad_glTexCoordP1ui +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint *coords); +GLAPI PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv; +#define glTexCoordP1uiv glad_glTexCoordP1uiv +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords); +GLAPI PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui; +#define glTexCoordP2ui glad_glTexCoordP2ui +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint *coords); +GLAPI PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv; +#define glTexCoordP2uiv glad_glTexCoordP2uiv +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords); +GLAPI PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui; +#define glTexCoordP3ui glad_glTexCoordP3ui +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint *coords); +GLAPI PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv; +#define glTexCoordP3uiv glad_glTexCoordP3uiv +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords); +GLAPI PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui; +#define glTexCoordP4ui glad_glTexCoordP4ui +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint *coords); +GLAPI PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv; +#define glTexCoordP4uiv glad_glTexCoordP4uiv +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords); +GLAPI PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui; +#define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +GLAPI PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv; +#define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords); +GLAPI PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui; +#define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +GLAPI PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv; +#define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords); +GLAPI PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui; +#define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +GLAPI PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv; +#define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords); +GLAPI PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui; +#define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +GLAPI PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv; +#define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv +typedef void (APIENTRYP PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords); +GLAPI PFNGLNORMALP3UIPROC glad_glNormalP3ui; +#define glNormalP3ui glad_glNormalP3ui +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint *coords); +GLAPI PFNGLNORMALP3UIVPROC glad_glNormalP3uiv; +#define glNormalP3uiv glad_glNormalP3uiv +typedef void (APIENTRYP PFNGLCOLORP3UIPROC)(GLenum type, GLuint color); +GLAPI PFNGLCOLORP3UIPROC glad_glColorP3ui; +#define glColorP3ui glad_glColorP3ui +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint *color); +GLAPI PFNGLCOLORP3UIVPROC glad_glColorP3uiv; +#define glColorP3uiv glad_glColorP3uiv +typedef void (APIENTRYP PFNGLCOLORP4UIPROC)(GLenum type, GLuint color); +GLAPI PFNGLCOLORP4UIPROC glad_glColorP4ui; +#define glColorP4ui glad_glColorP4ui +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint *color); +GLAPI PFNGLCOLORP4UIVPROC glad_glColorP4uiv; +#define glColorP4uiv glad_glColorP4uiv +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color); +GLAPI PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui; +#define glSecondaryColorP3ui glad_glSecondaryColorP3ui +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint *color); +GLAPI PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv; +#define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/ext/glad/src/glad.c b/src/ext/glad/src/glad.c new file mode 100644 index 000000000..5f793ee1a --- /dev/null +++ b/src/ext/glad/src/glad.c @@ -0,0 +1,1840 @@ +/* + + OpenGL loader generated by glad 0.1.35 on Fri Mar 18 22:50:35 2022. + + Language/Generator: C/C++ + Specification: gl + APIs: gl=3.3 + Profile: compatibility + Extensions: + + Loader: True + Local files: False + Omit khrplatform: False + Reproducible: False + + Commandline: + --profile="compatibility" --api="gl=3.3" --generator="c" --spec="gl" --extensions="" + Online: + https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D3.3 +*/ + +#include +#include +#include +#include + +static void* get_proc(const char *namez); + +#if defined(_WIN32) || defined(__CYGWIN__) +#ifndef _WINDOWS_ +#undef APIENTRY +#endif +#include +static HMODULE libGL; + +typedef void* (APIENTRYP PFNWGLGETPROCADDRESSPROC_PRIVATE)(const char*); +static PFNWGLGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; + +#ifdef _MSC_VER +#ifdef __has_include + #if __has_include() + #define HAVE_WINAPIFAMILY 1 + #endif +#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_ + #define HAVE_WINAPIFAMILY 1 +#endif +#endif + +#ifdef HAVE_WINAPIFAMILY + #include + #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + #define IS_UWP 1 + #endif +#endif + +static +int open_gl(void) { +#ifndef IS_UWP + libGL = LoadLibraryW(L"opengl32.dll"); + if(libGL != NULL) { + void (* tmp)(void); + tmp = (void(*)(void)) GetProcAddress(libGL, "wglGetProcAddress"); + gladGetProcAddressPtr = (PFNWGLGETPROCADDRESSPROC_PRIVATE) tmp; + return gladGetProcAddressPtr != NULL; + } +#endif + + return 0; +} + +static +void close_gl(void) { + if(libGL != NULL) { + FreeLibrary((HMODULE) libGL); + libGL = NULL; + } +} +#else +#include +static void* libGL; + +#if !defined(__APPLE__) && !defined(__HAIKU__) +typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*); +static PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; +#endif + +static +int open_gl(void) { +#ifdef __APPLE__ + static const char *NAMES[] = { + "../Frameworks/OpenGL.framework/OpenGL", + "/Library/Frameworks/OpenGL.framework/OpenGL", + "/System/Library/Frameworks/OpenGL.framework/OpenGL", + "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL" + }; +#else + static const char *NAMES[] = {"libGL.so.1", "libGL.so"}; +#endif + + unsigned int index = 0; + for(index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) { + libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL); + + if(libGL != NULL) { +#if defined(__APPLE__) || defined(__HAIKU__) + return 1; +#else + gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE)dlsym(libGL, + "glXGetProcAddressARB"); + return gladGetProcAddressPtr != NULL; +#endif + } + } + + return 0; +} + +static +void close_gl(void) { + if(libGL != NULL) { + dlclose(libGL); + libGL = NULL; + } +} +#endif + +static +void* get_proc(const char *namez) { + void* result = NULL; + if(libGL == NULL) return NULL; + +#if !defined(__APPLE__) && !defined(__HAIKU__) + if(gladGetProcAddressPtr != NULL) { + result = gladGetProcAddressPtr(namez); + } +#endif + if(result == NULL) { +#if defined(_WIN32) || defined(__CYGWIN__) + result = (void*)GetProcAddress((HMODULE) libGL, namez); +#else + result = dlsym(libGL, namez); +#endif + } + + return result; +} + +int gladLoadGL(void) { + int status = 0; + + if(open_gl()) { + status = gladLoadGLLoader(&get_proc); + close_gl(); + } + + return status; +} + +struct gladGLversionStruct GLVersion = { 0, 0 }; + +#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) +#define _GLAD_IS_SOME_NEW_VERSION 1 +#endif + +static int max_loaded_major; +static int max_loaded_minor; + +static const char *exts = NULL; +static int num_exts_i = 0; +static char **exts_i = NULL; + +static int get_exts(void) { +#ifdef _GLAD_IS_SOME_NEW_VERSION + if(max_loaded_major < 3) { +#endif + exts = (const char *)glGetString(GL_EXTENSIONS); +#ifdef _GLAD_IS_SOME_NEW_VERSION + } else { + unsigned int index; + + num_exts_i = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i); + if (num_exts_i > 0) { + exts_i = (char **)malloc((size_t)num_exts_i * (sizeof *exts_i)); + } + + if (exts_i == NULL) { + return 0; + } + + for(index = 0; index < (unsigned)num_exts_i; index++) { + const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index); + size_t len = strlen(gl_str_tmp); + + char *local_str = (char*)malloc((len+1) * sizeof(char)); + if(local_str != NULL) { + memcpy(local_str, gl_str_tmp, (len+1) * sizeof(char)); + } + exts_i[index] = local_str; + } + } +#endif + return 1; +} + +static void free_exts(void) { + if (exts_i != NULL) { + int index; + for(index = 0; index < num_exts_i; index++) { + free((char *)exts_i[index]); + } + free((void *)exts_i); + exts_i = NULL; + } +} + +static int has_ext(const char *ext) { +#ifdef _GLAD_IS_SOME_NEW_VERSION + if(max_loaded_major < 3) { +#endif + const char *extensions; + const char *loc; + const char *terminator; + extensions = exts; + if(extensions == NULL || ext == NULL) { + return 0; + } + + while(1) { + loc = strstr(extensions, ext); + if(loc == NULL) { + return 0; + } + + terminator = loc + strlen(ext); + if((loc == extensions || *(loc - 1) == ' ') && + (*terminator == ' ' || *terminator == '\0')) { + return 1; + } + extensions = terminator; + } +#ifdef _GLAD_IS_SOME_NEW_VERSION + } else { + int index; + if(exts_i == NULL) return 0; + for(index = 0; index < num_exts_i; index++) { + const char *e = exts_i[index]; + + if(exts_i[index] != NULL && strcmp(e, ext) == 0) { + return 1; + } + } + } +#endif + + return 0; +} +int GLAD_GL_VERSION_1_0 = 0; +int GLAD_GL_VERSION_1_1 = 0; +int GLAD_GL_VERSION_1_2 = 0; +int GLAD_GL_VERSION_1_3 = 0; +int GLAD_GL_VERSION_1_4 = 0; +int GLAD_GL_VERSION_1_5 = 0; +int GLAD_GL_VERSION_2_0 = 0; +int GLAD_GL_VERSION_2_1 = 0; +int GLAD_GL_VERSION_3_0 = 0; +int GLAD_GL_VERSION_3_1 = 0; +int GLAD_GL_VERSION_3_2 = 0; +int GLAD_GL_VERSION_3_3 = 0; +PFNGLACCUMPROC glad_glAccum = NULL; +PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL; +PFNGLALPHAFUNCPROC glad_glAlphaFunc = NULL; +PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident = NULL; +PFNGLARRAYELEMENTPROC glad_glArrayElement = NULL; +PFNGLATTACHSHADERPROC glad_glAttachShader = NULL; +PFNGLBEGINPROC glad_glBegin = NULL; +PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL; +PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL; +PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL; +PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL; +PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL; +PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL; +PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL; +PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL; +PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL; +PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL; +PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL; +PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL; +PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL; +PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL; +PFNGLBITMAPPROC glad_glBitmap = NULL; +PFNGLBLENDCOLORPROC glad_glBlendColor = NULL; +PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL; +PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL; +PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL; +PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL; +PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL; +PFNGLBUFFERDATAPROC glad_glBufferData = NULL; +PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL; +PFNGLCALLLISTPROC glad_glCallList = NULL; +PFNGLCALLLISTSPROC glad_glCallLists = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL; +PFNGLCLAMPCOLORPROC glad_glClampColor = NULL; +PFNGLCLEARPROC glad_glClear = NULL; +PFNGLCLEARACCUMPROC glad_glClearAccum = NULL; +PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL; +PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL; +PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL; +PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL; +PFNGLCLEARCOLORPROC glad_glClearColor = NULL; +PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL; +PFNGLCLEARINDEXPROC glad_glClearIndex = NULL; +PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL; +PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture = NULL; +PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL; +PFNGLCLIPPLANEPROC glad_glClipPlane = NULL; +PFNGLCOLOR3BPROC glad_glColor3b = NULL; +PFNGLCOLOR3BVPROC glad_glColor3bv = NULL; +PFNGLCOLOR3DPROC glad_glColor3d = NULL; +PFNGLCOLOR3DVPROC glad_glColor3dv = NULL; +PFNGLCOLOR3FPROC glad_glColor3f = NULL; +PFNGLCOLOR3FVPROC glad_glColor3fv = NULL; +PFNGLCOLOR3IPROC glad_glColor3i = NULL; +PFNGLCOLOR3IVPROC glad_glColor3iv = NULL; +PFNGLCOLOR3SPROC glad_glColor3s = NULL; +PFNGLCOLOR3SVPROC glad_glColor3sv = NULL; +PFNGLCOLOR3UBPROC glad_glColor3ub = NULL; +PFNGLCOLOR3UBVPROC glad_glColor3ubv = NULL; +PFNGLCOLOR3UIPROC glad_glColor3ui = NULL; +PFNGLCOLOR3UIVPROC glad_glColor3uiv = NULL; +PFNGLCOLOR3USPROC glad_glColor3us = NULL; +PFNGLCOLOR3USVPROC glad_glColor3usv = NULL; +PFNGLCOLOR4BPROC glad_glColor4b = NULL; +PFNGLCOLOR4BVPROC glad_glColor4bv = NULL; +PFNGLCOLOR4DPROC glad_glColor4d = NULL; +PFNGLCOLOR4DVPROC glad_glColor4dv = NULL; +PFNGLCOLOR4FPROC glad_glColor4f = NULL; +PFNGLCOLOR4FVPROC glad_glColor4fv = NULL; +PFNGLCOLOR4IPROC glad_glColor4i = NULL; +PFNGLCOLOR4IVPROC glad_glColor4iv = NULL; +PFNGLCOLOR4SPROC glad_glColor4s = NULL; +PFNGLCOLOR4SVPROC glad_glColor4sv = NULL; +PFNGLCOLOR4UBPROC glad_glColor4ub = NULL; +PFNGLCOLOR4UBVPROC glad_glColor4ubv = NULL; +PFNGLCOLOR4UIPROC glad_glColor4ui = NULL; +PFNGLCOLOR4UIVPROC glad_glColor4uiv = NULL; +PFNGLCOLOR4USPROC glad_glColor4us = NULL; +PFNGLCOLOR4USVPROC glad_glColor4usv = NULL; +PFNGLCOLORMASKPROC glad_glColorMask = NULL; +PFNGLCOLORMASKIPROC glad_glColorMaski = NULL; +PFNGLCOLORMATERIALPROC glad_glColorMaterial = NULL; +PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL; +PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL; +PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL; +PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL; +PFNGLCOLORPOINTERPROC glad_glColorPointer = NULL; +PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL; +PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL; +PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL; +PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL; +PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL; +PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL; +PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL; +PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL; +PFNGLCOPYPIXELSPROC glad_glCopyPixels = NULL; +PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL; +PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL; +PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL; +PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL; +PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL; +PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL; +PFNGLCREATESHADERPROC glad_glCreateShader = NULL; +PFNGLCULLFACEPROC glad_glCullFace = NULL; +PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL; +PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL; +PFNGLDELETELISTSPROC glad_glDeleteLists = NULL; +PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL; +PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL; +PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL; +PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL; +PFNGLDELETESHADERPROC glad_glDeleteShader = NULL; +PFNGLDELETESYNCPROC glad_glDeleteSync = NULL; +PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL; +PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL; +PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL; +PFNGLDEPTHMASKPROC glad_glDepthMask = NULL; +PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL; +PFNGLDETACHSHADERPROC glad_glDetachShader = NULL; +PFNGLDISABLEPROC glad_glDisable = NULL; +PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState = NULL; +PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL; +PFNGLDISABLEIPROC glad_glDisablei = NULL; +PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL; +PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL; +PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL; +PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL; +PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL; +PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL; +PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL; +PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL; +PFNGLDRAWPIXELSPROC glad_glDrawPixels = NULL; +PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL; +PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL; +PFNGLEDGEFLAGPROC glad_glEdgeFlag = NULL; +PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer = NULL; +PFNGLEDGEFLAGVPROC glad_glEdgeFlagv = NULL; +PFNGLENABLEPROC glad_glEnable = NULL; +PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState = NULL; +PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL; +PFNGLENABLEIPROC glad_glEnablei = NULL; +PFNGLENDPROC glad_glEnd = NULL; +PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL; +PFNGLENDLISTPROC glad_glEndList = NULL; +PFNGLENDQUERYPROC glad_glEndQuery = NULL; +PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL; +PFNGLEVALCOORD1DPROC glad_glEvalCoord1d = NULL; +PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv = NULL; +PFNGLEVALCOORD1FPROC glad_glEvalCoord1f = NULL; +PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv = NULL; +PFNGLEVALCOORD2DPROC glad_glEvalCoord2d = NULL; +PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv = NULL; +PFNGLEVALCOORD2FPROC glad_glEvalCoord2f = NULL; +PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv = NULL; +PFNGLEVALMESH1PROC glad_glEvalMesh1 = NULL; +PFNGLEVALMESH2PROC glad_glEvalMesh2 = NULL; +PFNGLEVALPOINT1PROC glad_glEvalPoint1 = NULL; +PFNGLEVALPOINT2PROC glad_glEvalPoint2 = NULL; +PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer = NULL; +PFNGLFENCESYNCPROC glad_glFenceSync = NULL; +PFNGLFINISHPROC glad_glFinish = NULL; +PFNGLFLUSHPROC glad_glFlush = NULL; +PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL; +PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer = NULL; +PFNGLFOGCOORDDPROC glad_glFogCoordd = NULL; +PFNGLFOGCOORDDVPROC glad_glFogCoorddv = NULL; +PFNGLFOGCOORDFPROC glad_glFogCoordf = NULL; +PFNGLFOGCOORDFVPROC glad_glFogCoordfv = NULL; +PFNGLFOGFPROC glad_glFogf = NULL; +PFNGLFOGFVPROC glad_glFogfv = NULL; +PFNGLFOGIPROC glad_glFogi = NULL; +PFNGLFOGIVPROC glad_glFogiv = NULL; +PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL; +PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL; +PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL; +PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL; +PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL; +PFNGLFRONTFACEPROC glad_glFrontFace = NULL; +PFNGLFRUSTUMPROC glad_glFrustum = NULL; +PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL; +PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL; +PFNGLGENLISTSPROC glad_glGenLists = NULL; +PFNGLGENQUERIESPROC glad_glGenQueries = NULL; +PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL; +PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL; +PFNGLGENTEXTURESPROC glad_glGenTextures = NULL; +PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL; +PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL; +PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL; +PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL; +PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL; +PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL; +PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL; +PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL; +PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL; +PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL; +PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL; +PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL; +PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL; +PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL; +PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL; +PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL; +PFNGLGETCLIPPLANEPROC glad_glGetClipPlane = NULL; +PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL; +PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL; +PFNGLGETERRORPROC glad_glGetError = NULL; +PFNGLGETFLOATVPROC glad_glGetFloatv = NULL; +PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL; +PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL; +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL; +PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL; +PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL; +PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL; +PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL; +PFNGLGETLIGHTFVPROC glad_glGetLightfv = NULL; +PFNGLGETLIGHTIVPROC glad_glGetLightiv = NULL; +PFNGLGETMAPDVPROC glad_glGetMapdv = NULL; +PFNGLGETMAPFVPROC glad_glGetMapfv = NULL; +PFNGLGETMAPIVPROC glad_glGetMapiv = NULL; +PFNGLGETMATERIALFVPROC glad_glGetMaterialfv = NULL; +PFNGLGETMATERIALIVPROC glad_glGetMaterialiv = NULL; +PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL; +PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv = NULL; +PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv = NULL; +PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv = NULL; +PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL; +PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple = NULL; +PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL; +PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL; +PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL; +PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL; +PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL; +PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL; +PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL; +PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL; +PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL; +PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL; +PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL; +PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL; +PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL; +PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL; +PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL; +PFNGLGETSTRINGPROC glad_glGetString = NULL; +PFNGLGETSTRINGIPROC glad_glGetStringi = NULL; +PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL; +PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv = NULL; +PFNGLGETTEXENVIVPROC glad_glGetTexEnviv = NULL; +PFNGLGETTEXGENDVPROC glad_glGetTexGendv = NULL; +PFNGLGETTEXGENFVPROC glad_glGetTexGenfv = NULL; +PFNGLGETTEXGENIVPROC glad_glGetTexGeniv = NULL; +PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL; +PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL; +PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL; +PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL; +PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL; +PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL; +PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL; +PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL; +PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL; +PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL; +PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL; +PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL; +PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL; +PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL; +PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL; +PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL; +PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL; +PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL; +PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL; +PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL; +PFNGLHINTPROC glad_glHint = NULL; +PFNGLINDEXMASKPROC glad_glIndexMask = NULL; +PFNGLINDEXPOINTERPROC glad_glIndexPointer = NULL; +PFNGLINDEXDPROC glad_glIndexd = NULL; +PFNGLINDEXDVPROC glad_glIndexdv = NULL; +PFNGLINDEXFPROC glad_glIndexf = NULL; +PFNGLINDEXFVPROC glad_glIndexfv = NULL; +PFNGLINDEXIPROC glad_glIndexi = NULL; +PFNGLINDEXIVPROC glad_glIndexiv = NULL; +PFNGLINDEXSPROC glad_glIndexs = NULL; +PFNGLINDEXSVPROC glad_glIndexsv = NULL; +PFNGLINDEXUBPROC glad_glIndexub = NULL; +PFNGLINDEXUBVPROC glad_glIndexubv = NULL; +PFNGLINITNAMESPROC glad_glInitNames = NULL; +PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays = NULL; +PFNGLISBUFFERPROC glad_glIsBuffer = NULL; +PFNGLISENABLEDPROC glad_glIsEnabled = NULL; +PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL; +PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL; +PFNGLISLISTPROC glad_glIsList = NULL; +PFNGLISPROGRAMPROC glad_glIsProgram = NULL; +PFNGLISQUERYPROC glad_glIsQuery = NULL; +PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL; +PFNGLISSAMPLERPROC glad_glIsSampler = NULL; +PFNGLISSHADERPROC glad_glIsShader = NULL; +PFNGLISSYNCPROC glad_glIsSync = NULL; +PFNGLISTEXTUREPROC glad_glIsTexture = NULL; +PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL; +PFNGLLIGHTMODELFPROC glad_glLightModelf = NULL; +PFNGLLIGHTMODELFVPROC glad_glLightModelfv = NULL; +PFNGLLIGHTMODELIPROC glad_glLightModeli = NULL; +PFNGLLIGHTMODELIVPROC glad_glLightModeliv = NULL; +PFNGLLIGHTFPROC glad_glLightf = NULL; +PFNGLLIGHTFVPROC glad_glLightfv = NULL; +PFNGLLIGHTIPROC glad_glLighti = NULL; +PFNGLLIGHTIVPROC glad_glLightiv = NULL; +PFNGLLINESTIPPLEPROC glad_glLineStipple = NULL; +PFNGLLINEWIDTHPROC glad_glLineWidth = NULL; +PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL; +PFNGLLISTBASEPROC glad_glListBase = NULL; +PFNGLLOADIDENTITYPROC glad_glLoadIdentity = NULL; +PFNGLLOADMATRIXDPROC glad_glLoadMatrixd = NULL; +PFNGLLOADMATRIXFPROC glad_glLoadMatrixf = NULL; +PFNGLLOADNAMEPROC glad_glLoadName = NULL; +PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd = NULL; +PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf = NULL; +PFNGLLOGICOPPROC glad_glLogicOp = NULL; +PFNGLMAP1DPROC glad_glMap1d = NULL; +PFNGLMAP1FPROC glad_glMap1f = NULL; +PFNGLMAP2DPROC glad_glMap2d = NULL; +PFNGLMAP2FPROC glad_glMap2f = NULL; +PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL; +PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL; +PFNGLMAPGRID1DPROC glad_glMapGrid1d = NULL; +PFNGLMAPGRID1FPROC glad_glMapGrid1f = NULL; +PFNGLMAPGRID2DPROC glad_glMapGrid2d = NULL; +PFNGLMAPGRID2FPROC glad_glMapGrid2f = NULL; +PFNGLMATERIALFPROC glad_glMaterialf = NULL; +PFNGLMATERIALFVPROC glad_glMaterialfv = NULL; +PFNGLMATERIALIPROC glad_glMateriali = NULL; +PFNGLMATERIALIVPROC glad_glMaterialiv = NULL; +PFNGLMATRIXMODEPROC glad_glMatrixMode = NULL; +PFNGLMULTMATRIXDPROC glad_glMultMatrixd = NULL; +PFNGLMULTMATRIXFPROC glad_glMultMatrixf = NULL; +PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd = NULL; +PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf = NULL; +PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL; +PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL; +PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL; +PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d = NULL; +PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv = NULL; +PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f = NULL; +PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv = NULL; +PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i = NULL; +PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv = NULL; +PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s = NULL; +PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv = NULL; +PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d = NULL; +PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv = NULL; +PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f = NULL; +PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv = NULL; +PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i = NULL; +PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv = NULL; +PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s = NULL; +PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv = NULL; +PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d = NULL; +PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv = NULL; +PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f = NULL; +PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv = NULL; +PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i = NULL; +PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv = NULL; +PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s = NULL; +PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv = NULL; +PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d = NULL; +PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv = NULL; +PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f = NULL; +PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv = NULL; +PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i = NULL; +PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv = NULL; +PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s = NULL; +PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv = NULL; +PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL; +PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL; +PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL; +PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL; +PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL; +PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL; +PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL; +PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL; +PFNGLNEWLISTPROC glad_glNewList = NULL; +PFNGLNORMAL3BPROC glad_glNormal3b = NULL; +PFNGLNORMAL3BVPROC glad_glNormal3bv = NULL; +PFNGLNORMAL3DPROC glad_glNormal3d = NULL; +PFNGLNORMAL3DVPROC glad_glNormal3dv = NULL; +PFNGLNORMAL3FPROC glad_glNormal3f = NULL; +PFNGLNORMAL3FVPROC glad_glNormal3fv = NULL; +PFNGLNORMAL3IPROC glad_glNormal3i = NULL; +PFNGLNORMAL3IVPROC glad_glNormal3iv = NULL; +PFNGLNORMAL3SPROC glad_glNormal3s = NULL; +PFNGLNORMAL3SVPROC glad_glNormal3sv = NULL; +PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL; +PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL; +PFNGLNORMALPOINTERPROC glad_glNormalPointer = NULL; +PFNGLORTHOPROC glad_glOrtho = NULL; +PFNGLPASSTHROUGHPROC glad_glPassThrough = NULL; +PFNGLPIXELMAPFVPROC glad_glPixelMapfv = NULL; +PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv = NULL; +PFNGLPIXELMAPUSVPROC glad_glPixelMapusv = NULL; +PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL; +PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL; +PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf = NULL; +PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi = NULL; +PFNGLPIXELZOOMPROC glad_glPixelZoom = NULL; +PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL; +PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL; +PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL; +PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL; +PFNGLPOINTSIZEPROC glad_glPointSize = NULL; +PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL; +PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL; +PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple = NULL; +PFNGLPOPATTRIBPROC glad_glPopAttrib = NULL; +PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib = NULL; +PFNGLPOPMATRIXPROC glad_glPopMatrix = NULL; +PFNGLPOPNAMEPROC glad_glPopName = NULL; +PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL; +PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures = NULL; +PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL; +PFNGLPUSHATTRIBPROC glad_glPushAttrib = NULL; +PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib = NULL; +PFNGLPUSHMATRIXPROC glad_glPushMatrix = NULL; +PFNGLPUSHNAMEPROC glad_glPushName = NULL; +PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL; +PFNGLRASTERPOS2DPROC glad_glRasterPos2d = NULL; +PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv = NULL; +PFNGLRASTERPOS2FPROC glad_glRasterPos2f = NULL; +PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv = NULL; +PFNGLRASTERPOS2IPROC glad_glRasterPos2i = NULL; +PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv = NULL; +PFNGLRASTERPOS2SPROC glad_glRasterPos2s = NULL; +PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv = NULL; +PFNGLRASTERPOS3DPROC glad_glRasterPos3d = NULL; +PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv = NULL; +PFNGLRASTERPOS3FPROC glad_glRasterPos3f = NULL; +PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv = NULL; +PFNGLRASTERPOS3IPROC glad_glRasterPos3i = NULL; +PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv = NULL; +PFNGLRASTERPOS3SPROC glad_glRasterPos3s = NULL; +PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv = NULL; +PFNGLRASTERPOS4DPROC glad_glRasterPos4d = NULL; +PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv = NULL; +PFNGLRASTERPOS4FPROC glad_glRasterPos4f = NULL; +PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv = NULL; +PFNGLRASTERPOS4IPROC glad_glRasterPos4i = NULL; +PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv = NULL; +PFNGLRASTERPOS4SPROC glad_glRasterPos4s = NULL; +PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv = NULL; +PFNGLREADBUFFERPROC glad_glReadBuffer = NULL; +PFNGLREADPIXELSPROC glad_glReadPixels = NULL; +PFNGLRECTDPROC glad_glRectd = NULL; +PFNGLRECTDVPROC glad_glRectdv = NULL; +PFNGLRECTFPROC glad_glRectf = NULL; +PFNGLRECTFVPROC glad_glRectfv = NULL; +PFNGLRECTIPROC glad_glRecti = NULL; +PFNGLRECTIVPROC glad_glRectiv = NULL; +PFNGLRECTSPROC glad_glRects = NULL; +PFNGLRECTSVPROC glad_glRectsv = NULL; +PFNGLRENDERMODEPROC glad_glRenderMode = NULL; +PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL; +PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL; +PFNGLROTATEDPROC glad_glRotated = NULL; +PFNGLROTATEFPROC glad_glRotatef = NULL; +PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL; +PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL; +PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL; +PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL; +PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL; +PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL; +PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL; +PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL; +PFNGLSCALEDPROC glad_glScaled = NULL; +PFNGLSCALEFPROC glad_glScalef = NULL; +PFNGLSCISSORPROC glad_glScissor = NULL; +PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b = NULL; +PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv = NULL; +PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d = NULL; +PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv = NULL; +PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f = NULL; +PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv = NULL; +PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i = NULL; +PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv = NULL; +PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s = NULL; +PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv = NULL; +PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub = NULL; +PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv = NULL; +PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui = NULL; +PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv = NULL; +PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us = NULL; +PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv = NULL; +PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL; +PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL; +PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer = NULL; +PFNGLSELECTBUFFERPROC glad_glSelectBuffer = NULL; +PFNGLSHADEMODELPROC glad_glShadeModel = NULL; +PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL; +PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL; +PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL; +PFNGLSTENCILMASKPROC glad_glStencilMask = NULL; +PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL; +PFNGLSTENCILOPPROC glad_glStencilOp = NULL; +PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL; +PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL; +PFNGLTEXCOORD1DPROC glad_glTexCoord1d = NULL; +PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv = NULL; +PFNGLTEXCOORD1FPROC glad_glTexCoord1f = NULL; +PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv = NULL; +PFNGLTEXCOORD1IPROC glad_glTexCoord1i = NULL; +PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv = NULL; +PFNGLTEXCOORD1SPROC glad_glTexCoord1s = NULL; +PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv = NULL; +PFNGLTEXCOORD2DPROC glad_glTexCoord2d = NULL; +PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv = NULL; +PFNGLTEXCOORD2FPROC glad_glTexCoord2f = NULL; +PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv = NULL; +PFNGLTEXCOORD2IPROC glad_glTexCoord2i = NULL; +PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv = NULL; +PFNGLTEXCOORD2SPROC glad_glTexCoord2s = NULL; +PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv = NULL; +PFNGLTEXCOORD3DPROC glad_glTexCoord3d = NULL; +PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv = NULL; +PFNGLTEXCOORD3FPROC glad_glTexCoord3f = NULL; +PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv = NULL; +PFNGLTEXCOORD3IPROC glad_glTexCoord3i = NULL; +PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv = NULL; +PFNGLTEXCOORD3SPROC glad_glTexCoord3s = NULL; +PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv = NULL; +PFNGLTEXCOORD4DPROC glad_glTexCoord4d = NULL; +PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv = NULL; +PFNGLTEXCOORD4FPROC glad_glTexCoord4f = NULL; +PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv = NULL; +PFNGLTEXCOORD4IPROC glad_glTexCoord4i = NULL; +PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv = NULL; +PFNGLTEXCOORD4SPROC glad_glTexCoord4s = NULL; +PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv = NULL; +PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL; +PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL; +PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL; +PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL; +PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL; +PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL; +PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL; +PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL; +PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer = NULL; +PFNGLTEXENVFPROC glad_glTexEnvf = NULL; +PFNGLTEXENVFVPROC glad_glTexEnvfv = NULL; +PFNGLTEXENVIPROC glad_glTexEnvi = NULL; +PFNGLTEXENVIVPROC glad_glTexEnviv = NULL; +PFNGLTEXGENDPROC glad_glTexGend = NULL; +PFNGLTEXGENDVPROC glad_glTexGendv = NULL; +PFNGLTEXGENFPROC glad_glTexGenf = NULL; +PFNGLTEXGENFVPROC glad_glTexGenfv = NULL; +PFNGLTEXGENIPROC glad_glTexGeni = NULL; +PFNGLTEXGENIVPROC glad_glTexGeniv = NULL; +PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL; +PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL; +PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL; +PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL; +PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL; +PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL; +PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL; +PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL; +PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL; +PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL; +PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL; +PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL; +PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL; +PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL; +PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL; +PFNGLTRANSLATEDPROC glad_glTranslated = NULL; +PFNGLTRANSLATEFPROC glad_glTranslatef = NULL; +PFNGLUNIFORM1FPROC glad_glUniform1f = NULL; +PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL; +PFNGLUNIFORM1IPROC glad_glUniform1i = NULL; +PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL; +PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL; +PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL; +PFNGLUNIFORM2FPROC glad_glUniform2f = NULL; +PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL; +PFNGLUNIFORM2IPROC glad_glUniform2i = NULL; +PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL; +PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL; +PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL; +PFNGLUNIFORM3FPROC glad_glUniform3f = NULL; +PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL; +PFNGLUNIFORM3IPROC glad_glUniform3i = NULL; +PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL; +PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL; +PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL; +PFNGLUNIFORM4FPROC glad_glUniform4f = NULL; +PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL; +PFNGLUNIFORM4IPROC glad_glUniform4i = NULL; +PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL; +PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL; +PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL; +PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL; +PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL; +PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL; +PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL; +PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL; +PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL; +PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL; +PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL; +PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL; +PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL; +PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL; +PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL; +PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL; +PFNGLVERTEX2DPROC glad_glVertex2d = NULL; +PFNGLVERTEX2DVPROC glad_glVertex2dv = NULL; +PFNGLVERTEX2FPROC glad_glVertex2f = NULL; +PFNGLVERTEX2FVPROC glad_glVertex2fv = NULL; +PFNGLVERTEX2IPROC glad_glVertex2i = NULL; +PFNGLVERTEX2IVPROC glad_glVertex2iv = NULL; +PFNGLVERTEX2SPROC glad_glVertex2s = NULL; +PFNGLVERTEX2SVPROC glad_glVertex2sv = NULL; +PFNGLVERTEX3DPROC glad_glVertex3d = NULL; +PFNGLVERTEX3DVPROC glad_glVertex3dv = NULL; +PFNGLVERTEX3FPROC glad_glVertex3f = NULL; +PFNGLVERTEX3FVPROC glad_glVertex3fv = NULL; +PFNGLVERTEX3IPROC glad_glVertex3i = NULL; +PFNGLVERTEX3IVPROC glad_glVertex3iv = NULL; +PFNGLVERTEX3SPROC glad_glVertex3s = NULL; +PFNGLVERTEX3SVPROC glad_glVertex3sv = NULL; +PFNGLVERTEX4DPROC glad_glVertex4d = NULL; +PFNGLVERTEX4DVPROC glad_glVertex4dv = NULL; +PFNGLVERTEX4FPROC glad_glVertex4f = NULL; +PFNGLVERTEX4FVPROC glad_glVertex4fv = NULL; +PFNGLVERTEX4IPROC glad_glVertex4i = NULL; +PFNGLVERTEX4IVPROC glad_glVertex4iv = NULL; +PFNGLVERTEX4SPROC glad_glVertex4s = NULL; +PFNGLVERTEX4SVPROC glad_glVertex4sv = NULL; +PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL; +PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL; +PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL; +PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL; +PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL; +PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL; +PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL; +PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL; +PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL; +PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL; +PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL; +PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL; +PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL; +PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL; +PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL; +PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL; +PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL; +PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL; +PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL; +PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL; +PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL; +PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL; +PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL; +PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL; +PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL; +PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL; +PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL; +PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL; +PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL; +PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL; +PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL; +PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL; +PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL; +PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL; +PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL; +PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL; +PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL; +PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL; +PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL; +PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL; +PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL; +PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL; +PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL; +PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL; +PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL; +PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL; +PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL; +PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL; +PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL; +PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL; +PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL; +PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL; +PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL; +PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL; +PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL; +PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL; +PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL; +PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL; +PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL; +PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL; +PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL; +PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL; +PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL; +PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL; +PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL; +PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL; +PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL; +PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL; +PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL; +PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL; +PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL; +PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL; +PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL; +PFNGLVERTEXPOINTERPROC glad_glVertexPointer = NULL; +PFNGLVIEWPORTPROC glad_glViewport = NULL; +PFNGLWAITSYNCPROC glad_glWaitSync = NULL; +PFNGLWINDOWPOS2DPROC glad_glWindowPos2d = NULL; +PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv = NULL; +PFNGLWINDOWPOS2FPROC glad_glWindowPos2f = NULL; +PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv = NULL; +PFNGLWINDOWPOS2IPROC glad_glWindowPos2i = NULL; +PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv = NULL; +PFNGLWINDOWPOS2SPROC glad_glWindowPos2s = NULL; +PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv = NULL; +PFNGLWINDOWPOS3DPROC glad_glWindowPos3d = NULL; +PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv = NULL; +PFNGLWINDOWPOS3FPROC glad_glWindowPos3f = NULL; +PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv = NULL; +PFNGLWINDOWPOS3IPROC glad_glWindowPos3i = NULL; +PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL; +PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL; +PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL; +static void load_GL_VERSION_1_0(GLADloadproc load) { + if(!GLAD_GL_VERSION_1_0) return; + glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace"); + glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace"); + glad_glHint = (PFNGLHINTPROC)load("glHint"); + glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth"); + glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize"); + glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode"); + glad_glScissor = (PFNGLSCISSORPROC)load("glScissor"); + glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf"); + glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv"); + glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri"); + glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv"); + glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D"); + glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D"); + glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer"); + glad_glClear = (PFNGLCLEARPROC)load("glClear"); + glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor"); + glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil"); + glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth"); + glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask"); + glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask"); + glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask"); + glad_glDisable = (PFNGLDISABLEPROC)load("glDisable"); + glad_glEnable = (PFNGLENABLEPROC)load("glEnable"); + glad_glFinish = (PFNGLFINISHPROC)load("glFinish"); + glad_glFlush = (PFNGLFLUSHPROC)load("glFlush"); + glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc"); + glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp"); + glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc"); + glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp"); + glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc"); + glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref"); + glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei"); + glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer"); + glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels"); + glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv"); + glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev"); + glad_glGetError = (PFNGLGETERRORPROC)load("glGetError"); + glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv"); + glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv"); + glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); + glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage"); + glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv"); + glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv"); + glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv"); + glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv"); + glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled"); + glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange"); + glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport"); + glad_glNewList = (PFNGLNEWLISTPROC)load("glNewList"); + glad_glEndList = (PFNGLENDLISTPROC)load("glEndList"); + glad_glCallList = (PFNGLCALLLISTPROC)load("glCallList"); + glad_glCallLists = (PFNGLCALLLISTSPROC)load("glCallLists"); + glad_glDeleteLists = (PFNGLDELETELISTSPROC)load("glDeleteLists"); + glad_glGenLists = (PFNGLGENLISTSPROC)load("glGenLists"); + glad_glListBase = (PFNGLLISTBASEPROC)load("glListBase"); + glad_glBegin = (PFNGLBEGINPROC)load("glBegin"); + glad_glBitmap = (PFNGLBITMAPPROC)load("glBitmap"); + glad_glColor3b = (PFNGLCOLOR3BPROC)load("glColor3b"); + glad_glColor3bv = (PFNGLCOLOR3BVPROC)load("glColor3bv"); + glad_glColor3d = (PFNGLCOLOR3DPROC)load("glColor3d"); + glad_glColor3dv = (PFNGLCOLOR3DVPROC)load("glColor3dv"); + glad_glColor3f = (PFNGLCOLOR3FPROC)load("glColor3f"); + glad_glColor3fv = (PFNGLCOLOR3FVPROC)load("glColor3fv"); + glad_glColor3i = (PFNGLCOLOR3IPROC)load("glColor3i"); + glad_glColor3iv = (PFNGLCOLOR3IVPROC)load("glColor3iv"); + glad_glColor3s = (PFNGLCOLOR3SPROC)load("glColor3s"); + glad_glColor3sv = (PFNGLCOLOR3SVPROC)load("glColor3sv"); + glad_glColor3ub = (PFNGLCOLOR3UBPROC)load("glColor3ub"); + glad_glColor3ubv = (PFNGLCOLOR3UBVPROC)load("glColor3ubv"); + glad_glColor3ui = (PFNGLCOLOR3UIPROC)load("glColor3ui"); + glad_glColor3uiv = (PFNGLCOLOR3UIVPROC)load("glColor3uiv"); + glad_glColor3us = (PFNGLCOLOR3USPROC)load("glColor3us"); + glad_glColor3usv = (PFNGLCOLOR3USVPROC)load("glColor3usv"); + glad_glColor4b = (PFNGLCOLOR4BPROC)load("glColor4b"); + glad_glColor4bv = (PFNGLCOLOR4BVPROC)load("glColor4bv"); + glad_glColor4d = (PFNGLCOLOR4DPROC)load("glColor4d"); + glad_glColor4dv = (PFNGLCOLOR4DVPROC)load("glColor4dv"); + glad_glColor4f = (PFNGLCOLOR4FPROC)load("glColor4f"); + glad_glColor4fv = (PFNGLCOLOR4FVPROC)load("glColor4fv"); + glad_glColor4i = (PFNGLCOLOR4IPROC)load("glColor4i"); + glad_glColor4iv = (PFNGLCOLOR4IVPROC)load("glColor4iv"); + glad_glColor4s = (PFNGLCOLOR4SPROC)load("glColor4s"); + glad_glColor4sv = (PFNGLCOLOR4SVPROC)load("glColor4sv"); + glad_glColor4ub = (PFNGLCOLOR4UBPROC)load("glColor4ub"); + glad_glColor4ubv = (PFNGLCOLOR4UBVPROC)load("glColor4ubv"); + glad_glColor4ui = (PFNGLCOLOR4UIPROC)load("glColor4ui"); + glad_glColor4uiv = (PFNGLCOLOR4UIVPROC)load("glColor4uiv"); + glad_glColor4us = (PFNGLCOLOR4USPROC)load("glColor4us"); + glad_glColor4usv = (PFNGLCOLOR4USVPROC)load("glColor4usv"); + glad_glEdgeFlag = (PFNGLEDGEFLAGPROC)load("glEdgeFlag"); + glad_glEdgeFlagv = (PFNGLEDGEFLAGVPROC)load("glEdgeFlagv"); + glad_glEnd = (PFNGLENDPROC)load("glEnd"); + glad_glIndexd = (PFNGLINDEXDPROC)load("glIndexd"); + glad_glIndexdv = (PFNGLINDEXDVPROC)load("glIndexdv"); + glad_glIndexf = (PFNGLINDEXFPROC)load("glIndexf"); + glad_glIndexfv = (PFNGLINDEXFVPROC)load("glIndexfv"); + glad_glIndexi = (PFNGLINDEXIPROC)load("glIndexi"); + glad_glIndexiv = (PFNGLINDEXIVPROC)load("glIndexiv"); + glad_glIndexs = (PFNGLINDEXSPROC)load("glIndexs"); + glad_glIndexsv = (PFNGLINDEXSVPROC)load("glIndexsv"); + glad_glNormal3b = (PFNGLNORMAL3BPROC)load("glNormal3b"); + glad_glNormal3bv = (PFNGLNORMAL3BVPROC)load("glNormal3bv"); + glad_glNormal3d = (PFNGLNORMAL3DPROC)load("glNormal3d"); + glad_glNormal3dv = (PFNGLNORMAL3DVPROC)load("glNormal3dv"); + glad_glNormal3f = (PFNGLNORMAL3FPROC)load("glNormal3f"); + glad_glNormal3fv = (PFNGLNORMAL3FVPROC)load("glNormal3fv"); + glad_glNormal3i = (PFNGLNORMAL3IPROC)load("glNormal3i"); + glad_glNormal3iv = (PFNGLNORMAL3IVPROC)load("glNormal3iv"); + glad_glNormal3s = (PFNGLNORMAL3SPROC)load("glNormal3s"); + glad_glNormal3sv = (PFNGLNORMAL3SVPROC)load("glNormal3sv"); + glad_glRasterPos2d = (PFNGLRASTERPOS2DPROC)load("glRasterPos2d"); + glad_glRasterPos2dv = (PFNGLRASTERPOS2DVPROC)load("glRasterPos2dv"); + glad_glRasterPos2f = (PFNGLRASTERPOS2FPROC)load("glRasterPos2f"); + glad_glRasterPos2fv = (PFNGLRASTERPOS2FVPROC)load("glRasterPos2fv"); + glad_glRasterPos2i = (PFNGLRASTERPOS2IPROC)load("glRasterPos2i"); + glad_glRasterPos2iv = (PFNGLRASTERPOS2IVPROC)load("glRasterPos2iv"); + glad_glRasterPos2s = (PFNGLRASTERPOS2SPROC)load("glRasterPos2s"); + glad_glRasterPos2sv = (PFNGLRASTERPOS2SVPROC)load("glRasterPos2sv"); + glad_glRasterPos3d = (PFNGLRASTERPOS3DPROC)load("glRasterPos3d"); + glad_glRasterPos3dv = (PFNGLRASTERPOS3DVPROC)load("glRasterPos3dv"); + glad_glRasterPos3f = (PFNGLRASTERPOS3FPROC)load("glRasterPos3f"); + glad_glRasterPos3fv = (PFNGLRASTERPOS3FVPROC)load("glRasterPos3fv"); + glad_glRasterPos3i = (PFNGLRASTERPOS3IPROC)load("glRasterPos3i"); + glad_glRasterPos3iv = (PFNGLRASTERPOS3IVPROC)load("glRasterPos3iv"); + glad_glRasterPos3s = (PFNGLRASTERPOS3SPROC)load("glRasterPos3s"); + glad_glRasterPos3sv = (PFNGLRASTERPOS3SVPROC)load("glRasterPos3sv"); + glad_glRasterPos4d = (PFNGLRASTERPOS4DPROC)load("glRasterPos4d"); + glad_glRasterPos4dv = (PFNGLRASTERPOS4DVPROC)load("glRasterPos4dv"); + glad_glRasterPos4f = (PFNGLRASTERPOS4FPROC)load("glRasterPos4f"); + glad_glRasterPos4fv = (PFNGLRASTERPOS4FVPROC)load("glRasterPos4fv"); + glad_glRasterPos4i = (PFNGLRASTERPOS4IPROC)load("glRasterPos4i"); + glad_glRasterPos4iv = (PFNGLRASTERPOS4IVPROC)load("glRasterPos4iv"); + glad_glRasterPos4s = (PFNGLRASTERPOS4SPROC)load("glRasterPos4s"); + glad_glRasterPos4sv = (PFNGLRASTERPOS4SVPROC)load("glRasterPos4sv"); + glad_glRectd = (PFNGLRECTDPROC)load("glRectd"); + glad_glRectdv = (PFNGLRECTDVPROC)load("glRectdv"); + glad_glRectf = (PFNGLRECTFPROC)load("glRectf"); + glad_glRectfv = (PFNGLRECTFVPROC)load("glRectfv"); + glad_glRecti = (PFNGLRECTIPROC)load("glRecti"); + glad_glRectiv = (PFNGLRECTIVPROC)load("glRectiv"); + glad_glRects = (PFNGLRECTSPROC)load("glRects"); + glad_glRectsv = (PFNGLRECTSVPROC)load("glRectsv"); + glad_glTexCoord1d = (PFNGLTEXCOORD1DPROC)load("glTexCoord1d"); + glad_glTexCoord1dv = (PFNGLTEXCOORD1DVPROC)load("glTexCoord1dv"); + glad_glTexCoord1f = (PFNGLTEXCOORD1FPROC)load("glTexCoord1f"); + glad_glTexCoord1fv = (PFNGLTEXCOORD1FVPROC)load("glTexCoord1fv"); + glad_glTexCoord1i = (PFNGLTEXCOORD1IPROC)load("glTexCoord1i"); + glad_glTexCoord1iv = (PFNGLTEXCOORD1IVPROC)load("glTexCoord1iv"); + glad_glTexCoord1s = (PFNGLTEXCOORD1SPROC)load("glTexCoord1s"); + glad_glTexCoord1sv = (PFNGLTEXCOORD1SVPROC)load("glTexCoord1sv"); + glad_glTexCoord2d = (PFNGLTEXCOORD2DPROC)load("glTexCoord2d"); + glad_glTexCoord2dv = (PFNGLTEXCOORD2DVPROC)load("glTexCoord2dv"); + glad_glTexCoord2f = (PFNGLTEXCOORD2FPROC)load("glTexCoord2f"); + glad_glTexCoord2fv = (PFNGLTEXCOORD2FVPROC)load("glTexCoord2fv"); + glad_glTexCoord2i = (PFNGLTEXCOORD2IPROC)load("glTexCoord2i"); + glad_glTexCoord2iv = (PFNGLTEXCOORD2IVPROC)load("glTexCoord2iv"); + glad_glTexCoord2s = (PFNGLTEXCOORD2SPROC)load("glTexCoord2s"); + glad_glTexCoord2sv = (PFNGLTEXCOORD2SVPROC)load("glTexCoord2sv"); + glad_glTexCoord3d = (PFNGLTEXCOORD3DPROC)load("glTexCoord3d"); + glad_glTexCoord3dv = (PFNGLTEXCOORD3DVPROC)load("glTexCoord3dv"); + glad_glTexCoord3f = (PFNGLTEXCOORD3FPROC)load("glTexCoord3f"); + glad_glTexCoord3fv = (PFNGLTEXCOORD3FVPROC)load("glTexCoord3fv"); + glad_glTexCoord3i = (PFNGLTEXCOORD3IPROC)load("glTexCoord3i"); + glad_glTexCoord3iv = (PFNGLTEXCOORD3IVPROC)load("glTexCoord3iv"); + glad_glTexCoord3s = (PFNGLTEXCOORD3SPROC)load("glTexCoord3s"); + glad_glTexCoord3sv = (PFNGLTEXCOORD3SVPROC)load("glTexCoord3sv"); + glad_glTexCoord4d = (PFNGLTEXCOORD4DPROC)load("glTexCoord4d"); + glad_glTexCoord4dv = (PFNGLTEXCOORD4DVPROC)load("glTexCoord4dv"); + glad_glTexCoord4f = (PFNGLTEXCOORD4FPROC)load("glTexCoord4f"); + glad_glTexCoord4fv = (PFNGLTEXCOORD4FVPROC)load("glTexCoord4fv"); + glad_glTexCoord4i = (PFNGLTEXCOORD4IPROC)load("glTexCoord4i"); + glad_glTexCoord4iv = (PFNGLTEXCOORD4IVPROC)load("glTexCoord4iv"); + glad_glTexCoord4s = (PFNGLTEXCOORD4SPROC)load("glTexCoord4s"); + glad_glTexCoord4sv = (PFNGLTEXCOORD4SVPROC)load("glTexCoord4sv"); + glad_glVertex2d = (PFNGLVERTEX2DPROC)load("glVertex2d"); + glad_glVertex2dv = (PFNGLVERTEX2DVPROC)load("glVertex2dv"); + glad_glVertex2f = (PFNGLVERTEX2FPROC)load("glVertex2f"); + glad_glVertex2fv = (PFNGLVERTEX2FVPROC)load("glVertex2fv"); + glad_glVertex2i = (PFNGLVERTEX2IPROC)load("glVertex2i"); + glad_glVertex2iv = (PFNGLVERTEX2IVPROC)load("glVertex2iv"); + glad_glVertex2s = (PFNGLVERTEX2SPROC)load("glVertex2s"); + glad_glVertex2sv = (PFNGLVERTEX2SVPROC)load("glVertex2sv"); + glad_glVertex3d = (PFNGLVERTEX3DPROC)load("glVertex3d"); + glad_glVertex3dv = (PFNGLVERTEX3DVPROC)load("glVertex3dv"); + glad_glVertex3f = (PFNGLVERTEX3FPROC)load("glVertex3f"); + glad_glVertex3fv = (PFNGLVERTEX3FVPROC)load("glVertex3fv"); + glad_glVertex3i = (PFNGLVERTEX3IPROC)load("glVertex3i"); + glad_glVertex3iv = (PFNGLVERTEX3IVPROC)load("glVertex3iv"); + glad_glVertex3s = (PFNGLVERTEX3SPROC)load("glVertex3s"); + glad_glVertex3sv = (PFNGLVERTEX3SVPROC)load("glVertex3sv"); + glad_glVertex4d = (PFNGLVERTEX4DPROC)load("glVertex4d"); + glad_glVertex4dv = (PFNGLVERTEX4DVPROC)load("glVertex4dv"); + glad_glVertex4f = (PFNGLVERTEX4FPROC)load("glVertex4f"); + glad_glVertex4fv = (PFNGLVERTEX4FVPROC)load("glVertex4fv"); + glad_glVertex4i = (PFNGLVERTEX4IPROC)load("glVertex4i"); + glad_glVertex4iv = (PFNGLVERTEX4IVPROC)load("glVertex4iv"); + glad_glVertex4s = (PFNGLVERTEX4SPROC)load("glVertex4s"); + glad_glVertex4sv = (PFNGLVERTEX4SVPROC)load("glVertex4sv"); + glad_glClipPlane = (PFNGLCLIPPLANEPROC)load("glClipPlane"); + glad_glColorMaterial = (PFNGLCOLORMATERIALPROC)load("glColorMaterial"); + glad_glFogf = (PFNGLFOGFPROC)load("glFogf"); + glad_glFogfv = (PFNGLFOGFVPROC)load("glFogfv"); + glad_glFogi = (PFNGLFOGIPROC)load("glFogi"); + glad_glFogiv = (PFNGLFOGIVPROC)load("glFogiv"); + glad_glLightf = (PFNGLLIGHTFPROC)load("glLightf"); + glad_glLightfv = (PFNGLLIGHTFVPROC)load("glLightfv"); + glad_glLighti = (PFNGLLIGHTIPROC)load("glLighti"); + glad_glLightiv = (PFNGLLIGHTIVPROC)load("glLightiv"); + glad_glLightModelf = (PFNGLLIGHTMODELFPROC)load("glLightModelf"); + glad_glLightModelfv = (PFNGLLIGHTMODELFVPROC)load("glLightModelfv"); + glad_glLightModeli = (PFNGLLIGHTMODELIPROC)load("glLightModeli"); + glad_glLightModeliv = (PFNGLLIGHTMODELIVPROC)load("glLightModeliv"); + glad_glLineStipple = (PFNGLLINESTIPPLEPROC)load("glLineStipple"); + glad_glMaterialf = (PFNGLMATERIALFPROC)load("glMaterialf"); + glad_glMaterialfv = (PFNGLMATERIALFVPROC)load("glMaterialfv"); + glad_glMateriali = (PFNGLMATERIALIPROC)load("glMateriali"); + glad_glMaterialiv = (PFNGLMATERIALIVPROC)load("glMaterialiv"); + glad_glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC)load("glPolygonStipple"); + glad_glShadeModel = (PFNGLSHADEMODELPROC)load("glShadeModel"); + glad_glTexEnvf = (PFNGLTEXENVFPROC)load("glTexEnvf"); + glad_glTexEnvfv = (PFNGLTEXENVFVPROC)load("glTexEnvfv"); + glad_glTexEnvi = (PFNGLTEXENVIPROC)load("glTexEnvi"); + glad_glTexEnviv = (PFNGLTEXENVIVPROC)load("glTexEnviv"); + glad_glTexGend = (PFNGLTEXGENDPROC)load("glTexGend"); + glad_glTexGendv = (PFNGLTEXGENDVPROC)load("glTexGendv"); + glad_glTexGenf = (PFNGLTEXGENFPROC)load("glTexGenf"); + glad_glTexGenfv = (PFNGLTEXGENFVPROC)load("glTexGenfv"); + glad_glTexGeni = (PFNGLTEXGENIPROC)load("glTexGeni"); + glad_glTexGeniv = (PFNGLTEXGENIVPROC)load("glTexGeniv"); + glad_glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC)load("glFeedbackBuffer"); + glad_glSelectBuffer = (PFNGLSELECTBUFFERPROC)load("glSelectBuffer"); + glad_glRenderMode = (PFNGLRENDERMODEPROC)load("glRenderMode"); + glad_glInitNames = (PFNGLINITNAMESPROC)load("glInitNames"); + glad_glLoadName = (PFNGLLOADNAMEPROC)load("glLoadName"); + glad_glPassThrough = (PFNGLPASSTHROUGHPROC)load("glPassThrough"); + glad_glPopName = (PFNGLPOPNAMEPROC)load("glPopName"); + glad_glPushName = (PFNGLPUSHNAMEPROC)load("glPushName"); + glad_glClearAccum = (PFNGLCLEARACCUMPROC)load("glClearAccum"); + glad_glClearIndex = (PFNGLCLEARINDEXPROC)load("glClearIndex"); + glad_glIndexMask = (PFNGLINDEXMASKPROC)load("glIndexMask"); + glad_glAccum = (PFNGLACCUMPROC)load("glAccum"); + glad_glPopAttrib = (PFNGLPOPATTRIBPROC)load("glPopAttrib"); + glad_glPushAttrib = (PFNGLPUSHATTRIBPROC)load("glPushAttrib"); + glad_glMap1d = (PFNGLMAP1DPROC)load("glMap1d"); + glad_glMap1f = (PFNGLMAP1FPROC)load("glMap1f"); + glad_glMap2d = (PFNGLMAP2DPROC)load("glMap2d"); + glad_glMap2f = (PFNGLMAP2FPROC)load("glMap2f"); + glad_glMapGrid1d = (PFNGLMAPGRID1DPROC)load("glMapGrid1d"); + glad_glMapGrid1f = (PFNGLMAPGRID1FPROC)load("glMapGrid1f"); + glad_glMapGrid2d = (PFNGLMAPGRID2DPROC)load("glMapGrid2d"); + glad_glMapGrid2f = (PFNGLMAPGRID2FPROC)load("glMapGrid2f"); + glad_glEvalCoord1d = (PFNGLEVALCOORD1DPROC)load("glEvalCoord1d"); + glad_glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC)load("glEvalCoord1dv"); + glad_glEvalCoord1f = (PFNGLEVALCOORD1FPROC)load("glEvalCoord1f"); + glad_glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC)load("glEvalCoord1fv"); + glad_glEvalCoord2d = (PFNGLEVALCOORD2DPROC)load("glEvalCoord2d"); + glad_glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC)load("glEvalCoord2dv"); + glad_glEvalCoord2f = (PFNGLEVALCOORD2FPROC)load("glEvalCoord2f"); + glad_glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC)load("glEvalCoord2fv"); + glad_glEvalMesh1 = (PFNGLEVALMESH1PROC)load("glEvalMesh1"); + glad_glEvalPoint1 = (PFNGLEVALPOINT1PROC)load("glEvalPoint1"); + glad_glEvalMesh2 = (PFNGLEVALMESH2PROC)load("glEvalMesh2"); + glad_glEvalPoint2 = (PFNGLEVALPOINT2PROC)load("glEvalPoint2"); + glad_glAlphaFunc = (PFNGLALPHAFUNCPROC)load("glAlphaFunc"); + glad_glPixelZoom = (PFNGLPIXELZOOMPROC)load("glPixelZoom"); + glad_glPixelTransferf = (PFNGLPIXELTRANSFERFPROC)load("glPixelTransferf"); + glad_glPixelTransferi = (PFNGLPIXELTRANSFERIPROC)load("glPixelTransferi"); + glad_glPixelMapfv = (PFNGLPIXELMAPFVPROC)load("glPixelMapfv"); + glad_glPixelMapuiv = (PFNGLPIXELMAPUIVPROC)load("glPixelMapuiv"); + glad_glPixelMapusv = (PFNGLPIXELMAPUSVPROC)load("glPixelMapusv"); + glad_glCopyPixels = (PFNGLCOPYPIXELSPROC)load("glCopyPixels"); + glad_glDrawPixels = (PFNGLDRAWPIXELSPROC)load("glDrawPixels"); + glad_glGetClipPlane = (PFNGLGETCLIPPLANEPROC)load("glGetClipPlane"); + glad_glGetLightfv = (PFNGLGETLIGHTFVPROC)load("glGetLightfv"); + glad_glGetLightiv = (PFNGLGETLIGHTIVPROC)load("glGetLightiv"); + glad_glGetMapdv = (PFNGLGETMAPDVPROC)load("glGetMapdv"); + glad_glGetMapfv = (PFNGLGETMAPFVPROC)load("glGetMapfv"); + glad_glGetMapiv = (PFNGLGETMAPIVPROC)load("glGetMapiv"); + glad_glGetMaterialfv = (PFNGLGETMATERIALFVPROC)load("glGetMaterialfv"); + glad_glGetMaterialiv = (PFNGLGETMATERIALIVPROC)load("glGetMaterialiv"); + glad_glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC)load("glGetPixelMapfv"); + glad_glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC)load("glGetPixelMapuiv"); + glad_glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC)load("glGetPixelMapusv"); + glad_glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC)load("glGetPolygonStipple"); + glad_glGetTexEnvfv = (PFNGLGETTEXENVFVPROC)load("glGetTexEnvfv"); + glad_glGetTexEnviv = (PFNGLGETTEXENVIVPROC)load("glGetTexEnviv"); + glad_glGetTexGendv = (PFNGLGETTEXGENDVPROC)load("glGetTexGendv"); + glad_glGetTexGenfv = (PFNGLGETTEXGENFVPROC)load("glGetTexGenfv"); + glad_glGetTexGeniv = (PFNGLGETTEXGENIVPROC)load("glGetTexGeniv"); + glad_glIsList = (PFNGLISLISTPROC)load("glIsList"); + glad_glFrustum = (PFNGLFRUSTUMPROC)load("glFrustum"); + glad_glLoadIdentity = (PFNGLLOADIDENTITYPROC)load("glLoadIdentity"); + glad_glLoadMatrixf = (PFNGLLOADMATRIXFPROC)load("glLoadMatrixf"); + glad_glLoadMatrixd = (PFNGLLOADMATRIXDPROC)load("glLoadMatrixd"); + glad_glMatrixMode = (PFNGLMATRIXMODEPROC)load("glMatrixMode"); + glad_glMultMatrixf = (PFNGLMULTMATRIXFPROC)load("glMultMatrixf"); + glad_glMultMatrixd = (PFNGLMULTMATRIXDPROC)load("glMultMatrixd"); + glad_glOrtho = (PFNGLORTHOPROC)load("glOrtho"); + glad_glPopMatrix = (PFNGLPOPMATRIXPROC)load("glPopMatrix"); + glad_glPushMatrix = (PFNGLPUSHMATRIXPROC)load("glPushMatrix"); + glad_glRotated = (PFNGLROTATEDPROC)load("glRotated"); + glad_glRotatef = (PFNGLROTATEFPROC)load("glRotatef"); + glad_glScaled = (PFNGLSCALEDPROC)load("glScaled"); + glad_glScalef = (PFNGLSCALEFPROC)load("glScalef"); + glad_glTranslated = (PFNGLTRANSLATEDPROC)load("glTranslated"); + glad_glTranslatef = (PFNGLTRANSLATEFPROC)load("glTranslatef"); +} +static void load_GL_VERSION_1_1(GLADloadproc load) { + if(!GLAD_GL_VERSION_1_1) return; + glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays"); + glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements"); + glad_glGetPointerv = (PFNGLGETPOINTERVPROC)load("glGetPointerv"); + glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset"); + glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D"); + glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D"); + glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D"); + glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D"); + glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D"); + glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D"); + glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture"); + glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures"); + glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures"); + glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture"); + glad_glArrayElement = (PFNGLARRAYELEMENTPROC)load("glArrayElement"); + glad_glColorPointer = (PFNGLCOLORPOINTERPROC)load("glColorPointer"); + glad_glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC)load("glDisableClientState"); + glad_glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC)load("glEdgeFlagPointer"); + glad_glEnableClientState = (PFNGLENABLECLIENTSTATEPROC)load("glEnableClientState"); + glad_glIndexPointer = (PFNGLINDEXPOINTERPROC)load("glIndexPointer"); + glad_glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC)load("glInterleavedArrays"); + glad_glNormalPointer = (PFNGLNORMALPOINTERPROC)load("glNormalPointer"); + glad_glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC)load("glTexCoordPointer"); + glad_glVertexPointer = (PFNGLVERTEXPOINTERPROC)load("glVertexPointer"); + glad_glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC)load("glAreTexturesResident"); + glad_glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC)load("glPrioritizeTextures"); + glad_glIndexub = (PFNGLINDEXUBPROC)load("glIndexub"); + glad_glIndexubv = (PFNGLINDEXUBVPROC)load("glIndexubv"); + glad_glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC)load("glPopClientAttrib"); + glad_glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC)load("glPushClientAttrib"); +} +static void load_GL_VERSION_1_2(GLADloadproc load) { + if(!GLAD_GL_VERSION_1_2) return; + glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements"); + glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D"); + glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D"); + glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D"); +} +static void load_GL_VERSION_1_3(GLADloadproc load) { + if(!GLAD_GL_VERSION_1_3) return; + glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture"); + glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage"); + glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D"); + glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D"); + glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D"); + glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D"); + glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D"); + glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D"); + glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage"); + glad_glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)load("glClientActiveTexture"); + glad_glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC)load("glMultiTexCoord1d"); + glad_glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC)load("glMultiTexCoord1dv"); + glad_glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC)load("glMultiTexCoord1f"); + glad_glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC)load("glMultiTexCoord1fv"); + glad_glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC)load("glMultiTexCoord1i"); + glad_glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC)load("glMultiTexCoord1iv"); + glad_glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC)load("glMultiTexCoord1s"); + glad_glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC)load("glMultiTexCoord1sv"); + glad_glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC)load("glMultiTexCoord2d"); + glad_glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC)load("glMultiTexCoord2dv"); + glad_glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC)load("glMultiTexCoord2f"); + glad_glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC)load("glMultiTexCoord2fv"); + glad_glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC)load("glMultiTexCoord2i"); + glad_glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC)load("glMultiTexCoord2iv"); + glad_glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC)load("glMultiTexCoord2s"); + glad_glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC)load("glMultiTexCoord2sv"); + glad_glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC)load("glMultiTexCoord3d"); + glad_glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC)load("glMultiTexCoord3dv"); + glad_glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC)load("glMultiTexCoord3f"); + glad_glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC)load("glMultiTexCoord3fv"); + glad_glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC)load("glMultiTexCoord3i"); + glad_glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC)load("glMultiTexCoord3iv"); + glad_glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC)load("glMultiTexCoord3s"); + glad_glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC)load("glMultiTexCoord3sv"); + glad_glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC)load("glMultiTexCoord4d"); + glad_glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC)load("glMultiTexCoord4dv"); + glad_glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC)load("glMultiTexCoord4f"); + glad_glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC)load("glMultiTexCoord4fv"); + glad_glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC)load("glMultiTexCoord4i"); + glad_glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC)load("glMultiTexCoord4iv"); + glad_glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC)load("glMultiTexCoord4s"); + glad_glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC)load("glMultiTexCoord4sv"); + glad_glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC)load("glLoadTransposeMatrixf"); + glad_glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC)load("glLoadTransposeMatrixd"); + glad_glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC)load("glMultTransposeMatrixf"); + glad_glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC)load("glMultTransposeMatrixd"); +} +static void load_GL_VERSION_1_4(GLADloadproc load) { + if(!GLAD_GL_VERSION_1_4) return; + glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate"); + glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays"); + glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements"); + glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf"); + glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv"); + glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri"); + glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv"); + glad_glFogCoordf = (PFNGLFOGCOORDFPROC)load("glFogCoordf"); + glad_glFogCoordfv = (PFNGLFOGCOORDFVPROC)load("glFogCoordfv"); + glad_glFogCoordd = (PFNGLFOGCOORDDPROC)load("glFogCoordd"); + glad_glFogCoorddv = (PFNGLFOGCOORDDVPROC)load("glFogCoorddv"); + glad_glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)load("glFogCoordPointer"); + glad_glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC)load("glSecondaryColor3b"); + glad_glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC)load("glSecondaryColor3bv"); + glad_glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC)load("glSecondaryColor3d"); + glad_glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC)load("glSecondaryColor3dv"); + glad_glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC)load("glSecondaryColor3f"); + glad_glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC)load("glSecondaryColor3fv"); + glad_glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC)load("glSecondaryColor3i"); + glad_glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC)load("glSecondaryColor3iv"); + glad_glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC)load("glSecondaryColor3s"); + glad_glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC)load("glSecondaryColor3sv"); + glad_glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC)load("glSecondaryColor3ub"); + glad_glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC)load("glSecondaryColor3ubv"); + glad_glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC)load("glSecondaryColor3ui"); + glad_glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC)load("glSecondaryColor3uiv"); + glad_glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC)load("glSecondaryColor3us"); + glad_glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC)load("glSecondaryColor3usv"); + glad_glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC)load("glSecondaryColorPointer"); + glad_glWindowPos2d = (PFNGLWINDOWPOS2DPROC)load("glWindowPos2d"); + glad_glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC)load("glWindowPos2dv"); + glad_glWindowPos2f = (PFNGLWINDOWPOS2FPROC)load("glWindowPos2f"); + glad_glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC)load("glWindowPos2fv"); + glad_glWindowPos2i = (PFNGLWINDOWPOS2IPROC)load("glWindowPos2i"); + glad_glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC)load("glWindowPos2iv"); + glad_glWindowPos2s = (PFNGLWINDOWPOS2SPROC)load("glWindowPos2s"); + glad_glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC)load("glWindowPos2sv"); + glad_glWindowPos3d = (PFNGLWINDOWPOS3DPROC)load("glWindowPos3d"); + glad_glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC)load("glWindowPos3dv"); + glad_glWindowPos3f = (PFNGLWINDOWPOS3FPROC)load("glWindowPos3f"); + glad_glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC)load("glWindowPos3fv"); + glad_glWindowPos3i = (PFNGLWINDOWPOS3IPROC)load("glWindowPos3i"); + glad_glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC)load("glWindowPos3iv"); + glad_glWindowPos3s = (PFNGLWINDOWPOS3SPROC)load("glWindowPos3s"); + glad_glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC)load("glWindowPos3sv"); + glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor"); + glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation"); +} +static void load_GL_VERSION_1_5(GLADloadproc load) { + if(!GLAD_GL_VERSION_1_5) return; + glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries"); + glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries"); + glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery"); + glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery"); + glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery"); + glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv"); + glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv"); + glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv"); + glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer"); + glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers"); + glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers"); + glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer"); + glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData"); + glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData"); + glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData"); + glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer"); + glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer"); + glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv"); + glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv"); +} +static void load_GL_VERSION_2_0(GLADloadproc load) { + if(!GLAD_GL_VERSION_2_0) return; + glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate"); + glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers"); + glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate"); + glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate"); + glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate"); + glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader"); + glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation"); + glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader"); + glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram"); + glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader"); + glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram"); + glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader"); + glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader"); + glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray"); + glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray"); + glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib"); + glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform"); + glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders"); + glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation"); + glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv"); + glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog"); + glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv"); + glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog"); + glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource"); + glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation"); + glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv"); + glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv"); + glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv"); + glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv"); + glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv"); + glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv"); + glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram"); + glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader"); + glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram"); + glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource"); + glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram"); + glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f"); + glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f"); + glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f"); + glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f"); + glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i"); + glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i"); + glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i"); + glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i"); + glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv"); + glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv"); + glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv"); + glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv"); + glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv"); + glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv"); + glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv"); + glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv"); + glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv"); + glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv"); + glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv"); + glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram"); + glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d"); + glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv"); + glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f"); + glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv"); + glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s"); + glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv"); + glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d"); + glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv"); + glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f"); + glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv"); + glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s"); + glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv"); + glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d"); + glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv"); + glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f"); + glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv"); + glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s"); + glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv"); + glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv"); + glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv"); + glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv"); + glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub"); + glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv"); + glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv"); + glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv"); + glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv"); + glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d"); + glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv"); + glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f"); + glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv"); + glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv"); + glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s"); + glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv"); + glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv"); + glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv"); + glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv"); + glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer"); +} +static void load_GL_VERSION_2_1(GLADloadproc load) { + if(!GLAD_GL_VERSION_2_1) return; + glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv"); + glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv"); + glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv"); + glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv"); + glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv"); + glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv"); +} +static void load_GL_VERSION_3_0(GLADloadproc load) { + if(!GLAD_GL_VERSION_3_0) return; + glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski"); + glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v"); + glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei"); + glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei"); + glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi"); + glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback"); + glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange"); + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase"); + glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings"); + glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying"); + glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor"); + glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender"); + glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender"); + glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer"); + glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv"); + glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv"); + glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i"); + glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i"); + glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i"); + glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i"); + glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui"); + glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui"); + glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui"); + glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui"); + glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv"); + glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv"); + glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv"); + glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv"); + glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv"); + glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv"); + glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv"); + glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv"); + glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv"); + glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv"); + glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv"); + glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv"); + glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv"); + glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation"); + glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation"); + glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui"); + glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui"); + glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui"); + glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui"); + glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv"); + glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv"); + glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv"); + glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv"); + glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv"); + glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv"); + glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv"); + glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv"); + glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv"); + glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv"); + glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv"); + glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi"); + glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi"); + glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer"); + glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer"); + glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers"); + glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers"); + glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage"); + glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv"); + glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer"); + glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer"); + glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers"); + glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers"); + glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus"); + glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D"); + glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D"); + glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D"); + glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer"); + glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv"); + glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap"); + glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer"); + glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample"); + glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer"); + glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange"); + glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange"); + glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray"); + glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays"); + glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays"); + glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray"); +} +static void load_GL_VERSION_3_1(GLADloadproc load) { + if(!GLAD_GL_VERSION_3_1) return; + glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load("glDrawArraysInstanced"); + glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load("glDrawElementsInstanced"); + glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load("glTexBuffer"); + glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load("glPrimitiveRestartIndex"); + glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load("glCopyBufferSubData"); + glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices"); + glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv"); + glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName"); + glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex"); + glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv"); + glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName"); + glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange"); + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v"); +} +static void load_GL_VERSION_3_2(GLADloadproc load) { + if(!GLAD_GL_VERSION_3_2) return; + glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex"); + glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex"); + glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex"); + glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex"); + glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load("glProvokingVertex"); + glad_glFenceSync = (PFNGLFENCESYNCPROC)load("glFenceSync"); + glad_glIsSync = (PFNGLISSYNCPROC)load("glIsSync"); + glad_glDeleteSync = (PFNGLDELETESYNCPROC)load("glDeleteSync"); + glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load("glClientWaitSync"); + glad_glWaitSync = (PFNGLWAITSYNCPROC)load("glWaitSync"); + glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load("glGetInteger64v"); + glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load("glGetSynciv"); + glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load("glGetInteger64i_v"); + glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load("glGetBufferParameteri64v"); + glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load("glFramebufferTexture"); + glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample"); + glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample"); + glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv"); + glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski"); +} +static void load_GL_VERSION_3_3(GLADloadproc load) { + if(!GLAD_GL_VERSION_3_3) return; + glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed"); + glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex"); + glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers"); + glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)load("glDeleteSamplers"); + glad_glIsSampler = (PFNGLISSAMPLERPROC)load("glIsSampler"); + glad_glBindSampler = (PFNGLBINDSAMPLERPROC)load("glBindSampler"); + glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)load("glSamplerParameteri"); + glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)load("glSamplerParameteriv"); + glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)load("glSamplerParameterf"); + glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)load("glSamplerParameterfv"); + glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)load("glSamplerParameterIiv"); + glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)load("glSamplerParameterIuiv"); + glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)load("glGetSamplerParameteriv"); + glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)load("glGetSamplerParameterIiv"); + glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)load("glGetSamplerParameterfv"); + glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)load("glGetSamplerParameterIuiv"); + glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC)load("glQueryCounter"); + glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)load("glGetQueryObjecti64v"); + glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)load("glGetQueryObjectui64v"); + glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)load("glVertexAttribDivisor"); + glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)load("glVertexAttribP1ui"); + glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)load("glVertexAttribP1uiv"); + glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)load("glVertexAttribP2ui"); + glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)load("glVertexAttribP2uiv"); + glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)load("glVertexAttribP3ui"); + glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)load("glVertexAttribP3uiv"); + glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)load("glVertexAttribP4ui"); + glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)load("glVertexAttribP4uiv"); + glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC)load("glVertexP2ui"); + glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)load("glVertexP2uiv"); + glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC)load("glVertexP3ui"); + glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)load("glVertexP3uiv"); + glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC)load("glVertexP4ui"); + glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)load("glVertexP4uiv"); + glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)load("glTexCoordP1ui"); + glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)load("glTexCoordP1uiv"); + glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)load("glTexCoordP2ui"); + glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)load("glTexCoordP2uiv"); + glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)load("glTexCoordP3ui"); + glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)load("glTexCoordP3uiv"); + glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)load("glTexCoordP4ui"); + glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)load("glTexCoordP4uiv"); + glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)load("glMultiTexCoordP1ui"); + glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)load("glMultiTexCoordP1uiv"); + glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)load("glMultiTexCoordP2ui"); + glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)load("glMultiTexCoordP2uiv"); + glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)load("glMultiTexCoordP3ui"); + glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)load("glMultiTexCoordP3uiv"); + glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)load("glMultiTexCoordP4ui"); + glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)load("glMultiTexCoordP4uiv"); + glad_glNormalP3ui = (PFNGLNORMALP3UIPROC)load("glNormalP3ui"); + glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC)load("glNormalP3uiv"); + glad_glColorP3ui = (PFNGLCOLORP3UIPROC)load("glColorP3ui"); + glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC)load("glColorP3uiv"); + glad_glColorP4ui = (PFNGLCOLORP4UIPROC)load("glColorP4ui"); + glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC)load("glColorP4uiv"); + glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui"); + glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv"); +} +static int find_extensionsGL(void) { + if (!get_exts()) return 0; + (void)&has_ext; + free_exts(); + return 1; +} + +static void find_coreGL(void) { + + /* Thank you @elmindreda + * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176 + * https://github.com/glfw/glfw/blob/master/src/context.c#L36 + */ + int i, major, minor; + + const char* version; + const char* prefixes[] = { + "OpenGL ES-CM ", + "OpenGL ES-CL ", + "OpenGL ES ", + NULL + }; + + version = (const char*) glGetString(GL_VERSION); + if (!version) return; + + for (i = 0; prefixes[i]; i++) { + const size_t length = strlen(prefixes[i]); + if (strncmp(version, prefixes[i], length) == 0) { + version += length; + break; + } + } + +/* PR #18 */ +#ifdef _MSC_VER + sscanf_s(version, "%d.%d", &major, &minor); +#else + sscanf(version, "%d.%d", &major, &minor); +#endif + + GLVersion.major = major; GLVersion.minor = minor; + max_loaded_major = major; max_loaded_minor = minor; + GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; + GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; + GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; + GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1; + GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1; + GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1; + GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; + GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2; + GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; + GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3; + GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; + GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3; + if (GLVersion.major > 3 || (GLVersion.major >= 3 && GLVersion.minor >= 3)) { + max_loaded_major = 3; + max_loaded_minor = 3; + } +} + +int gladLoadGLLoader(GLADloadproc load) { + GLVersion.major = 0; GLVersion.minor = 0; + glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); + if(glGetString == NULL) return 0; + if(glGetString(GL_VERSION) == NULL) return 0; + find_coreGL(); + load_GL_VERSION_1_0(load); + load_GL_VERSION_1_1(load); + load_GL_VERSION_1_2(load); + load_GL_VERSION_1_3(load); + load_GL_VERSION_1_4(load); + load_GL_VERSION_1_5(load); + load_GL_VERSION_2_0(load); + load_GL_VERSION_2_1(load); + load_GL_VERSION_3_0(load); + load_GL_VERSION_3_1(load); + load_GL_VERSION_3_2(load); + load_GL_VERSION_3_3(load); + + if (!find_extensionsGL()) return 0; + return GLVersion.major != 0 || GLVersion.minor != 0; +} + From e4e6ad3274963872d38afba972a776ec712797eb Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 26 Apr 2022 06:26:44 -0700 Subject: [PATCH 029/149] Add --interactive option Currently only works with the --gpu / --wavefront integrator. WASD-style controls; could use refinement. Control-R to record frames. --- .github/workflows/ci-cpu-linux.yml | 3 + .github/workflows/ci-gpu.yml | 4 + CMakeLists.txt | 13 +- src/pbrt/cmd/pbrt.cpp | 6 + src/pbrt/gpu/cudagl.h | 454 +++++++++++++++++++++++++++++ src/pbrt/options.cpp | 4 +- src/pbrt/options.h | 1 + src/pbrt/util/gui.cpp | 251 ++++++++++++++++ src/pbrt/util/gui.h | 77 +++++ src/pbrt/wavefront/camera.cpp | 10 +- src/pbrt/wavefront/integrator.cpp | 96 ++++-- src/pbrt/wavefront/integrator.h | 19 +- src/pbrt/wavefront/surfscatter.cpp | 20 +- 13 files changed, 918 insertions(+), 40 deletions(-) create mode 100644 src/pbrt/gpu/cudagl.h create mode 100644 src/pbrt/util/gui.cpp create mode 100644 src/pbrt/util/gui.h diff --git a/.github/workflows/ci-cpu-linux.yml b/.github/workflows/ci-cpu-linux.yml index 0a535549a..feafca28a 100644 --- a/.github/workflows/ci-cpu-linux.yml +++ b/.github/workflows/ci-cpu-linux.yml @@ -61,6 +61,9 @@ jobs: - name: Install OpenEXR run: sudo apt-get -y install libopenexr-dev + - name: Install OpenGL + run: sudo apt-get install -y --no-install-recommends libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libgl1-mesa-dev + - name: Install compilers run: sudo apt-get -y install ${{ matrix.compilers.cc }} ${{ matrix.compilers.cxx }} diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index 9aceace6f..77cf5f057 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -65,6 +65,10 @@ jobs: if: ${{ matrix.os == 'ubuntu-20.04' }} run: sudo apt-get -y install libopenexr-dev + - name: Install OpenGL + if: ${{ matrix.os == 'ubuntu-20.04' }} + run: sudo apt-get install -y --no-install-recommends libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libgl1-mesa-dev + - name: Configure run: | cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index d6fa9dd4f..d79d59ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,6 @@ check_ext ("qoi" "qoi" 028c75fd26e5e0758c7c711216c00404994c1ad3) check_ext ("stb" "stb/tools" af1a5bc352164740c1cc1354942b1c6b72eacb8a) check_ext ("utf8proc" "utf8proc/bench" 2484e2ed5e1d9c19edcccf392a7d9920ad90dfaf) check_ext ("zlib" "zlib/doc" 54d591eabf9fe0e84c725638f8d5d8d202a093fa) - add_compile_definitions ("$<$:PBRT_DEBUG_BUILD>") enable_testing () @@ -77,6 +76,8 @@ enable_testing () find_package (Sanitizers) find_package (Threads) +find_package(OpenGL REQUIRED) + set_property (GLOBAL PROPERTY USE_FOLDERS ON) if (MSVC) @@ -601,6 +602,7 @@ SET (PBRT_UTIL_SOURCE src/pbrt/util/error.cpp src/pbrt/util/file.cpp src/pbrt/util/float.cpp + src/pbrt/util/gui.cpp src/pbrt/util/image.cpp src/pbrt/util/log.cpp src/pbrt/util/loopsubdiv.cpp @@ -640,6 +642,7 @@ SET (PBRT_UTIL_SOURCE_HEADERS src/pbrt/util/error.h src/pbrt/util/file.h src/pbrt/util/float.h + src/pbrt/util/gui.h src/pbrt/util/hash.h src/pbrt/util/image.h src/pbrt/util/log.h @@ -679,6 +682,7 @@ if (PBRT_CUDA_ENABLED) ) set (PBRT_GPU_SOURCE_HEADERS src/pbrt/gpu/aggregate.h + src/pbrt/gpu/cudagl.h src/pbrt/gpu/denoiser.h src/pbrt/gpu/memory.h src/pbrt/gpu/optix.h @@ -842,7 +846,10 @@ target_include_directories (pbrt_lib PUBLIC ${DOUBLE_CONVERSION_INCLUDE} ${NANOVDB_INCLUDE} ${CMAKE_CURRENT_BINARY_DIR} + ${GLFW_INCLUDE} + ${GLAD_INCLUDE} ) + if (PBRT_CUDA_ENABLED AND PBRT_OPTIX7_PATH) target_include_directories (pbrt_lib SYSTEM PUBLIC ${PBRT_OPTIX7_PATH}/include) endif () @@ -868,7 +875,9 @@ set (ALL_PBRT_LIBS double-conversion ${PBRT_CUDA_LIB} utf8proc -) + glfw + glad + OpenGL::GL) if (PBRT_CUDA_ENABLED) set_property (TARGET pbrt_lib PROPERTY CUDA_SEPARABLE_COMPILATION ON) diff --git a/src/pbrt/cmd/pbrt.cpp b/src/pbrt/cmd/pbrt.cpp index a16d914f2..d9634df6b 100644 --- a/src/pbrt/cmd/pbrt.cpp +++ b/src/pbrt/cmd/pbrt.cpp @@ -54,6 +54,7 @@ Rendering options: #endif R"( --help Print this help text. + --interactive Enable interactive rendering mode. --mse-reference-image Filename for reference image to use for MSE computation. --mse-reference-out File to write MSE error vs spp results. --nthreads Use specified number of threads for rendering. @@ -176,6 +177,7 @@ int main(int argc, char *argv[]) { ParseArg(&iter, args.end(), "log-utilization", &options.logUtilization, onError) || ParseArg(&iter, args.end(), "log-file", &options.logFile, onError) || + ParseArg(&iter, args.end(), "interactive", &options.interactive, onError) || ParseArg(&iter, args.end(), "mse-reference-image", &options.mseReferenceImage, onError) || ParseArg(&iter, args.end(), "mse-reference-out", &options.mseReferenceOutput, @@ -248,6 +250,10 @@ int main(int argc, char *argv[]) { options.wavefront = false; } + if (options.interactive && !(options.useGPU || options.wavefront)) + ErrorExit("The --interactive option is only supported with the --gpu " + "and --wavefront integrators."); + options.logLevel = LogLevelFromString(logLevel); // Initialize pbrt diff --git a/src/pbrt/gpu/cudagl.h b/src/pbrt/gpu/cudagl.h new file mode 100644 index 000000000..1543ad042 --- /dev/null +++ b/src/pbrt/gpu/cudagl.h @@ -0,0 +1,454 @@ +// +// Copyright (c) 2021, NVIDIA CORPORATION. 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 name of NVIDIA CORPORATION 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 ``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 OWNER 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. +// + +#ifndef PBRT_GPU_CUDAGL_H +#define PBRT_GPU_CUDAGL_H + +#include +#include + +#include + +#include +#include +#include + +#define GL_CHECK(call) \ + do { \ + call; \ + if (GLenum err = glGetError(); err != GL_NO_ERROR) \ + LOG_FATAL("GL error: %s for " #call, getGLErrorString(err)); \ + } while (0) + +#define GL_CHECK_ERRORS() \ + do { \ + if (GLenum err = glGetError(); err != GL_NO_ERROR) \ + LOG_FATAL("GL error: %s", getGLErrorString(err)); \ + } while (0) + +namespace pbrt { + +// BufferDisplay functionality +// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. +// BSD 3-clause license + +extern const char *getGLErrorString(GLenum error); + +enum BufferImageFormat { UNSIGNED_BYTE4, FLOAT4, FLOAT3 }; + +class BufferDisplay { + public: + BufferDisplay(BufferImageFormat format = BufferImageFormat::UNSIGNED_BYTE4); + + void display(const int32_t screen_res_x, const int32_t screen_res_y, + const int32_t framebuf_res_x, const int32_t framebuf_res_y, + const uint32_t pbo) const; + + private: + GLuint m_render_tex = 0u; + GLuint m_program = 0u; + GLint m_render_tex_uniform_loc = -1; + GLuint m_quad_vertex_buffer = 0; + + BufferImageFormat m_image_format; +}; + +static GLuint createGLShader(const std::string& source, GLuint shader_type) { + GLuint shader = glCreateShader(shader_type); + + const GLchar* source_data = reinterpret_cast(source.data()); + glShaderSource(shader, 1, &source_data, nullptr); + glCompileShader(shader); + + GLint is_compiled = 0; + glGetShaderiv(shader, GL_COMPILE_STATUS, &is_compiled); + if (is_compiled == GL_FALSE) { + GLint max_length = 0; + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &max_length); + + std::string info_log(max_length, '\0'); + GLchar* info_log_data = reinterpret_cast(&info_log[0]); + glGetShaderInfoLog(shader, max_length, nullptr, info_log_data); + + glDeleteShader(shader); + LOG_FATAL("Shader compilation failed: %s", info_log); + } + + GL_CHECK_ERRORS(); + + return shader; +} + +static GLuint createGLProgram(const std::string& vert_source, + const std::string& frag_source) { + GLuint vert_shader = createGLShader(vert_source, GL_VERTEX_SHADER); + if (vert_shader == 0) + return 0; + + GLuint frag_shader = createGLShader(frag_source, GL_FRAGMENT_SHADER); + if (frag_shader == 0) { + glDeleteShader(vert_shader); + return 0; + } + + GLuint program = glCreateProgram(); + glAttachShader(program, vert_shader); + glAttachShader(program, frag_shader); + glLinkProgram(program); + + GLint is_linked = 0; + glGetProgramiv(program, GL_LINK_STATUS, &is_linked); + if (is_linked == GL_FALSE) { + GLint max_length = 0; + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &max_length); + + std::string info_log(max_length, '\0'); + GLchar* info_log_data = reinterpret_cast(&info_log[0]); + glGetProgramInfoLog(program, max_length, nullptr, info_log_data); + LOG_FATAL("Program linking failed: %s", info_log); + + glDeleteProgram(program); + glDeleteShader(vert_shader); + glDeleteShader(frag_shader); + + return 0; + } + + glDetachShader(program, vert_shader); + glDetachShader(program, frag_shader); + + GL_CHECK_ERRORS(); + + return program; +} + +static GLint getGLUniformLocation(GLuint program, const std::string& name) { + GLint loc = glGetUniformLocation(program, name.c_str()); + CHECK_NE(loc, -1); + return loc; +} + +static size_t pixelFormatSize(BufferImageFormat format) { + switch (format) { + case BufferImageFormat::UNSIGNED_BYTE4: + return sizeof(char) * 4; + case BufferImageFormat::FLOAT3: + return sizeof(float) * 3; + case BufferImageFormat::FLOAT4: + return sizeof(float) * 4; + default: + LOG_FATAL("sutil::pixelFormatSize: Unrecognized buffer format"); + } +} + +inline BufferDisplay::BufferDisplay(BufferImageFormat image_format) : m_image_format(image_format) { + GLuint m_vertex_array; + GL_CHECK(glGenVertexArrays(1, &m_vertex_array)); + GL_CHECK(glBindVertexArray(m_vertex_array)); + + std::string vert_source = R"( +#version 330 core + +layout(location = 0) in vec3 vertexPosition_modelspace; +out vec2 UV; + +void main() +{ + gl_Position = vec4(vertexPosition_modelspace,1); + UV = (vec2( vertexPosition_modelspace.x, vertexPosition_modelspace.y )+vec2(1,1))/2.0; + UV.y = 1 - UV.y; +} +)"; + + std::string frag_source = R"( +#version 330 core + +in vec2 UV; +out vec3 color; + +uniform sampler2D render_tex; + +void main() +{ + color = texture( render_tex, UV ).xyz; +} +)"; + + m_program = createGLProgram(vert_source, frag_source); + m_render_tex_uniform_loc = getGLUniformLocation(m_program, "render_tex"); + + GL_CHECK(glGenTextures(1, &m_render_tex)); + GL_CHECK(glBindTexture(GL_TEXTURE_2D, m_render_tex)); + + GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); + GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); + GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); + GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); + + static const GLfloat g_quad_vertex_buffer_data[] = { + -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, + -1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, + }; + + GL_CHECK(glGenBuffers(1, &m_quad_vertex_buffer)); + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, m_quad_vertex_buffer)); + GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(g_quad_vertex_buffer_data), + g_quad_vertex_buffer_data, GL_STATIC_DRAW)); + + GL_CHECK_ERRORS(); +} + +inline void BufferDisplay::display(const int32_t screen_res_x, const int32_t screen_res_y, + const int32_t framebuf_res_x, const int32_t framebuf_res_y, + const uint32_t pbo) const { + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0)); + GL_CHECK(glViewport(0, 0, framebuf_res_x, framebuf_res_y)); + + GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); + + GL_CHECK(glUseProgram(m_program)); + + // Bind our texture in Texture Unit 0 + GL_CHECK(glActiveTexture(GL_TEXTURE0)); + GL_CHECK(glBindTexture(GL_TEXTURE_2D, m_render_tex)); + GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo)); + + GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 4)); // TODO!!!!!! + + size_t elmt_size = pixelFormatSize(m_image_format); + if (elmt_size % 8 == 0) + glPixelStorei(GL_UNPACK_ALIGNMENT, 8); + else if (elmt_size % 4 == 0) + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + else if (elmt_size % 2 == 0) + glPixelStorei(GL_UNPACK_ALIGNMENT, 2); + else + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + bool convertToSrgb = true; + + if (m_image_format == BufferImageFormat::UNSIGNED_BYTE4) { + // input is assumed to be in srgb since it is only 1 byte per channel in size + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, screen_res_x, screen_res_y, 0, GL_RGBA, + GL_UNSIGNED_BYTE, nullptr); + convertToSrgb = false; + } else if (m_image_format == BufferImageFormat::FLOAT3) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, screen_res_x, screen_res_y, 0, GL_RGB, + GL_FLOAT, nullptr); + + else if (m_image_format == BufferImageFormat::FLOAT4) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, screen_res_x, screen_res_y, 0, GL_RGBA, + GL_FLOAT, nullptr); + + else + LOG_FATAL("Unknown buffer format"); + + GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); + GL_CHECK(glUniform1i(m_render_tex_uniform_loc, 0)); + + // 1st attribute buffer : vertices + GL_CHECK(glEnableVertexAttribArray(0)); + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, m_quad_vertex_buffer)); + GL_CHECK(glVertexAttribPointer(0, // attribute 0. No particular reason for 0, but + // must match the layout in the shader. + 3, // size + GL_FLOAT, // type + GL_FALSE, // normalized? + 0, // stride + (void*)0 // array buffer offset + )); + + if (convertToSrgb) + GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB)); + else + GL_CHECK(glDisable(GL_FRAMEBUFFER_SRGB)); + + GL_CHECK(glDrawArrays(GL_TRIANGLES, 0, 6)); // 2*3 indices starting at 0 -> 2 triangles + + GL_CHECK(glDisableVertexAttribArray(0)); + + GL_CHECK(glDisable(GL_FRAMEBUFFER_SRGB)); + + GL_CHECK_ERRORS(); +} + +// Specialized from the original to only support GL_INTEROP +template +class CUDAOutputBuffer { + public: + CUDAOutputBuffer(int32_t width, int32_t height); + ~CUDAOutputBuffer(); + + void StartAsynchronousReadback(); + const PIXEL_FORMAT *GetReadbackPixels(); + + void Draw(int windowWidth, int windowHeight) { + display->display(m_width, m_height, windowWidth, windowHeight, + getPBO()); + } + + PIXEL_FORMAT *Map(); + void Unmap(); + + private: + void setStream(CUstream stream) { m_stream = stream; } + // Allocate or update device pointer as necessary for CUDA access + void makeCurrent() { CUDA_CHECK(cudaSetDevice(m_device_idx)); } + + // Get output buffer + GLuint getPBO(); + void deletePBO(); + + int32_t m_width = 0u; + int32_t m_height = 0u; + + cudaGraphicsResource *m_cuda_gfx_resource = nullptr; + GLuint m_pbo = 0u; + PIXEL_FORMAT *m_device_pixels = nullptr; + PIXEL_FORMAT *m_host_pixels = nullptr; + + bool readbackActive = false; + cudaEvent_t readbackFinishedEvent; + + CUstream m_stream = 0u; + int32_t m_device_idx = 0; + + BufferDisplay *display = nullptr; +}; + +template +CUDAOutputBuffer::CUDAOutputBuffer(int32_t width, int32_t height) { + CHECK(width > 0 && height > 0); + + // If using GL Interop, expect that the active device is also the display device. + int current_device, is_display_device; + CUDA_CHECK(cudaGetDevice(¤t_device)); + CUDA_CHECK(cudaDeviceGetAttribute(&is_display_device, cudaDevAttrKernelExecTimeout, + current_device)); + if (!is_display_device) + LOG_FATAL("GL interop is only available on display device."); + + CUDA_CHECK(cudaGetDevice(&m_device_idx)); + + m_width = width; + m_height = height; + + makeCurrent(); + + // GL buffer gets resized below + GL_CHECK(glGenBuffers(1, &m_pbo)); + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, m_pbo)); + GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(PIXEL_FORMAT) * m_width * m_height, + nullptr, GL_STREAM_DRAW)); + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0u)); + + CUDA_CHECK(cudaGraphicsGLRegisterBuffer(&m_cuda_gfx_resource, m_pbo, + cudaGraphicsMapFlagsWriteDiscard)); + + CUDA_CHECK(cudaEventCreate(&readbackFinishedEvent)); + CUDA_CHECK(cudaMallocHost(&m_host_pixels, m_width * m_height * sizeof(PIXEL_FORMAT))); + + display = new BufferDisplay(BufferImageFormat::FLOAT3); +} + +template +CUDAOutputBuffer::~CUDAOutputBuffer() { + makeCurrent(); + + delete display; + + if (m_pbo != 0u) { + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0)); + GL_CHECK(glDeleteBuffers(1, &m_pbo)); + } +} + +template +PIXEL_FORMAT* CUDAOutputBuffer::Map() { + makeCurrent(); + + size_t buffer_size = 0u; + CUDA_CHECK(cudaGraphicsMapResources(1, &m_cuda_gfx_resource, m_stream)); + CUDA_CHECK(cudaGraphicsResourceGetMappedPointer( + reinterpret_cast(&m_device_pixels), &buffer_size, m_cuda_gfx_resource)); + + return m_device_pixels; +} + +template +void CUDAOutputBuffer::Unmap() { + makeCurrent(); + + CUDA_CHECK(cudaGraphicsUnmapResources(1, &m_cuda_gfx_resource, m_stream)); +} + +template +GLuint CUDAOutputBuffer::getPBO() { + if (m_pbo == 0u) + GL_CHECK(glGenBuffers(1, &m_pbo)); + return m_pbo; +} + +template +void CUDAOutputBuffer::deletePBO() { + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0)); + GL_CHECK(glDeleteBuffers(1, &m_pbo)); + m_pbo = 0; +} + +template +void CUDAOutputBuffer::StartAsynchronousReadback() { + CHECK(!readbackActive); + + makeCurrent(); + + CUDA_CHECK(cudaMemcpyAsync(m_host_pixels, m_device_pixels, + m_width * m_height * sizeof(PIXEL_FORMAT), + cudaMemcpyDeviceToHost)); + CUDA_CHECK(cudaEventRecord(readbackFinishedEvent)); + readbackActive = true; +} + +template +const PIXEL_FORMAT *CUDAOutputBuffer::GetReadbackPixels() { + if (!readbackActive) + return nullptr; + + makeCurrent(); + + CUDA_CHECK(cudaEventSynchronize(readbackFinishedEvent)); + readbackActive = false; + return m_host_pixels; +} + +} // end namespace pbrt + +#undef GL_CHECK +#undef GL_CHECK_ERRORS + +#endif // PBRT_GPU_CUDAGL_H diff --git a/src/pbrt/options.cpp b/src/pbrt/options.cpp index 608a58aaa..9c7e522b3 100644 --- a/src/pbrt/options.cpp +++ b/src/pbrt/options.cpp @@ -36,14 +36,14 @@ std::string PBRTOptions::ToString() const { return StringPrintf( "[ PBRTOptions seed: %s quiet: %s disablePixelJitter: %s " "disableWavelengthJitter: %s disableTextureFiltering: %s forceDiffuse: %s " - "useGPU: %s wavefront: %s renderingSpace: %s nThreads: %s logLevel: %s logFile: " + "useGPU: %s wavefront: %s interactive: %s renderingSpace: %s nThreads: %s logLevel: %s logFile: " "%s logUtilization: %s writePartialImages: %s recordPixelStatistics: %s " "printStatistics: %s pixelSamples: %s gpuDevice: %s quickRender: %s upgrade: %s " "imageFile: %s mseReferenceImage: %s mseReferenceOutput: %s debugStart: %s " "displayServer: %s cropWindow: %s pixelBounds: %s pixelMaterial: %s " "displacementEdgeScale: %f ]", seed, quiet, disablePixelJitter, disableWavelengthJitter, disableTextureFiltering, - forceDiffuse, useGPU, wavefront, renderingSpace, nThreads, logLevel, logFile, + forceDiffuse, useGPU, wavefront, interactive, renderingSpace, nThreads, logLevel, logFile, logUtilization, writePartialImages, recordPixelStatistics, printStatistics, pixelSamples, gpuDevice, quickRender, upgrade, imageFile, mseReferenceImage, mseReferenceOutput, debugStart, displayServer, cropWindow, pixelBounds, diff --git a/src/pbrt/options.h b/src/pbrt/options.h index c05094c66..3f1a4be37 100644 --- a/src/pbrt/options.h +++ b/src/pbrt/options.h @@ -27,6 +27,7 @@ struct BasicPBRTOptions { bool forceDiffuse = false; bool useGPU = false; bool wavefront = false; + bool interactive = false; RenderingCoordinateSystem renderingSpace = RenderingCoordinateSystem::CameraWorld; }; diff --git a/src/pbrt/util/gui.cpp b/src/pbrt/util/gui.cpp new file mode 100644 index 000000000..920c28251 --- /dev/null +++ b/src/pbrt/util/gui.cpp @@ -0,0 +1,251 @@ +// 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 + +#include + +#include +#ifdef PBRT_BUILD_GPU_RENDERER +#include +#endif // PBRT_BUILD_GPU_RENDERER +#include +#include +#include + +#define GL_CHECK(call) \ + do { \ + call; \ + if (GLenum err = glGetError(); err != GL_NO_ERROR) \ + LOG_FATAL("GL error: %s for " #call, getGLErrorString(err)); \ + } while (0) + +#define GL_CHECK_ERRORS() \ + do { \ + if (GLenum err = glGetError(); err != GL_NO_ERROR) \ + LOG_FATAL("GL error: %s", getGLErrorString(err)); \ + } while (0) + +namespace pbrt { + +const char *getGLErrorString(GLenum error) { + switch (error) { + case GL_NO_ERROR: + return "No error"; + case GL_INVALID_ENUM: + return "Invalid enum"; + case GL_INVALID_VALUE: + return "Invalid value"; + case GL_INVALID_OPERATION: + return "Invalid operation"; + case GL_OUT_OF_MEMORY: + return "Out of memory"; + default: + return "Unknown GL error"; + } +} + +static void glfwErrorCallback(int error, const char *desc) { + LOG_ERROR("GLFW [%d]: %s", error, desc); +} + +void GUI::keyboardCallback(GLFWwindow *window, int key, int scan, int action, int mods) { + if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) + glfwSetWindowShouldClose(window, GLFW_TRUE); + + auto doKey = [&](int k, char ch) { + if (key == k) { + if (action == GLFW_PRESS) + keysDown.insert(ch); + else if (action == GLFW_RELEASE) { + if (auto iter = keysDown.find(ch); iter != keysDown.end()) + keysDown.erase(iter); + } + } + }; + + doKey(GLFW_KEY_A, 'a'); + doKey(GLFW_KEY_D, 'd'); + doKey(GLFW_KEY_S, 's'); + doKey(GLFW_KEY_W, 'w'); + doKey(GLFW_KEY_Q, 'q'); + doKey(GLFW_KEY_E, 'e'); + + doKey(GLFW_KEY_B, (mods & GLFW_MOD_SHIFT) ? 'B' : 'b'); + doKey(GLFW_KEY_C, 'c'); + doKey(GLFW_KEY_EQUAL, '='); + doKey(GLFW_KEY_MINUS, '-'); + + doKey(GLFW_KEY_LEFT, 'L'); + doKey(GLFW_KEY_RIGHT, 'R'); + doKey(GLFW_KEY_UP, 'U'); + doKey(GLFW_KEY_DOWN, 'D'); + + if (key == GLFW_KEY_R && action == GLFW_PRESS && + glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) + recordFrames = !recordFrames; + else + doKey(GLFW_KEY_R, 'r'); +} + +bool GUI::processKeys() { + bool needsReset = false; + + auto handleNeedsReset = [&](char key, std::function update) { + if (keysDown.find(key) != keysDown.end()) { + movingFromCamera = update(movingFromCamera); + needsReset = true; + } + }; + + handleNeedsReset( + 'a', [&](Transform t) { return t * Translate(Vector3f(-moveScale, 0, 0)); }); + handleNeedsReset( + 'd', [&](Transform t) { return t * Translate(Vector3f(moveScale, 0, 0)); }); + handleNeedsReset( + 's', [&](Transform t) { return t * Translate(Vector3f(0, 0, -moveScale)); }); + handleNeedsReset( + 'w', [&](Transform t) { return t * Translate(Vector3f(0, 0, moveScale)); }); + handleNeedsReset( + 'q', [&](Transform t) { return t * Translate(Vector3f(0, -moveScale, 0)); }); + handleNeedsReset( + 'e', [&](Transform t) { return t * Translate(Vector3f(0, moveScale, 0)); }); + handleNeedsReset('L', + [&](Transform t) { return t * Rotate(-.5f, Vector3f(0, 1, 0)); }); + handleNeedsReset('R', + [&](Transform t) { return t * Rotate(.5f, Vector3f(0, 1, 0)); }); + handleNeedsReset('U', + [&](Transform t) { return t * Rotate(-.5f, Vector3f(1, 0, 0)); }); + handleNeedsReset('D', + [&](Transform t) { return t * Rotate(.5f, Vector3f(1, 0, 0)); }); + handleNeedsReset('r', [&](Transform t) { return Transform(); }); + + // No reset needed for these. + if (keysDown.find('c') != keysDown.end()) { + keysDown.erase(keysDown.find('c')); + printCameraTransform = true; + } + if (keysDown.find('b') != keysDown.end()) { + keysDown.erase(keysDown.find('b')); + exposure *= 1.125f; + } + if (keysDown.find('B') != keysDown.end()) { + keysDown.erase(keysDown.find('B')); + exposure /= 1.125f; + } + if (keysDown.find('=') != keysDown.end()) { + keysDown.erase(keysDown.find('=')); + moveScale *= 2; + } + if (keysDown.find('-') != keysDown.end()) { + keysDown.erase(keysDown.find('-')); + moveScale *= 0.5; + } + + return needsReset; +} + +static void glfwKeyCallback(GLFWwindow* window, int key, int scan, int action, int mods) { + GUI* gui = (GUI*)glfwGetWindowUserPointer(window); + gui->keyboardCallback(window, key, scan, action, mods); +} + +GUI::GUI(std::string title, Vector2i resolution, Bounds3f sceneBounds) + : resolution(resolution) { + moveScale = Length(sceneBounds.Diagonal()) / 1000.f; + + glfwSetErrorCallback(glfwErrorCallback); + if (!glfwInit()) + LOG_FATAL("Unable to initialize GLFW"); + window = glfwCreateWindow(resolution.x, resolution.y, "pbrt", NULL, NULL); + if (!window) { + glfwTerminate(); + LOG_FATAL("Unable to create GLFW window"); + } + glfwSetKeyCallback(window, glfwKeyCallback); + glfwSetWindowUserPointer(window, this); + glfwMakeContextCurrent(window); + + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + + if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) + LOG_FATAL("gladLoadGLLoader failed"); + +#ifdef PBRT_BUILD_GPU_RENDERER + if (Options->useGPU) + cudaFramebuffer = new CUDAOutputBuffer(resolution.x, resolution.y); + else +#endif // PBRT_BUILD_GPU_RENDERER + cpuFramebuffer = new RGB[resolution.x * resolution.y]; +} + +GUI::~GUI() { +#ifdef PBRT_BUILD_GPU_RENDERER + delete cudaFramebuffer; +#endif // PBRT_BUILD_GPU_RENDERER + delete[] cpuFramebuffer; + + glfwDestroyWindow(window); + glfwTerminate(); +} + +DisplayState GUI::RefreshDisplay() { + int width, height; + glfwGetFramebufferSize(window, &width, &height); + GL_CHECK(glViewport(0, 0, width, height)); + +#ifdef PBRT_BUILD_GPU_RENDERER + if (Options->useGPU) + cudaFramebuffer->Draw(width, height); + else +#endif // PBRT_BUILD_GPU_RENDERER + { + GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB)); + GL_CHECK(glRasterPos2f(-1, 1)); + GL_CHECK(glPixelZoom(1, -1)); + GL_CHECK( + glDrawPixels(resolution.x, resolution.y, GL_RGB, GL_FLOAT, cpuFramebuffer)); + } + + glfwSwapBuffers(window); + glfwPollEvents(); + + if (recordFrames) { + const RGB *fb = nullptr; +#ifdef PBRT_BUILD_GPU_RENDERER + if (cudaFramebuffer) + fb = cudaFramebuffer->GetReadbackPixels(); + else +#endif + fb = cpuFramebuffer; + + if (fb) { + Image image(PixelFormat::Float, {width, height}, {"R", "G", "B"}); + std::memcpy(image.RawPointer({0, 0}), fb, width * height * sizeof(RGB)); + + RunAsync([](Image image, int frameNumber) { + // TODO: set metadata for e.g. current camera position... + ImageMetadata metadata; + image.Write(StringPrintf("pbrt-frame%05d.exr", frameNumber), metadata); + return 0; // FIXME: RunAsync() doesn't like lambdas that return void.. + }, std::move(image), frameNumber); + + ++frameNumber; + } +#ifdef PBRT_BUILD_GPU_RENDERER + if (cudaFramebuffer) + cudaFramebuffer->StartAsynchronousReadback(); +#endif + } + + if (glfwWindowShouldClose(window)) + return DisplayState::EXIT; + else if (processKeys()) + return DisplayState::RESET; + else + return DisplayState::NONE; +} + +} // namespace pbrt diff --git a/src/pbrt/util/gui.h b/src/pbrt/util/gui.h new file mode 100644 index 000000000..a67834e19 --- /dev/null +++ b/src/pbrt/util/gui.h @@ -0,0 +1,77 @@ +// 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 + +#ifndef PBRT_UTIL_GUI_H +#define PBRT_UTIL_GUI_H + +#include +#include + +#include + +#ifdef PBRT_BUILD_GPU_RENDERER +#include +#endif // PBRT_BUILD_GPU_RENDERER +#include +#include +#include + +#include +#include + +namespace pbrt { + +enum DisplayState { EXIT, RESET, NONE }; + +class GUI { + public: + GUI(std::string title, Vector2i resolution, Bounds3f sceneBounds); + ~GUI(); + + RGB *MapFramebuffer() { +#ifdef PBRT_BUILD_GPU_RENDERER + if (cudaFramebuffer) + return cudaFramebuffer->Map(); + else +#endif // PBRT_BUILD_GPU_RENDERER + return cpuFramebuffer; + } + void UnmapFramebuffer() { +#ifdef PBRT_BUILD_GPU_RENDERER + if (cudaFramebuffer) + cudaFramebuffer->Unmap(); +#endif // PBRT_BUILD_GPU_RENDERER + } + + DisplayState RefreshDisplay(); + + // It's a little messy that the state of values controlled via the UI + // are just public variables here but it's probably not worth putting + // an abstraction layer on top of all this at this point. + Transform GetCameraTransform() const { return movingFromCamera; } + Float exposure = 1.f; + bool printCameraTransform = false; + + void keyboardCallback(GLFWwindow *window, int key, int scan, int action, int mods); + + private: + bool processKeys(); + + std::set keysDown; + Float moveScale = 1.f; + Transform movingFromCamera; + Vector2i resolution; + bool recordFrames = false; + int frameNumber = 0; + +#ifdef PBRT_BUILD_GPU_RENDERER + CUDAOutputBuffer *cudaFramebuffer = nullptr; +#endif + RGB *cpuFramebuffer = nullptr; + GLFWwindow *window = nullptr; +}; + +} // namespace pbrt + +#endif // PBRT_UTIL_GUI_H diff --git a/src/pbrt/wavefront/camera.cpp b/src/pbrt/wavefront/camera.cpp index a1a1722cd..9f759f5b1 100644 --- a/src/pbrt/wavefront/camera.cpp +++ b/src/pbrt/wavefront/camera.cpp @@ -15,20 +15,22 @@ namespace pbrt { // WavefrontPathIntegrator Camera Ray Methods -void WavefrontPathIntegrator::GenerateCameraRays(int y0, int sampleIndex) { +void WavefrontPathIntegrator::GenerateCameraRays(int y0, Transform movingFromCamera, + int sampleIndex) { // Define _generateRays_ lambda function auto generateRays = [=](auto sampler) { using ConcreteSampler = std::remove_reference_t; if constexpr (!std::is_same_v && !std::is_same_v) - GenerateCameraRays(y0, sampleIndex); + GenerateCameraRays(y0, movingFromCamera, sampleIndex); }; sampler.DispatchCPU(generateRays); } template -void WavefrontPathIntegrator::GenerateCameraRays(int y0, int sampleIndex) { +void WavefrontPathIntegrator::GenerateCameraRays(int y0, Transform movingFromCamera, + int sampleIndex) { RayQueue *rayQueue = CurrentRayQueue(0); ParallelFor( "Generate camera rays", maxQueueSize, PBRT_CPU_GPU_LAMBDA(int pixelIndex) { @@ -58,6 +60,8 @@ void WavefrontPathIntegrator::GenerateCameraRays(int y0, int sampleIndex) { CameraSample cameraSample = GetCameraSample(pixelSampler, pPixel, filter); pstd::optional cameraRay = camera.GenerateRay(cameraSample, lambda); + if (cameraRay) + cameraRay->ray = movingFromCamera(cameraRay->ray); // Initialize remainder of _PixelSampleState_ for ray pixelSampleState.L[pixelIndex] = SampledSpectrum(0.f); diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index da2c72ddc..7ea7166b1 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -286,6 +287,18 @@ WavefrontPathIntegrator::WavefrontPathIntegrator( Float WavefrontPathIntegrator::Render() { Bounds2i pixelBounds = film.PixelBounds(); Vector2i resolution = pixelBounds.Diagonal(); + + GUI *gui = nullptr; + // FIXME: camera animation; whatever... + Transform renderFromCamera = camera.GetCameraTransform().RenderFromCamera().startTransform; + Transform cameraFromRender = Inverse(renderFromCamera); + Transform cameraFromWorld = camera.GetCameraTransform().CameraFromWorld(camera.SampleTime(0.f)); + if (Options->interactive) { + if (!Options->displayServer.empty()) + ErrorExit("--interactive and --display-server cannot be used at the same time."); + gui = new GUI(film.GetFilename(), resolution, aggregate->Bounds()); + } + Timer timer; // Prefetch allocations to GPU memory #ifdef PBRT_BUILD_GPU_RENDERER @@ -313,9 +326,8 @@ Float WavefrontPathIntegrator::Render() { } ProgressReporter progress(lastSampleIndex - firstSampleIndex, "Rendering", - Options->quiet, Options->useGPU); - for (int sampleIndex = firstSampleIndex; sampleIndex < lastSampleIndex; - ++sampleIndex) { + Options->quiet || Options->interactive, Options->useGPU); + for (int sampleIndex = firstSampleIndex; sampleIndex < lastSampleIndex; ++sampleIndex) { // Attempt to work around issue #145. #if !(defined(PBRT_IS_WINDOWS) && defined(PBRT_BUILD_GPU_RENDERER) && \ __CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ == 1) @@ -338,7 +350,11 @@ Float WavefrontPathIntegrator::Render() { sampleIndex, samplesPerPixel); cameraRayQueue->Reset(); }); - GenerateCameraRays(y0, sampleIndex); + + Transform cameraMotion; + if (gui) + cameraMotion = renderFromCamera * gui->GetCameraTransform() * cameraFromRender; + GenerateCameraRays(y0, cameraMotion, sampleIndex); Do( "Update camera ray stats", PBRT_CPU_GPU_LAMBDA() { stats->cameraRays += cameraRayQueue->Size(); }); @@ -396,7 +412,7 @@ Float WavefrontPathIntegrator::Render() { if (wavefrontDepth == maxDepth) break; - EvaluateMaterialsAndBSDFs(wavefrontDepth); + EvaluateMaterialsAndBSDFs(wavefrontDepth, cameraMotion); // Do immediately so that we have space for shadow rays for subsurface.. TraceShadowRays(wavefrontDepth); @@ -405,12 +421,48 @@ Float WavefrontPathIntegrator::Render() { } UpdateFilm(); - // Copy updated film pixels to buffer for display - UpdateDisplay(resolution); + } + + // Copy updated film pixels to buffer for the display server. + if (Options->useGPU && !Options->displayServer.empty()) + UpdateDisplayRGBFromFilm(pixelBounds); + + if (gui) { + RGB *rgb = gui->MapFramebuffer(); + UpdateFramebufferFromFilm(pixelBounds, gui->exposure, rgb); + gui->UnmapFramebuffer(); + + if (gui->printCameraTransform) { + SquareMatrix<4> cfw = (Inverse(gui->GetCameraTransform()) * cameraFromWorld).GetMatrix(); + Printf("Current camera transform:\nTransform [ "); + for (int i = 0; i < 16; ++i) + Printf("%f ", cfw[i % 4][i / 4]); + Printf("]\n"); + std::fflush(stdout); + gui->printCameraTransform = false; + } + + DisplayState state = gui->RefreshDisplay(); + if (state == DisplayState::EXIT) + break; + else if (state == DisplayState::RESET) { + sampleIndex = firstSampleIndex - 1; + ParallelFor("Reset pixels", resolution.x * resolution.y, + PBRT_CPU_GPU_LAMBDA(int i) { + int x = i % resolution.x, y = i / resolution.x; + film.ResetPixel(pixelBounds.pMin + Vector2i(x, y)); + }); + } } progress.Update(); } + + if (gui) { + delete gui; + gui = nullptr; + } + progress.Done(); #ifdef PBRT_BUILD_GPU_RENDERER @@ -650,19 +702,15 @@ void WavefrontPathIntegrator::StartDisplayThread() { }); } -void WavefrontPathIntegrator::UpdateDisplay(Vector2i resolution) { +void WavefrontPathIntegrator::UpdateDisplayRGBFromFilm(Bounds2i pixelBounds) { #ifdef PBRT_BUILD_GPU_RENDERER - if (Options->useGPU && !Options->displayServer.empty()) - GPUParallelFor( - "Update Display RGB Buffer", maxQueueSize, - PBRT_CPU_GPU_LAMBDA(int pixelIndex) { - Point2i pPixel = pixelSampleState.pPixel[pixelIndex]; - if (!InsideExclusive(pPixel, film.PixelBounds())) - return; - - Point2i p(pPixel - film.PixelBounds().pMin); - displayRGB[p.x + p.y * resolution.x] = film.GetPixelRGB(pPixel); - }); + Vector2i resolution = pixelBounds.Diagonal(); + GPUParallelFor( + "Update Display RGB Buffer", resolution.x * resolution.y, + PBRT_CPU_GPU_LAMBDA(int index) { + Point2i p(index % resolution.x, index / resolution.x); + displayRGB[index] = film.GetPixelRGB(p + pixelBounds.pMin); + }); #endif // PBRT_BUILD_GPU_RENDERER } @@ -685,4 +733,14 @@ void WavefrontPathIntegrator::StopDisplayThread() { #endif // PBRT_BUILD_GPU_RENDERER } +void WavefrontPathIntegrator::UpdateFramebufferFromFilm(Bounds2i pixelBounds, Float exposure, + RGB *rgb) { + Vector2i resolution = pixelBounds.Diagonal(); + ParallelFor("Update framebuffer", resolution.x * resolution.y, + PBRT_CPU_GPU_LAMBDA(int index) { + Point2i p(index % resolution.x, index / resolution.x); + rgb[index] = exposure * film.GetPixelRGB(p + film.PixelBounds().pMin); + }); +} + } // namespace pbrt diff --git a/src/pbrt/wavefront/integrator.h b/src/pbrt/wavefront/integrator.h index 46267e202..ecfa5558e 100644 --- a/src/pbrt/wavefront/integrator.h +++ b/src/pbrt/wavefront/integrator.h @@ -26,6 +26,7 @@ namespace pbrt { class BasicScene; +class GUI; // WavefrontAggregate Definition class WavefrontAggregate { @@ -58,9 +59,10 @@ class WavefrontPathIntegrator { // WavefrontPathIntegrator Public Methods Float Render(); - void GenerateCameraRays(int y0, int sampleIndex); + void GenerateCameraRays(int y0, Transform movingFromcamera, + int sampleIndex); template - void GenerateCameraRays(int y0, int sampleIndex); + void GenerateCameraRays(int y0, Transform movingFromCamera, int sampleIndex); void GenerateRaySamples(int wavefrontDepth, int sampleIndex); template @@ -75,11 +77,12 @@ class WavefrontPathIntegrator { void HandleEscapedRays(); void HandleEmissiveIntersection(); - void EvaluateMaterialsAndBSDFs(int wavefrontDepth); + void EvaluateMaterialsAndBSDFs(int wavefrontDepth, Transform movingFromCamera); template - void EvaluateMaterialAndBSDF(int wavefrontDepth); + void EvaluateMaterialAndBSDF(int wavefrontDepth, Transform movingFromCamera); template - void EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQueue, int wavefrontDepth); + void EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQueue, Transform movingFromCamera, + int wavefrontDepth); void UpdateFilm(); @@ -121,10 +124,14 @@ class WavefrontPathIntegrator { void PrefetchGPUAllocations(); #endif // PBRT_BUILD_GPU_RENDERER + // --display-server methods void StartDisplayThread(); - void UpdateDisplay(Vector2i resolution); + void UpdateDisplayRGBFromFilm(Bounds2i pixelBounds); void StopDisplayThread(); + // --interactive support + void UpdateFramebufferFromFilm(Bounds2i pixelBounds, Float exposure, RGB *rgb); + // WavefrontPathIntegrator Member Variables bool initializeVisibleSurface; bool haveSubsurface; diff --git a/src/pbrt/wavefront/surfscatter.cpp b/src/pbrt/wavefront/surfscatter.cpp index 0bf146c8c..3a6dafda7 100644 --- a/src/pbrt/wavefront/surfscatter.cpp +++ b/src/pbrt/wavefront/surfscatter.cpp @@ -25,33 +25,35 @@ namespace pbrt { struct EvaluateMaterialCallback { int wavefrontDepth; WavefrontPathIntegrator *integrator; + Transform movingFromCamera; // EvaluateMaterialCallback Public Methods template void operator()() { if constexpr (!std::is_same_v) - integrator->EvaluateMaterialAndBSDF(wavefrontDepth); + integrator->EvaluateMaterialAndBSDF(wavefrontDepth, movingFromCamera); } }; // WavefrontPathIntegrator Surface Scattering Methods -void WavefrontPathIntegrator::EvaluateMaterialsAndBSDFs(int wavefrontDepth) { - ForEachType(EvaluateMaterialCallback{wavefrontDepth, this}, Material::Types()); +void WavefrontPathIntegrator::EvaluateMaterialsAndBSDFs(int wavefrontDepth, Transform movingFromCamera) { + ForEachType(EvaluateMaterialCallback{wavefrontDepth, this, movingFromCamera}, + Material::Types()); } template -void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(int wavefrontDepth) { +void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(int wavefrontDepth, Transform movingFromCamera) { int index = Material::TypeIndex(); if (haveBasicEvalMaterial[index]) EvaluateMaterialAndBSDF( - basicEvalMaterialQueue, wavefrontDepth); + basicEvalMaterialQueue, movingFromCamera, wavefrontDepth); if (haveUniversalEvalMaterial[index]) EvaluateMaterialAndBSDF( - universalEvalMaterialQueue, wavefrontDepth); + universalEvalMaterialQueue, movingFromCamera, wavefrontDepth); } template void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQueue, - int wavefrontDepth) { + Transform movingFromCamera, int wavefrontDepth) { // Get BSDF for items in _evalQueue_ and sample illumination // Construct _desc_ for material/texture evaluation kernel std::string desc = StringPrintf( @@ -69,7 +71,9 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue Vector3f dpdx, dpdy; Float dudx = 0, dudy = 0, dvdx = 0, dvdy = 0; if (!GetOptions().disableTextureFiltering) { - camera.Approximate_dp_dxy(Point3f(w.pi), w.n, w.time, samplesPerPixel, + Point3f pc = movingFromCamera.ApplyInverse(Point3f(w.pi)); + Normal3f nc = movingFromCamera.ApplyInverse(w.n); + camera.Approximate_dp_dxy(pc, nc, w.time, samplesPerPixel, &dpdx, &dpdy); Vector3f dpdu = w.dpdu, dpdv = w.dpdv; // Estimate screen-space change in $(u,v)$ From 523f7a425e8243b39f41d3e686cbe246620082ad Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 26 Apr 2022 06:37:36 -0700 Subject: [PATCH 030/149] Add glfw submodule (lost in the merges) --- src/ext/glfw | 1 + 1 file changed, 1 insertion(+) create mode 160000 src/ext/glfw diff --git a/src/ext/glfw b/src/ext/glfw new file mode 160000 index 000000000..4cb36872a --- /dev/null +++ b/src/ext/glfw @@ -0,0 +1 @@ +Subproject commit 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0 From 0eb8526777f16d431c6a54e2f105ad39cc50d60b Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 26 Apr 2022 06:42:09 -0700 Subject: [PATCH 031/149] Update expected glfw revision --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d79d59ef0..fcaf1c70d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ check_ext ("OpenVDB" "openvdb/nanovdb" 414bed84c2fc22e188eac7b611aa85c7edd7a5a9) check_ext ("Ptex" "ptex/src" 4cd8e9a6db2b06e478dfbbd8c26eb6df97f84483) check_ext ("double-conversion" "double-conversion/cmake" cc1f75a114aca8d2af69f73a5a959aecbab0e87a) check_ext ("filesystem" "filesystem/filesystem" c5f9de30142453eb3c6fe991e82dfc2583373116) -check_ext ("glfw" "glfw/docs" 9cc252a406b79c31ab82648a21b715e2d3fc7ece) +check_ext ("glfw" "glfw/docs" 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0) check_ext ("libdeflate" "libdeflate/common" 1fd0bea6ca2073c68493632dafc4b1ddda1bcbc3) check_ext ("lodepng" "lodepng/examples" 8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a) check_ext ("qoi" "qoi" 028c75fd26e5e0758c7c711216c00404994c1ad3) From 6a9e0c49518ab0b0931c8671d90e7bcf5a994f79 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 28 Apr 2022 06:06:16 -0700 Subject: [PATCH 032/149] Fix TaggedPointer for 32-bit targets Fixes Issue #239. --- src/pbrt/util/taggedptr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pbrt/util/taggedptr.h b/src/pbrt/util/taggedptr.h index 6e612b52d..966775afe 100644 --- a/src/pbrt/util/taggedptr.h +++ b/src/pbrt/util/taggedptr.h @@ -687,10 +687,10 @@ class TaggedPointer { TaggedPointer() = default; template PBRT_CPU_GPU TaggedPointer(T *ptr) { - uintptr_t iptr = reinterpret_cast(ptr); + uint64_t iptr = reinterpret_cast(ptr); DCHECK_EQ(iptr & ptrMask, iptr); constexpr unsigned int type = TypeIndex(); - bits = iptr | ((uintptr_t)type << tagShift); + bits = iptr | ((uint64_t)type << tagShift); } PBRT_CPU_GPU @@ -803,13 +803,13 @@ class TaggedPointer { } private: - static_assert(sizeof(uintptr_t) == 8, "Expected uintptr_t to be 64 bits"); + static_assert(sizeof(uintptr_t) <= sizeof(uint64_t), "Expected pointer size to be <= 64 bits"); // TaggedPointer Private Members static constexpr int tagShift = 57; static constexpr int tagBits = 64 - tagShift; static constexpr uint64_t tagMask = ((1ull << tagBits) - 1) << tagShift; static constexpr uint64_t ptrMask = ~tagMask; - uintptr_t bits = 0; + uint64_t bits = 0; }; } // namespace pbrt From adc9c8cbd82152c8dc0394779f2b7b2f249d6bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E5=B0=91=E9=94=9F?= Date: Thu, 28 Apr 2022 21:39:21 +0800 Subject: [PATCH 033/149] Fix interactive display when window size and framebuffer size mismatch on high-dpi monitors (#244) --- src/pbrt/util/gui.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pbrt/util/gui.cpp b/src/pbrt/util/gui.cpp index 920c28251..8a350ed77 100644 --- a/src/pbrt/util/gui.cpp +++ b/src/pbrt/util/gui.cpp @@ -194,7 +194,11 @@ GUI::~GUI() { DisplayState GUI::RefreshDisplay() { int width, height; glfwGetFramebufferSize(window, &width, &height); + int windowWidth, windowHeight; + glfwGetWindowSize(window, &windowWidth, &windowHeight); GL_CHECK(glViewport(0, 0, width, height)); + float pixelScales[2] = {(float)width / (float)windowWidth, + (float)height / (float)windowHeight}; #ifdef PBRT_BUILD_GPU_RENDERER if (Options->useGPU) @@ -204,7 +208,7 @@ DisplayState GUI::RefreshDisplay() { { GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB)); GL_CHECK(glRasterPos2f(-1, 1)); - GL_CHECK(glPixelZoom(1, -1)); + GL_CHECK(glPixelZoom(pixelScales[0], -pixelScales[1])); GL_CHECK( glDrawPixels(resolution.x, resolution.y, GL_RGB, GL_FLOAT, cpuFramebuffer)); } From d873c89c6369aa2ab7fa11f6bea916197931af68 Mon Sep 17 00:00:00 2001 From: Lin Hsu Date: Fri, 29 Apr 2022 12:49:19 -0700 Subject: [PATCH 034/149] Fix process of directly visible light for LightPathIntegrator (#245) * Reverse direction for PDF_Li to intersect with light * Fix L computation of directly visible light for LightPathIntegrator --- src/pbrt/cpu/integrators.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index 53de75dcc..f76a810c0 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -535,13 +535,13 @@ void LightPathIntegrator::EvaluatePixelSample(Point2i pPixel, int sampleIndex, pstd::optional cs = camera.SampleWi(*les->intr, sampler.Get2D(), lambda); if (cs && cs->pdf != 0) { - if (Float pdf = light.PDF_Li(cs->pLens, cs->wi); pdf > 0) { + if (Float pdf = light.PDF_Li(cs->pLens, -cs->wi); pdf > 0) { // Add light's emitted radiance if nonzero and light is visible SampledSpectrum Le = light.L(les->intr->p(), les->intr->n, les->intr->uv, cs->wi, lambda); if (Le && Unoccluded(cs->pRef, cs->pLens)) { // Compute visible light's path contribution and add to film - SampledSpectrum L = Le * les->AbsCosTheta(cs->wi) * cs->Wi / + SampledSpectrum L = Le * DistanceSquared(cs->pRef.p(), cs->pLens.p()) * cs->Wi / (lightPDF * pdf * cs->pdf); camera.GetFilm().AddSplat(cs->pRaster, L, lambda); } From 2c5fdee1854d8bcf52b7573f4677d1797abd2ae3 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 29 Apr 2022 13:35:09 -0700 Subject: [PATCH 035/149] Fix --display-server with PBRT_FLOAT_AS_DOUBLE builds --- src/pbrt/cpu/integrators.cpp | 6 +++--- src/pbrt/util/display.cpp | 18 +++++++++--------- src/pbrt/util/display.h | 12 ++++++------ src/pbrt/wavefront/integrator.cpp | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index f76a810c0..550fbc76a 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -146,7 +146,7 @@ void ImageTileIntegrator::Render() { Film film = camera.GetFilm(); DisplayDynamic(film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, - [&](Bounds2i b, pstd::span> displayValue) { + [&](Bounds2i b, pstd::span> displayValue) { int index = 0; for (Point2i p : b) { RGB rgb = film.GetPixelRGB(pixelBounds.pMin + p, @@ -2585,7 +2585,7 @@ void MLTIntegrator::Render() { DisplayDynamic( camera.GetFilm().GetFilename(), Point2i(camera.GetFilm().PixelBounds().Diagonal()), {"R", "G", "B"}, - [&](Bounds2i bounds, pstd::span> displayValue) { + [&](Bounds2i bounds, pstd::span> displayValue) { Film film = camera.GetFilm(); Bounds2i pixelBounds = film.PixelBounds(); int index = 0; @@ -2808,7 +2808,7 @@ void SPPMIntegrator::Render() { if (iter == 0 && !Options->displayServer.empty()) { DisplayDynamic( film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, - [&](Bounds2i b, pstd::span> displayValue) { + [&](Bounds2i b, pstd::span> displayValue) { int index = 0; uint64_t np = (uint64_t)(iter + 1) * (uint64_t)photonsPerIteration; for (Point2i pPixel : b) { diff --git a/src/pbrt/util/display.cpp b/src/pbrt/util/display.cpp index 05fee4a38..c0ff70da1 100644 --- a/src/pbrt/util/display.cpp +++ b/src/pbrt/util/display.cpp @@ -233,7 +233,7 @@ class DisplayItem { DisplayItem( const std::string &title, Point2i resolution, std::vector channelNames, - std::function>)> getTileValues); + std::function>)> getTileValues); bool Display(IPCChannel &channel); @@ -243,7 +243,7 @@ class DisplayItem { bool openedImage = false; std::string title; Point2i resolution; - std::function>)> getTileValues; + std::function>)> getTileValues; std::vector channelNames; struct ImageChannelBuffer { @@ -265,7 +265,7 @@ class DisplayItem { DisplayItem::DisplayItem( const std::string &baseTitle, Point2i resolution, std::vector channelNames, - std::function>)> getTileValues) + std::function>)> getTileValues) : resolution(resolution), getTileValues(getTileValues), channelNames(channelNames) { #ifdef PBRT_IS_WINDOWS title = StringPrintf("%s (%d)", baseTitle, GetCurrentThreadId()); @@ -298,7 +298,7 @@ DisplayItem::ImageChannelBuffer::ImageChannelBuffer(const std::string &channelNa tileBoundsOffset = ptr - buffer.data(); // Note: may not be float-aligned, but that's not a problem on x86... // TODO: fix this. The problem is that it breaks the whole idea of - // passing a span to the callback function... + // passing a span to the callback function... channelValuesOffset = tileBoundsOffset + 4 * sizeof(int); // Zero-initialize the buffer color contents before computing the hash @@ -349,9 +349,9 @@ bool DisplayItem::Display(IPCChannel &ipcChannel) { openedImage = true; } - std::vector> displayValues(channelBuffers.size()); + std::vector> displayValues(channelBuffers.size()); for (int c = 0; c < channelBuffers.size(); ++c) { - Float *ptr = (Float *)(channelBuffers[c].buffer.data() + + float *ptr = (float *)(channelBuffers[c].buffer.data() + channelBuffers[c].channelValuesOffset); displayValues[c] = pstd::MakeSpan(ptr, tileSize * tileSize); } @@ -446,7 +446,7 @@ void DisconnectFromDisplayServer() { static DisplayItem GetImageDisplayItem(const std::string &title, const Image &image, pstd::optional channelDesc) { - auto getValues = [=](Bounds2i b, pstd::span> displayValues) { + auto getValues = [=](Bounds2i b, pstd::span> displayValues) { int offset = 0; for (Point2i p : b) { ImageChannelValues v = @@ -488,7 +488,7 @@ void DisplayDynamic(std::string title, const Image &image, void DisplayStatic(std::string title, Point2i resolution, std::vector channelNames, - std::function>)> getTileValues) { + std::function>)> getTileValues) { DisplayItem item(title, resolution, channelNames, getTileValues); std::lock_guard lock(mutex); @@ -498,7 +498,7 @@ void DisplayStatic(std::string title, Point2i resolution, void DisplayDynamic(std::string title, Point2i resolution, std::vector channelNames, - std::function>)> getTileValues) { + std::function>)> getTileValues) { std::lock_guard lock(mutex); dynamicItems.push_back(DisplayItem(title, resolution, channelNames, getTileValues)); } diff --git a/src/pbrt/util/display.h b/src/pbrt/util/display.h index dffb39556..4091e6ff6 100644 --- a/src/pbrt/util/display.h +++ b/src/pbrt/util/display.h @@ -25,11 +25,11 @@ void DisconnectFromDisplayServer(); void DisplayStatic( std::string title, Point2i resolution, std::vector channelNames, - std::function>)> getValues); + std::function>)> getValues); void DisplayDynamic( std::string title, Point2i resolution, std::vector channelNames, - std::function>)> getValues); + std::function>)> getValues); void DisplayStatic(std::string title, const Image &image, pstd::optional channelDesc = {}); @@ -42,7 +42,7 @@ inline typename std::enable_if_t::value, void> DisplayStat CHECK_EQ(0, values.size() % xResolution); int yResolution = values.size() / xResolution; DisplayStatic(title, {xResolution, yResolution}, {"value"}, - [=](Bounds2i b, pstd::span> displayValue) { + [=](Bounds2i b, pstd::span> displayValue) { DCHECK_EQ(1, displayValue.size()); int index = 0; for (Point2i p : b) @@ -56,7 +56,7 @@ inline typename std::enable_if_t::value, void> DisplayDyna CHECK_EQ(0, values.size() % xResolution); int yResolution = values.size() / xResolution; DisplayDynamic(title, {xResolution, yResolution}, {"value"}, - [=](Bounds2i b, pstd::span> displayValue) { + [=](Bounds2i b, pstd::span> displayValue) { DCHECK_EQ(1, displayValue.size()); int index = 0; for (Point2i p : b) @@ -91,7 +91,7 @@ DisplayStatic(const std::string &title, pstd::span values, CHECK_EQ(0, values.size() % xResolution); int yResolution = values.size() / xResolution; DisplayStatic(title, {xResolution, yResolution}, channelNames, - [=](Bounds2i b, pstd::span> displayValue) { + [=](Bounds2i b, pstd::span> displayValue) { DCHECK_EQ(channelNames.size(), displayValue.size()); int index = 0; for (Point2i p : b) { @@ -110,7 +110,7 @@ DisplayDynamic(const std::string &title, pstd::span values, CHECK_EQ(0, values.size() % xResolution); int yResolution = values.size() / xResolution; DisplayDynamic(title, {xResolution, yResolution}, channelNames, - [=](Bounds2i b, pstd::span> displayValue) { + [=](Bounds2i b, pstd::span> displayValue) { DCHECK_EQ(channelNames.size(), displayValue.size()); int index = 0; for (Point2i p : b) { diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index 7ea7166b1..14ae5d359 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -676,7 +676,7 @@ void WavefrontPathIntegrator::StartDisplayThread() { // sending messages to the display program (i.e., tev). DisplayDynamic(film.GetFilename(), {resolution.x, resolution.y}, {"R", "G", "B"}, - [resolution, this](Bounds2i b, pstd::span> displayValue) { + [resolution, this](Bounds2i b, pstd::span> displayValue) { int index = 0; for (Point2i p : b) { RGB rgb = displayRGBHost[p.x + p.y * resolution.x]; @@ -690,7 +690,7 @@ void WavefrontPathIntegrator::StartDisplayThread() { #endif // PBRT_BUILD_GPU_RENDERER DisplayDynamic(film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, [pixelBounds, this](Bounds2i b, - pstd::span> displayValue) { + pstd::span> displayValue) { int index = 0; for (Point2i p : b) { RGB rgb = From 4ac95e65705ae595774cabe92ae79cb1d437ac92 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 4 May 2022 14:22:20 -0700 Subject: [PATCH 036/149] Fix overflow bug in radical inverse functions When pbrt is compiled with Float=double, the uint64 used to store the reversed digits could overflow, which led to all sorts of interesting image artifacts due to non-uniform samples being returned by the HaltonSampler. --- src/pbrt/util/lowdiscrepancy.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/pbrt/util/lowdiscrepancy.h b/src/pbrt/util/lowdiscrepancy.h index 4fa3ad54e..60cd71d61 100644 --- a/src/pbrt/util/lowdiscrepancy.h +++ b/src/pbrt/util/lowdiscrepancy.h @@ -84,10 +84,13 @@ struct NoRandomizer { // Low Discrepancy Inline Functions PBRT_CPU_GPU inline Float RadicalInverse(int baseIndex, uint64_t a) { - int base = Primes[baseIndex]; + unsigned int base = Primes[baseIndex]; + // We have to stop once reversedDigits is >= limit since otherwise the + // next digit of |a| may cause reversedDigits to overflow. + uint64_t limit = ~0ull / base - base; Float invBase = (Float)1 / (Float)base, invBaseN = 1; uint64_t reversedDigits = 0; - while (a) { + while (a && reversedDigits < limit) { // Extract least significant digit from _a_ and update _reversedDigits_ uint64_t next = a / base; uint64_t digit = a - next * base; @@ -111,11 +114,14 @@ PBRT_CPU_GPU inline uint64_t InverseRadicalInverse(uint64_t inverse, int base, PBRT_CPU_GPU inline Float ScrambledRadicalInverse(int baseIndex, uint64_t a, const DigitPermutation &perm) { - int base = Primes[baseIndex]; + unsigned int base = Primes[baseIndex]; + // We have to stop once reversedDigits is >= limit since otherwise the + // next digit of |a| may cause reversedDigits to overflow. + uint64_t limit = ~0ull / base - base; Float invBase = (Float)1 / (Float)base, invBaseM = 1; uint64_t reversedDigits = 0; int digitIndex = 0; - while (1 - (base - 1) * invBaseM < 1) { + while (1 - (base - 1) * invBaseM < 1 && reversedDigits < limit) { // Permute least significant digit from _a_ and update _reversedDigits_ uint64_t next = a / base; int digitValue = a - next * base; @@ -129,11 +135,14 @@ PBRT_CPU_GPU inline Float ScrambledRadicalInverse(int baseIndex, uint64_t a, PBRT_CPU_GPU inline Float OwenScrambledRadicalInverse(int baseIndex, uint64_t a, uint32_t hash) { - int base = Primes[baseIndex]; + unsigned int base = Primes[baseIndex]; + // We have to stop once reversedDigits is >= limit since otherwise the + // next digit of |a| may cause reversedDigits to overflow. + uint64_t limit = ~0ull / base - base; Float invBase = (Float)1 / (Float)base, invBaseM = 1; uint64_t reversedDigits = 0; int digitIndex = 0; - while (1 - invBaseM < 1) { + while (1 - invBaseM < 1 && reversedDigits < limit) { // Compute Owen-scrambled digit for _digitIndex_ uint64_t next = a / base; int digitValue = a - next * base; From b5e9e7c91209feeaef6064a2881acba9d8cda62f Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 4 May 2022 14:55:28 -0700 Subject: [PATCH 037/149] Fix cuda pubkeys (#248) Fix GPU github actions build due to breakage from NVIDIA changing apt signing keys. --- .github/workflows/ci-gpu.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index 77cf5f057..d2c9533d0 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -24,6 +24,13 @@ jobs: runs-on: ${{ matrix.os }} steps: + # https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212772 + - name: Fetch new CUDA pubkey + if: ${{ matrix.os == 'ubuntu-20.04' }} + run: | + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb + sudo dpkg -i cuda-keyring_1.0-1_all.deb + - uses: mmp/cuda-toolkit@master id: cuda-toolkit with: From ef82b805816f93dde4fb3ab66111cb09bfc7f786 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 5 May 2022 05:50:02 -0700 Subject: [PATCH 038/149] Disable now-incorrect CHECK --- src/pbrt/util/pstd.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pbrt/util/pstd.cpp b/src/pbrt/util/pstd.cpp index 3e91bc847..7f0236f63 100644 --- a/src/pbrt/util/pstd.cpp +++ b/src/pbrt/util/pstd.cpp @@ -73,7 +73,12 @@ void *monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) { // via something like ThreadLocal; there are perfectly reasonably ways // of allocating these in one thread and using them in another thread, // so this is tied to pbrt's current usage of them... - CHECK(constructTID == std::this_thread::get_id()); + // + // (... and commented out since InternCache uses a single + // monotonic_buffer_resource across multiple threads but protects its + // use with a mutex.) + // + //CHECK(constructTID == std::this_thread::get_id()); #endif if (bytes > block_size) From d9f0866e623764a0b9d56c9a3256254cbbf5ae47 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 7 May 2022 09:58:19 -0700 Subject: [PATCH 039/149] Fix typo in comment --- src/pbrt/shapes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/shapes.h b/src/pbrt/shapes.h index 04b9aa511..4629781ea 100644 --- a/src/pbrt/shapes.h +++ b/src/pbrt/shapes.h @@ -1427,7 +1427,7 @@ class BilinearPatch { Vector3f dpds = dpdu * duds + dpdv * dvds; Vector3f dpdt = dpdu * dudt + dpdv * dvdt; - // Set _dpdu_ and _dpdt_ to updated partial derivatives + // Set _dpdu_ and _dpdv_ to updated partial derivatives if (Cross(dpds, dpdt) != Vector3f(0, 0, 0)) { if (Dot(Cross(dpdu, dpdv), Cross(dpds, dpdt)) < 0) dpdt = -dpdt; From bc25558763649eb25052a29299594d62c67ed39f Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 7 May 2022 10:00:19 -0700 Subject: [PATCH 040/149] Cleanup: std::is_*<*>::value -> std::is_*_v<*> --- src/pbrt/util/containers.h | 4 ++-- src/pbrt/util/display.h | 4 ++-- src/pbrt/util/float.h | 12 ++++++------ src/pbrt/util/math.h | 4 ++-- src/pbrt/util/print.h | 16 ++++++++-------- src/pbrt/util/pstd.h | 4 ++-- src/pbrt/util/taggedptr.h | 2 +- src/pbrt/util/vecmath.cpp | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/pbrt/util/containers.h b/src/pbrt/util/containers.h index d5206fdc4..a6d573499 100644 --- a/src/pbrt/util/containers.h +++ b/src/pbrt/util/containers.h @@ -55,7 +55,7 @@ struct HasType { template struct HasType> { static constexpr bool value = - (std::is_same::value || HasType>::value); + (std::is_same_v || HasType>::value); }; template @@ -170,7 +170,7 @@ class Array2D { } template ::value && + !std::is_integral_v && std::is_base_of< std::input_iterator_tag, typename std::iterator_traits::iterator_category>::value>> diff --git a/src/pbrt/util/display.h b/src/pbrt/util/display.h index 4091e6ff6..588417770 100644 --- a/src/pbrt/util/display.h +++ b/src/pbrt/util/display.h @@ -37,7 +37,7 @@ void DisplayDynamic(std::string title, const Image &image, pstd::optional channelDesc = {}); template -inline typename std::enable_if_t::value, void> DisplayStatic( +inline typename std::enable_if_t, void> DisplayStatic( const std::string &title, pstd::span values, int xResolution) { CHECK_EQ(0, values.size() % xResolution); int yResolution = values.size() / xResolution; @@ -51,7 +51,7 @@ inline typename std::enable_if_t::value, void> DisplayStat } template -inline typename std::enable_if_t::value, void> DisplayDynamic( +inline typename std::enable_if_t, void> DisplayDynamic( const std::string &title, pstd::span values, int xResolution) { CHECK_EQ(0, values.size() % xResolution); int yResolution = values.size() / xResolution; diff --git a/src/pbrt/util/float.h b/src/pbrt/util/float.h index 5f268a84f..542933c79 100644 --- a/src/pbrt/util/float.h +++ b/src/pbrt/util/float.h @@ -54,7 +54,7 @@ static constexpr float OneMinusEpsilon = FloatOneMinusEpsilon; // Floating-point Inline Functions template -inline PBRT_CPU_GPU typename std::enable_if_t::value, bool> +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsNaN(T v) { #ifdef PBRT_IS_GPU_CODE return isnan(v); @@ -64,13 +64,13 @@ IsNaN(T v) { } template -inline PBRT_CPU_GPU typename std::enable_if_t::value, bool> IsNaN( +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsNaN( T v) { return false; } template -inline PBRT_CPU_GPU typename std::enable_if_t::value, bool> +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsInf(T v) { #ifdef PBRT_IS_GPU_CODE return isinf(v); @@ -80,13 +80,13 @@ IsInf(T v) { } template -inline PBRT_CPU_GPU typename std::enable_if_t::value, bool> IsInf( +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsInf( T v) { return false; } template -inline PBRT_CPU_GPU typename std::enable_if_t::value, bool> +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsFinite(T v) { #ifdef PBRT_IS_GPU_CODE return isfinite(v); @@ -95,7 +95,7 @@ IsFinite(T v) { #endif } template -inline PBRT_CPU_GPU typename std::enable_if_t::value, bool> IsFinite( +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsFinite( T v) { return true; } diff --git a/src/pbrt/util/math.h b/src/pbrt/util/math.h index e2002b108..bec2b9acc 100644 --- a/src/pbrt/util/math.h +++ b/src/pbrt/util/math.h @@ -212,8 +212,8 @@ PBRT_CPU_GPU inline Float Lerp(Float x, Float a, Float b) { } template -inline PBRT_CPU_GPU typename std::enable_if_t::value, T> FMA(T a, T b, - T c) { +inline PBRT_CPU_GPU typename std::enable_if_t, T> FMA(T a, T b, + T c) { return a * b + c; } diff --git a/src/pbrt/util/print.h b/src/pbrt/util/print.h index bd8a6ffc4..9a219a470 100644 --- a/src/pbrt/util/print.h +++ b/src/pbrt/util/print.h @@ -157,7 +157,7 @@ void stringPrintfRecursive(std::string *s, const char *fmt); std::string copyToFormatString(const char **fmt_ptr, std::string *s); template -inline typename std::enable_if_t>::value, +inline typename std::enable_if_t>, std::string> formatOne(const char *fmt, T &&v) { // Figure out how much space we need to allocate; add an extra @@ -172,7 +172,7 @@ formatOne(const char *fmt, T &&v) { template inline - typename std::enable_if_t>::value, std::string> + typename std::enable_if_t>, std::string> formatOne(const char *fmt, T &&v) { LOG_FATAL("Printf: Non-basic type %s passed for format string %s", typeid(v).name(), fmt); @@ -190,7 +190,7 @@ inline void stringPrintfRecursiveWithPrecision(std::string *s, const char *fmt, } template -inline typename std::enable_if_t>::value, void> +inline typename std::enable_if_t>, void> stringPrintfRecursiveWithPrecision(std::string *s, const char *fmt, const std::string &nextFmt, int precision, T &&v, Args &&...args) { @@ -221,7 +221,7 @@ inline void stringPrintfRecursive(std::string *s, const char *fmt, T &&v, bool isSFmt = nextFmt.find('s') != std::string::npos; bool isDFmt = nextFmt.find('d') != std::string::npos; - if constexpr (std::is_integral>::value) { + if constexpr (std::is_integral_v>) { if (precisionViaArg) { stringPrintfRecursiveWithPrecision(s, fmt, nextFmt, v, std::forward(args)...); @@ -230,25 +230,25 @@ inline void stringPrintfRecursive(std::string *s, const char *fmt, T &&v, } else if (precisionViaArg) LOG_FATAL("Non-integral type provided for %* format."); - if constexpr (std::is_same, float>::value) + if constexpr (std::is_same_v, float>) if (nextFmt == "%f" || nextFmt == "%s") { *s += detail::FloatToString(v); goto done; } - if constexpr (std::is_same, double>::value) + if constexpr (std::is_same_v, double>) if (nextFmt == "%f" || nextFmt == "%s") { *s += detail::DoubleToString(v); goto done; } - if constexpr (std::is_same, bool>::value) // FIXME: %-10s with bool + if constexpr (std::is_same_v, bool>) // FIXME: %-10s with bool if (isSFmt) { *s += bool(v) ? "true" : "false"; goto done; } - if constexpr (std::is_integral>::value) { + if constexpr (std::is_integral_v>) { if (isDFmt) { nextFmt.replace(nextFmt.find('d'), 1, detail::IntegerFormatTrait>::fmt()); diff --git a/src/pbrt/util/pstd.h b/src/pbrt/util/pstd.h index 20d2ff4ff..7a568eb3f 100644 --- a/src/pbrt/util/pstd.h +++ b/src/pbrt/util/pstd.h @@ -329,11 +329,11 @@ class span { // Used to SFINAE-enable a function when the slice elements are const. template - using EnableIfConstView = typename std::enable_if_t::value, U>; + using EnableIfConstView = typename std::enable_if_t, U>; // Used to SFINAE-enable a function when the slice elements are mutable. template - using EnableIfMutableView = typename std::enable_if_t::value, U>; + using EnableIfMutableView = typename std::enable_if_t, U>; using value_type = typename std::remove_cv_t; using iterator = T *; diff --git a/src/pbrt/util/taggedptr.h b/src/pbrt/util/taggedptr.h index 966775afe..ee0a16ec8 100644 --- a/src/pbrt/util/taggedptr.h +++ b/src/pbrt/util/taggedptr.h @@ -653,7 +653,7 @@ struct IsSameType { template struct IsSameType { static constexpr bool value = - (std::is_same::value && IsSameType::value); + (std::is_same_v && IsSameType::value); }; template diff --git a/src/pbrt/util/vecmath.cpp b/src/pbrt/util/vecmath.cpp index 5dbcda846..d4b587aa5 100644 --- a/src/pbrt/util/vecmath.cpp +++ b/src/pbrt/util/vecmath.cpp @@ -26,7 +26,7 @@ std::string internal::ToString3(Interval x, Interval y, Interval z) { template std::string internal::ToString2(T x, T y) { - if (std::is_floating_point::value) + if (std::is_floating_point_v) return StringPrintf("[ %f, %f ]", x, y); else return StringPrintf("[ %d, %d ]", x, y); @@ -34,7 +34,7 @@ std::string internal::ToString2(T x, T y) { template std::string internal::ToString3(T x, T y, T z) { - if (std::is_floating_point::value) + if (std::is_floating_point_v) return StringPrintf("[ %f, %f, %f ]", x, y, z); else return StringPrintf("[ %d, %d, %d ]", x, y, z); From 6f7d81adfa6ddb8b909033f94dfbacf6bd51f33e Mon Sep 17 00:00:00 2001 From: Andreas Wendleder Date: Tue, 10 May 2022 13:02:20 +0200 Subject: [PATCH 041/149] Add mouse handling. --- src/pbrt/util/gui.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++- src/pbrt/util/gui.h | 9 ++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/pbrt/util/gui.cpp b/src/pbrt/util/gui.cpp index 8a350ed77..94bed1911 100644 --- a/src/pbrt/util/gui.cpp +++ b/src/pbrt/util/gui.cpp @@ -87,6 +87,40 @@ void GUI::keyboardCallback(GLFWwindow *window, int key, int scan, int action, in doKey(GLFW_KEY_R, 'r'); } +bool GUI::processMouse() { + bool needsReset = false; + double amount = 1.f; + if (!pressed) return false; + if (xoffset < 0) { + movingFromCamera = movingFromCamera * Rotate(-amount, Vector3f(0, 1, 0)); + needsReset = true; + xoffset = 0; + } + if (xoffset > 0) { + movingFromCamera = movingFromCamera * Rotate(amount, Vector3f(0, 1, 0)); + needsReset = true; + xoffset = 0; + } + if (yoffset > 0) { + movingFromCamera = movingFromCamera * Rotate(-amount, Vector3f(1, 0, 0)); + needsReset = true; + yoffset = 0; + } + if (yoffset < 0) { + movingFromCamera = movingFromCamera * Rotate(amount, Vector3f(1, 0, 0)); + needsReset = true; + yoffset = 0; + } + return needsReset; +} + +bool GUI::process() { + bool needsReset = false; + needsReset |= processKeys(); + needsReset |= processMouse(); + return needsReset; +} + bool GUI::processKeys() { bool needsReset = false; @@ -144,11 +178,45 @@ bool GUI::processKeys() { return needsReset; } + static void glfwKeyCallback(GLFWwindow* window, int key, int scan, int action, int mods) { GUI* gui = (GUI*)glfwGetWindowUserPointer(window); gui->keyboardCallback(window, key, scan, action, mods); } + +void GUI::mouseButtonCallback(GLFWwindow* window, int button, int action, int mods) { + if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) + { + pressed = true; + glfwGetCursorPos(window, &lastX, &lastY); + } + if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) + { + pressed = false; + } +} + +static void glfwMouseButtonCallback(GLFWwindow* window, int button, int action, int mods) +{ + GUI* gui = (GUI*)glfwGetWindowUserPointer(window); + gui->mouseButtonCallback(window, button, action, mods); + +} + +static void glfwCursorPosCallback(GLFWwindow* window, double xpos, double ypos) { + GUI* gui = (GUI*)glfwGetWindowUserPointer(window); + gui->cursorPosCallback(window, xpos, ypos); +} + +void GUI::cursorPosCallback(GLFWwindow* window, double xpos, double ypos) +{ + xoffset = xpos - lastX; + yoffset = lastY - ypos; + lastX = xpos; + lastY = ypos; +} + GUI::GUI(std::string title, Vector2i resolution, Bounds3f sceneBounds) : resolution(resolution) { moveScale = Length(sceneBounds.Diagonal()) / 1000.f; @@ -162,6 +230,9 @@ GUI::GUI(std::string title, Vector2i resolution, Bounds3f sceneBounds) LOG_FATAL("Unable to create GLFW window"); } glfwSetKeyCallback(window, glfwKeyCallback); + glfwSetMouseButtonCallback(window, glfwMouseButtonCallback); + glfwSetCursorPosCallback(window, glfwCursorPosCallback); + glfwSetWindowUserPointer(window, this); glfwMakeContextCurrent(window); @@ -246,7 +317,7 @@ DisplayState GUI::RefreshDisplay() { if (glfwWindowShouldClose(window)) return DisplayState::EXIT; - else if (processKeys()) + else if (process()) return DisplayState::RESET; else return DisplayState::NONE; diff --git a/src/pbrt/util/gui.h b/src/pbrt/util/gui.h index a67834e19..32dc9693e 100644 --- a/src/pbrt/util/gui.h +++ b/src/pbrt/util/gui.h @@ -54,9 +54,13 @@ class GUI { bool printCameraTransform = false; void keyboardCallback(GLFWwindow *window, int key, int scan, int action, int mods); + void cursorPosCallback(GLFWwindow *window, double xpos, double ypos); + void mouseButtonCallback(GLFWwindow* window, int button, int action, int mods); private: bool processKeys(); + bool processMouse(); + bool process(); std::set keysDown; Float moveScale = 1.f; @@ -64,6 +68,11 @@ class GUI { Vector2i resolution; bool recordFrames = false; int frameNumber = 0; + bool pressed = false; + Float xoffset = 0.f; + Float yoffset = 0.f; + double lastX = 0.f; + double lastY = 0.f;; #ifdef PBRT_BUILD_GPU_RENDERER CUDAOutputBuffer *cudaFramebuffer = nullptr; From c5f3533ffb512eedd245a987ec425de089b6abdb Mon Sep 17 00:00:00 2001 From: Hearwindsaying Date: Fri, 13 May 2022 01:02:01 +0800 Subject: [PATCH 042/149] Fix TaggedPointer ambiguous `DispatchCPU()` call issue when instantiated with 8x types. (#253) taggedptr_test.cpp adds a test type to check if the fix works as expected. --- src/pbrt/util/taggedptr.h | 64 ++++++++++++++++++++++++++++++-- src/pbrt/util/taggedptr_test.cpp | 47 ++++++++++++++++++++--- 2 files changed, 102 insertions(+), 9 deletions(-) diff --git a/src/pbrt/util/taggedptr.h b/src/pbrt/util/taggedptr.h index ee0a16ec8..b0da7a4d9 100644 --- a/src/pbrt/util/taggedptr.h +++ b/src/pbrt/util/taggedptr.h @@ -249,6 +249,32 @@ PBRT_CPU_GPU R Dispatch(F &&func, void *ptr, int index) { } } +template +PBRT_CPU_GPU R Dispatch(F &&func, const void *ptr, int index) { + DCHECK_GE(index, 0); + DCHECK_LT(index, 8); + + switch (index) { + case 0: + return func((const T0 *)ptr); + case 1: + return func((const T1 *)ptr); + case 2: + return func((const T2 *)ptr); + case 3: + return func((const T3 *)ptr); + case 4: + return func((const T4 *)ptr); + case 5: + return func((const T5 *)ptr); + case 6: + return func((const T6 *)ptr); + default: + return func((const T7 *)ptr); + } +} + template PBRT_CPU_GPU R Dispatch(F &&func, void *ptr, int index) { @@ -276,7 +302,8 @@ PBRT_CPU_GPU R Dispatch(F &&func, void *ptr, int index) { } template + typename T4, typename T5, typename T6, typename T7, typename... Ts, + typename = typename std::enable_if_t<(sizeof...(Ts) > 0)>> PBRT_CPU_GPU R Dispatch(F &&func, const void *ptr, int index) { DCHECK_GE(index, 0); @@ -303,7 +330,8 @@ PBRT_CPU_GPU R Dispatch(F &&func, const void *ptr, int index) { } template + typename T4, typename T5, typename T6, typename T7, typename... Ts, + typename = typename std::enable_if_t<(sizeof...(Ts) > 0)>> PBRT_CPU_GPU R Dispatch(F &&func, void *ptr, int index) { DCHECK_GE(index, 0); @@ -559,6 +587,32 @@ auto DispatchCPU(F &&func, void *ptr, int index) { } } +template +auto DispatchCPU(F &&func, const void *ptr, int index) { + DCHECK_GE(index, 0); + DCHECK_LT(index, 8); + + switch (index) { + case 0: + return func((const T0 *)ptr); + case 1: + return func((const T1 *)ptr); + case 2: + return func((const T2 *)ptr); + case 3: + return func((const T3 *)ptr); + case 4: + return func((const T4 *)ptr); + case 5: + return func((const T5 *)ptr); + case 6: + return func((const T6 *)ptr); + default: + return func((const T7 *)ptr); + } +} + template auto DispatchCPU(F &&func, void *ptr, int index) { @@ -586,7 +640,8 @@ auto DispatchCPU(F &&func, void *ptr, int index) { } template + typename T4, typename T5, typename T6, typename T7, typename... Ts, + typename = typename std::enable_if_t<(sizeof...(Ts) > 0)>> auto DispatchCPU(F &&func, const void *ptr, int index) { DCHECK_GE(index, 0); @@ -613,7 +668,8 @@ auto DispatchCPU(F &&func, const void *ptr, int index) { } template + typename T4, typename T5, typename T6, typename T7, typename... Ts, + typename = typename std::enable_if_t<(sizeof...(Ts) > 0)>> auto DispatchCPU(F &&func, void *ptr, int index) { DCHECK_GE(index, 0); diff --git a/src/pbrt/util/taggedptr_test.cpp b/src/pbrt/util/taggedptr_test.cpp index 2d2a72b33..cecc74307 100644 --- a/src/pbrt/util/taggedptr_test.cpp +++ b/src/pbrt/util/taggedptr_test.cpp @@ -12,14 +12,14 @@ using namespace pbrt; template struct IntType { - int func() { return n; } - int cfunc() const { return n; } + PBRT_CPU_GPU int func() { return n; } + PBRT_CPU_GPU int cfunc() const { return n; } }; struct Handle : public TaggedPointer, IntType<1>, IntType<2>, IntType<3>, IntType<4>, IntType<5>, IntType<6>, IntType<7>, IntType<8>, IntType<9>, IntType<10>, IntType<11>, - IntType<12>, IntType<13>, IntType<14>> { + IntType<12>, IntType<13>, IntType<14>, IntType<15>> { using TaggedPointer::TaggedPointer; int func() { @@ -32,11 +32,36 @@ struct Handle : public TaggedPointer, IntType<1>, IntType<2>, IntType } }; +struct HandleWithEightConcreteTypes + : public TaggedPointer, IntType<1>, IntType<2>, IntType<3>, IntType<4>, + IntType<5>, IntType<6>, IntType<7>> { + using TaggedPointer::TaggedPointer; + + int func() { + auto f = [&](auto ptr) { return ptr->func(); }; + return DispatchCPU(f); + } + int cfunc() const { + auto f = [&](auto ptr) { return ptr->cfunc(); }; + return DispatchCPU(f); + } + + PBRT_CPU_GPU int funcGPU() { + auto f = [&](auto ptr) { return ptr->func(); }; + return Dispatch(f); + } + + PBRT_CPU_GPU int cfuncGPU() { + auto f = [&](auto ptr) { return ptr->cfunc(); }; + return Dispatch(f); + } +}; + TEST(TaggedPointer, Basics) { EXPECT_EQ(nullptr, Handle().ptr()); - EXPECT_EQ(15, Handle::MaxTag()); - EXPECT_EQ(16, Handle::NumTags()); + EXPECT_EQ(16, Handle::MaxTag()); + EXPECT_EQ(17, Handle::NumTags()); IntType<0> it0; IntType<1> it1; @@ -53,6 +78,7 @@ TEST(TaggedPointer, Basics) { IntType<12> it12; IntType<13> it13; IntType<14> it14; + IntType<15> it15; EXPECT_TRUE(Handle(&it0).Is>()); EXPECT_TRUE(Handle(&it1).Is>()); @@ -69,6 +95,7 @@ TEST(TaggedPointer, Basics) { EXPECT_TRUE(Handle(&it12).Is>()); EXPECT_TRUE(Handle(&it13).Is>()); EXPECT_TRUE(Handle(&it14).Is>()); + EXPECT_TRUE(Handle(&it15).Is>()); EXPECT_FALSE(Handle(&it0).Is>()); EXPECT_FALSE(Handle(&it1).Is>()); @@ -85,6 +112,7 @@ TEST(TaggedPointer, Basics) { EXPECT_FALSE(Handle(&it12).Is>()); EXPECT_FALSE(Handle(&it13).Is>()); EXPECT_FALSE(Handle(&it14).Is>()); + EXPECT_FALSE(Handle(&it15).Is>()); EXPECT_EQ(0, Handle(nullptr).Tag()); EXPECT_EQ(1, Handle(&it0).Tag()); @@ -102,6 +130,7 @@ TEST(TaggedPointer, Basics) { EXPECT_EQ(13, Handle(&it12).Tag()); EXPECT_EQ(14, Handle(&it13).Tag()); EXPECT_EQ(15, Handle(&it14).Tag()); + EXPECT_EQ(16, Handle(&it15).Tag()); EXPECT_EQ(1, Handle::TypeIndex()); EXPECT_EQ(2, Handle::TypeIndex()); @@ -118,6 +147,7 @@ TEST(TaggedPointer, Basics) { EXPECT_EQ(13, Handle::TypeIndex()); EXPECT_EQ(14, Handle::TypeIndex()); EXPECT_EQ(15, Handle::TypeIndex()); + EXPECT_EQ(16, Handle::TypeIndex()); EXPECT_EQ(&it0, Handle(&it0).CastOrNullptr>()); EXPECT_EQ(nullptr, Handle(&it0).CastOrNullptr>()); @@ -231,4 +261,11 @@ TEST(TaggedPointer, Dispatch) { EXPECT_EQ(14, h14.func()); ASSERT_EQ(14, it14.cfunc()); EXPECT_EQ(14, h14.cfunc()); + + IntType<15> it15; + Handle h15(&it15); + ASSERT_EQ(15, it15.func()); + EXPECT_EQ(15, h15.func()); + ASSERT_EQ(15, it15.cfunc()); + EXPECT_EQ(15, h15.cfunc()); } From a55307fa46651136f3c91387022960559ff6ae47 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 13 May 2022 06:12:44 -0700 Subject: [PATCH 043/149] Update to cuda-toolkit@v0.2.6. Allows removing the workaround for NVIDIA's changed signing keys. --- .github/workflows/ci-gpu.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index d2c9533d0..afdc147cb 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -24,14 +24,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - # https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212772 - - name: Fetch new CUDA pubkey - if: ${{ matrix.os == 'ubuntu-20.04' }} - run: | - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb - sudo dpkg -i cuda-keyring_1.0-1_all.deb - - - uses: mmp/cuda-toolkit@master + - uses: jimver/cuda-toolkit@v0.2.6 id: cuda-toolkit with: cuda: ${{ matrix.cuda }} From 42ab6e26f4bae982fcc94b1370bcd3c0fc7fb96d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 13 May 2022 06:20:46 -0700 Subject: [PATCH 044/149] Update CUDA versions used for github workflow CI. Add more recent versions, up to 11.7.0, and remove older ones. 11.2.2 is now the oldest version tested. --- .github/workflows/ci-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index afdc147cb..3ae44e799 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: optix: [ optix-7.1.0, optix-7.2.0, optix-7.3.0, optix-7.4.0 ] - cuda: [ '11.0.3', '11.1.1', '11.2.2', '11.4.3', '11.5.0' ] # 11.3.0 fails for unclear reasons + cuda: [ '11.2.2', '11.4.3', '11.5.2', '11.6.1', '11.7.0' ] # 11.3.0 fails for unclear reasons os: [ ubuntu-20.04, windows-latest ] name: GPU Build Only (${{ matrix.os }}, CUDA ${{ matrix.cuda }}, ${{ matrix.optix }}) From 19336a6c7fa12115dc83d5879254b68800623226 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 14 May 2022 07:52:43 -0700 Subject: [PATCH 045/149] Fix bug with CPU writing to managed memory while OptiX is creating BVHs On Windows, both CPU and GPU can't write to managed memory at the same time. Previously, it was possible that the asynchronous creation of the sampler, camera, film, etc., could still be running when OptiX BVH construction started. This was especially likely with the Halton sampler + random digit permutations, which take a while to initialize. Fixes #246. --- src/pbrt/scene.h | 2 ++ src/pbrt/wavefront/integrator.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pbrt/scene.h b/src/pbrt/scene.h index 4987a63bb..cd1958d55 100644 --- a/src/pbrt/scene.h +++ b/src/pbrt/scene.h @@ -287,6 +287,7 @@ class BasicScene { camera = *c; } cameraJobMutex.unlock(); + LOG_VERBOSE("Retrieved Camera from future"); return camera; } @@ -298,6 +299,7 @@ class BasicScene { sampler = *s; } samplerJobMutex.unlock(); + LOG_VERBOSE("Retrieved Sampler from future"); return sampler; } diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index 14ae5d359..94738b5e3 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -146,6 +146,14 @@ WavefrontPathIntegrator::WavefrontPathIntegrator( &haveSubsurface, &haveMedia); LOG_VERBOSE("Finished creating materials"); + // Retrieve these here so that the CPU isn't writing to managed memory + // concurrently with the OptiX acceleration-structure construction work + // that follows. (Verbotten on Windows.) + camera = scene.GetCamera(); + film = camera.GetFilm(); + filter = film.GetFilter(); + sampler = scene.GetSampler(); + if (Options->useGPU) { #ifdef PBRT_BUILD_GPU_RENDERER CUDATrackedMemoryResource *mr = @@ -188,11 +196,6 @@ WavefrontPathIntegrator::WavefrontPathIntegrator( regularize = scene.integrator.parameters.GetOneBool("regularize", false); maxDepth = scene.integrator.parameters.GetOneInt("maxdepth", 5); - camera = scene.GetCamera(); - film = camera.GetFilm(); - filter = film.GetFilter(); - sampler = scene.GetSampler(); - initializeVisibleSurface = film.UsesVisibleSurface(); samplesPerPixel = sampler.SamplesPerPixel(); From d12a23353eb638c20857a04562200b038541d1c3 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 14 May 2022 07:54:04 -0700 Subject: [PATCH 046/149] Fix format string error in HaltonSampler::Create() Noted by @pbrt4bounty in #246. --- src/pbrt/samplers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/samplers.cpp b/src/pbrt/samplers.cpp index e52bcd836..5953f1711 100644 --- a/src/pbrt/samplers.cpp +++ b/src/pbrt/samplers.cpp @@ -81,7 +81,7 @@ HaltonSampler *HaltonSampler::Create(const ParameterDictionary ¶meters, else if (s == "permutedigits") randomizer = RandomizeStrategy::PermuteDigits; else if (s == "fastowen") - ErrorExit("%s: \"fastowen\" randomization not supported by Halton sampler."); + ErrorExit("\"fastowen\" randomization not supported by Halton sampler."); else if (s == "owen") randomizer = RandomizeStrategy::Owen; else From 932aba808cdefd7382779bbfebf0ce003c4bb79d Mon Sep 17 00:00:00 2001 From: Andreas Wendleder Date: Mon, 23 May 2022 12:47:00 +0200 Subject: [PATCH 047/149] Read Optix path from environment. This way it doesn't has to be set in CMakeCache.txt every time the repository is checked out. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcaf1c70d..c668696c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ option (PBRT_DBG_LOGGING "Enable (very verbose!) debug logging" OFF) option (PBRT_NVTX "Insert NVTX annotations for NVIDIA Profiling and Debugging Tools" OFF) option (PBRT_NVML "Use NVML for GPU performance measurement" OFF) option (PBRT_USE_PREGENERATED_RGB_TO_SPECTRUM_TABLES "Use pregenerated rgbspectrum_*.cpp files rather than running rgb2spec_opt to generate them at build time" OFF) -set (PBRT_OPTIX7_PATH "" CACHE PATH "Path to OptiX 7 SDK") +set (PBRT_OPTIX7_PATH $ENV{PBRT_OPTIX7_PATH} CACHE PATH "Path to OptiX 7 SDK") set (PBRT_GPU_SHADER_MODEL "" CACHE STRING "") if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) From 96347e744107f70fafb70eb6054f148f51ff12e4 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 23 May 2022 09:53:36 -0700 Subject: [PATCH 048/149] clang-format run --- src/pbrt/bsdfs_test.cpp | 28 +++---- src/pbrt/cmd/imgtool.cpp | 127 +++++++++++++++-------------- src/pbrt/cpu/integrators.cpp | 5 +- src/pbrt/cpu/integrators_test.cpp | 5 +- src/pbrt/film.cpp | 29 ++++--- src/pbrt/film.h | 19 ++--- src/pbrt/gpu/aggregate.cpp | 50 ++++++------ src/pbrt/gpu/cudagl.h | 16 ++-- src/pbrt/gpu/denoiser.cpp | 4 +- src/pbrt/gpu/denoiser.h | 8 +- src/pbrt/lights_test.cpp | 3 +- src/pbrt/lightsamplers_test.cpp | 18 ++-- src/pbrt/materials.cpp | 50 ++++++------ src/pbrt/options.cpp | 13 +-- src/pbrt/parser.cpp | 96 ++++++++++++---------- src/pbrt/samplers_test.cpp | 31 +++---- src/pbrt/util/containers_test.cpp | 2 +- src/pbrt/util/display.cpp | 8 +- src/pbrt/util/file.cpp | 16 ++-- src/pbrt/util/float.h | 21 ++--- src/pbrt/util/gui.cpp | 37 ++++----- src/pbrt/util/gui.h | 4 +- src/pbrt/util/image.cpp | 36 ++++---- src/pbrt/util/image_test.cpp | 16 ++-- src/pbrt/util/log.cpp | 25 +++--- src/pbrt/util/parallel_test.cpp | 2 +- src/pbrt/util/print.h | 8 +- src/pbrt/util/pstd_test.cpp | 2 +- src/pbrt/util/string.cpp | 7 +- src/pbrt/util/string_test.cpp | 4 +- src/pbrt/util/taggedptr.h | 6 +- src/pbrt/wavefront/integrator.cpp | 111 +++++++++++++------------ src/pbrt/wavefront/integrator.h | 3 +- src/pbrt/wavefront/samples.cpp | 2 +- src/pbrt/wavefront/surfscatter.cpp | 15 ++-- 35 files changed, 423 insertions(+), 404 deletions(-) diff --git a/src/pbrt/bsdfs_test.cpp b/src/pbrt/bsdfs_test.cpp index df91e26e7..aa025eb76 100644 --- a/src/pbrt/bsdfs_test.cpp +++ b/src/pbrt/bsdfs_test.cpp @@ -430,9 +430,8 @@ void TestBSDF(std::function createB BSDF* createLambertian(const SurfaceInteraction& si, Allocator alloc) { SampledSpectrum Kd(1.); - return alloc.new_object( - si.shading.n, si.shading.dpdu, - alloc.new_object(Kd)); + return alloc.new_object(si.shading.n, si.shading.dpdu, + alloc.new_object(Kd)); } TEST(BSDFSampling, Lambertian) { @@ -446,7 +445,8 @@ BSDF* createConductorMicrofacet(const SurfaceInteraction& si, Allocator alloc, f Float alphay = TrowbridgeReitzDistribution::RoughnessToAlpha(roughy); TrowbridgeReitzDistribution distrib(alphax, alphay); return alloc.new_object(si.shading.n, si.shading.dpdu, - alloc.new_object(distrib, SampledSpectrum(eta), SampledSpectrum(k))); + alloc.new_object( + distrib, SampledSpectrum(eta), SampledSpectrum(k))); } BSDF* createDielectricMicrofacet(const SurfaceInteraction& si, Allocator alloc, float ior, @@ -455,7 +455,7 @@ BSDF* createDielectricMicrofacet(const SurfaceInteraction& si, Allocator alloc, Float alphay = TrowbridgeReitzDistribution::RoughnessToAlpha(roughy); TrowbridgeReitzDistribution distrib(alphax, alphay); return alloc.new_object(si.shading.n, si.shading.dpdu, - alloc.new_object(ior, distrib)); + alloc.new_object(ior, distrib)); } TEST(BSDFSampling, TRCondIso) { @@ -482,7 +482,6 @@ TEST(BSDFSampling, TRDielIso) { "TRDielIso"); } - TEST(BSDFSampling, TRDielAniso) { TestBSDF( [](const SurfaceInteraction& si, Allocator alloc) -> BSDF* { @@ -494,16 +493,15 @@ TEST(BSDFSampling, TRDielAniso) { TEST(BSDFSampling, TRDielIsoInv) { TestBSDF( [](const SurfaceInteraction& si, Allocator alloc) -> BSDF* { - return createDielectricMicrofacet(si, alloc, 1/1.5f, 0.5, 0.5); + return createDielectricMicrofacet(si, alloc, 1 / 1.5f, 0.5, 0.5); }, "TRDielIsoInv"); } - TEST(BSDFSampling, TRDielAnisoInv) { TestBSDF( [](const SurfaceInteraction& si, Allocator alloc) -> BSDF* { - return createDielectricMicrofacet(si, alloc, 1/1.5f, 0.3, 0.15); + return createDielectricMicrofacet(si, alloc, 1 / 1.5f, 0.3, 0.15); }, "TRDielAnisoInv"); } @@ -733,8 +731,8 @@ TEST(Hair, WhiteFurnaceSampled) { Float uc = RadicalInverse(2, i); Point2f u(RadicalInverse(3, i), RadicalInverse(4, i)); - pstd::optional bs = hair.Sample_f(wo, uc, u, TransportMode::Radiance, - BxDFReflTransFlags::All); + pstd::optional bs = hair.Sample_f( + wo, uc, u, TransportMode::Radiance, BxDFReflTransFlags::All); if (bs) { SampledSpectrum f = bs->f * AbsCosTheta(bs->wi) / bs->pdf; ySum += f.y(lambda); @@ -763,8 +761,8 @@ TEST(Hair, SamplingWeights) { SampleUniformSphere({RadicalInverse(1, i), RadicalInverse(2, i)}); Float uc = RadicalInverse(3, i); Point2f u = {RadicalInverse(4, i), RadicalInverse(5, i)}; - pstd::optional bs = hair.Sample_f(wo, uc, u, TransportMode::Radiance, - BxDFReflTransFlags::All); + pstd::optional bs = hair.Sample_f( + wo, uc, u, TransportMode::Radiance, BxDFReflTransFlags::All); if (bs) { Float sum = 0; int ny = 20; @@ -803,8 +801,8 @@ TEST(Hair, SamplingConsistency) { Vector3f wi; Float uc = rng.Uniform(); Point2f u = {rng.Uniform(), rng.Uniform()}; - pstd::optional bs = hair.Sample_f(wo, uc, u, TransportMode::Radiance, - BxDFReflTransFlags::All); + pstd::optional bs = hair.Sample_f( + wo, uc, u, TransportMode::Radiance, BxDFReflTransFlags::All); if (bs) fImportance += bs->f * Li(bs->wi) * AbsCosTheta(bs->wi) / (count * bs->pdf); diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index a5c2e4cf9..e8e65b403 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -9,7 +9,7 @@ #ifdef PBRT_BUILD_GPU_RENDERER #include #include -#endif // PBRT_BUILD_GPU_RENDERER +#endif // PBRT_BUILD_GPU_RENDERER #include #include #include @@ -291,17 +291,18 @@ int help(std::vector args) { return 0; } -static bool checkImageCompatibility(std::string fn1, const Image &im1, const RGBColorSpace *cs1, - std::string fn2, const Image &im2, const RGBColorSpace *cs2) { +static bool checkImageCompatibility(std::string fn1, const Image &im1, + const RGBColorSpace *cs1, std::string fn2, + const Image &im2, const RGBColorSpace *cs2) { if (im1.Resolution() != im2.Resolution()) { - Error("%s: image resolution (%d, %d) doesn't match \"%s\" (%d, %d).", - fn1.c_str(), im1.Resolution().x, im1.Resolution().y, fn2.c_str(), - im2.Resolution().x, im2.Resolution().y); + Error("%s: image resolution (%d, %d) doesn't match \"%s\" (%d, %d).", fn1.c_str(), + im1.Resolution().x, im1.Resolution().y, fn2.c_str(), im2.Resolution().x, + im2.Resolution().y); return false; } if (im1.NChannels() != im2.NChannels()) { - Error("%s: image channel count %d doesn't match \"%s\", %d.", - fn1.c_str(), im1.NChannels(), fn2.c_str(), im2.NChannels()); + Error("%s: image channel count %d doesn't match \"%s\", %d.", fn1.c_str(), + im1.NChannels(), fn2.c_str(), im2.NChannels()); return false; } if (im1.ChannelNames() != im2.ChannelNames()) { @@ -461,13 +462,11 @@ int assemble(std::vector args) { ImageMetadata &metadata = im.metadata; if (!metadata.fullResolution) { - Error("%s: doesn't have full resolution in image metadata. Skipping.", - file); + Error("%s: doesn't have full resolution in image metadata. Skipping.", file); continue; } if (!metadata.pixelBounds) { - Error("%s: doesn't have pixel bounds in image metadata. Skipping.", - file); + Error("%s: doesn't have pixel bounds in image metadata. Skipping.", file); continue; } @@ -482,30 +481,32 @@ int assemble(std::vector args) { // Make sure that this image's info is compatible with the // first image's. if (*metadata.fullResolution != fullImage.Resolution()) { - Warning("%s: full resolution (%d, %d) in EXR file doesn't match the full resolution of first EXR file (%d, %d). " - "Ignoring this file.", file, metadata.fullResolution->x, - metadata.fullResolution->y, fullImage.Resolution().x, - fullImage.Resolution().y); + Warning("%s: full resolution (%d, %d) in EXR file doesn't match the full " + "resolution of first EXR file (%d, %d). " + "Ignoring this file.", + file, metadata.fullResolution->x, metadata.fullResolution->y, + fullImage.Resolution().x, fullImage.Resolution().y); continue; } if (Union(*metadata.pixelBounds, fullBounds) != fullBounds) { - Warning("%s: pixel bounds (%d, %d) - (%d, %d) in EXR file isn't inside the the full image (0, 0) - (%d, %d). " - "Ignoring this file.", file, metadata.pixelBounds->pMin.x, - metadata.pixelBounds->pMin.y, metadata.pixelBounds->pMax.x, - metadata.pixelBounds->pMax.y, fullBounds.pMax.x, - fullBounds.pMax.y); + Warning("%s: pixel bounds (%d, %d) - (%d, %d) in EXR file isn't inside " + "the the full image (0, 0) - (%d, %d). " + "Ignoring this file.", + file, metadata.pixelBounds->pMin.x, metadata.pixelBounds->pMin.y, + metadata.pixelBounds->pMax.x, metadata.pixelBounds->pMax.y, + fullBounds.pMax.x, fullBounds.pMax.y); continue; } if (fullImage.NChannels() != image.NChannels()) { - Warning("%s: %d channel image; expecting %d channels.", - file, image.NChannels(), fullImage.NChannels()); + Warning("%s: %d channel image; expecting %d channels.", file, + image.NChannels(), fullImage.NChannels()); continue; } const RGBColorSpace *cs = metadata.GetColorSpace(); if (*cs != *colorSpace) { - Warning("%s: color space (%s) doesn't match first image's color space (%s).", - file, cs->ToString(), - colorSpace->ToString()); + Warning( + "%s: color space (%s) doesn't match first image's color space (%s).", + file, cs->ToString(), colorSpace->ToString()); continue; } } @@ -532,11 +533,9 @@ int assemble(std::vector args) { ++unseenPixels; if (seenMultiple > 0) - Warning("%s: %d pixels present in multiple images.", outfile, - seenMultiple); + Warning("%s: %d pixels present in multiple images.", outfile, seenMultiple); if (unseenPixels > 0) - Warning("%s: %d pixels not present in any images.", outfile, - unseenPixels); + Warning("%s: %d pixels not present in any images.", outfile, unseenPixels); ImageMetadata outMetadata; outMetadata.colorSpace = colorSpace; @@ -583,8 +582,8 @@ int splitn(std::vector args) { if (!colorSpace) colorSpace = im.metadata.GetColorSpace(); - else if (!checkImageCompatibility(infiles[0], images.front(), colorSpace, - file, image, im.metadata.GetColorSpace())) + else if (!checkImageCompatibility(infiles[0], images.front(), colorSpace, file, + image, im.metadata.GetColorSpace())) return false; images.push_back(image); @@ -870,8 +869,9 @@ int average(std::vector args) { if (avg.Resolution() == Point2i(0, 0)) { avg = Image(PixelFormat::Float, im.Resolution(), im.ChannelNames()); colorSpaces.Get() = imRead.metadata.GetColorSpace(); - } else if (!checkImageCompatibility(filenames[i], im, imRead.metadata.GetColorSpace(), - filenames[0], avg, colorSpaces.Get())) { + } else if (!checkImageCompatibility(filenames[i], im, + imRead.metadata.GetColorSpace(), filenames[0], + avg, colorSpaces.Get())) { failed = true; return; } @@ -1019,7 +1019,8 @@ int error(std::vector args) { for (int i = 1; i < filenames.size(); ++i) { if (spp[i] != spp[0]) { - Error("%s: spp %d mismatch. %s has %d.", filenames[i], spp[i], filenames[0], spp[0]); + Error("%s: spp %d mismatch. %s has %d.", filenames[i], spp[i], filenames[0], + spp[0]); return 1; } } @@ -1124,8 +1125,7 @@ int diff(std::vector args) { refImage = refImage.SelectChannels(refDesc); if (imgDesc.size() != splitChannels.size()) { - Error("%s: image does not have \"%s\" channels.", imageFile, - channels); + Error("%s: image does not have \"%s\" channels.", imageFile, channels); return 1; } image = image.SelectChannels(imgDesc); @@ -1156,8 +1156,7 @@ int diff(std::vector args) { if (nClamped > 0) Warning("%s: clamped %d infinite pixel values.", imageFile, nClamped); if (nRefClamped > 0) - Warning("%s: clamped %d infinite pixel values.", referenceFile, - nRefClamped); + Warning("%s: clamped %d infinite pixel values.", referenceFile, nRefClamped); // Image averages. Compute before FLIP potentially goes and clamps things... Float refAverage = refImage.Average(refImage.AllChannelsDesc()).Average(); @@ -1726,8 +1725,7 @@ int convert(std::vector args) { std::vector splitChannelNames = SplitString(channelNames, ','); ImageChannelDesc desc = image.GetChannelDesc(splitChannelNames); if (!desc) { - Error("%s: image doesn't have channels \"%s\".", inFile, - channelNames); + Error("%s: image doesn't have channels \"%s\".", inFile, channelNames); return 1; } image = image.SelectChannels(desc); @@ -1743,24 +1741,25 @@ int convert(std::vector args) { if (cropWindow[3] < 0) cropWindow[3] = cropWindow[2] - cropWindow[3]; if (cropWindow[0] >= 0 && cropWindow[2] >= 0) { - Bounds2i cropBounds({cropWindow[0], cropWindow[2]}, {cropWindow[1], cropWindow[3]}); + Bounds2i cropBounds({cropWindow[0], cropWindow[2]}, + {cropWindow[1], cropWindow[3]}); - Point2i fullRes = metadata.fullResolution ? *metadata.fullResolution : - image.Resolution(); + Point2i fullRes = + metadata.fullResolution ? *metadata.fullResolution : image.Resolution(); if (metadata.pixelBounds && !Inside(cropBounds, *metadata.pixelBounds)) { Error("%s: crop window bounds (%d,%d)-(%d,%d) are not inside " - "image's pixel bounds (%d,%d)-(%d,%d).", inFile, - cropBounds.pMin.x, cropBounds.pMin.y, cropBounds.pMax.x, + "image's pixel bounds (%d,%d)-(%d,%d).", + inFile, cropBounds.pMin.x, cropBounds.pMin.y, cropBounds.pMax.x, cropBounds.pMax.y, metadata.pixelBounds->pMin.x, metadata.pixelBounds->pMin.y, metadata.pixelBounds->pMax.x, metadata.pixelBounds->pMax.y); return 1; - } else if (!Inside(cropBounds, Bounds2i(Point2i(0,0), fullRes))) { + } else if (!Inside(cropBounds, Bounds2i(Point2i(0, 0), fullRes))) { Error("%s: crop window bounds (%d,%d)-(%d,%d) are not inside " - "image's resolution (%d,%d).", inFile, cropBounds.pMin.x, - cropBounds.pMin.y, cropBounds.pMax.x, cropBounds.pMax.y, - fullRes.x, fullRes.y); + "image's resolution (%d,%d).", + inFile, cropBounds.pMin.x, cropBounds.pMin.y, cropBounds.pMax.x, + cropBounds.pMax.y, fullRes.x, fullRes.y); return 1; } @@ -1965,8 +1964,9 @@ int convert(std::vector args) { image.FlipY(); if (outMetadata.pixelBounds && outMetadata.fullResolution) { // Flip the pixel bounds in the metadata as well - int by[2] = { outMetadata.fullResolution->y - 1 - outMetadata.pixelBounds->pMax.y, - outMetadata.fullResolution->y - 1 - outMetadata.pixelBounds->pMin.y }; + int by[2] = { + outMetadata.fullResolution->y - 1 - outMetadata.pixelBounds->pMax.y, + outMetadata.fullResolution->y - 1 - outMetadata.pixelBounds->pMin.y}; outMetadata.pixelBounds->pMin.y = by[0]; outMetadata.pixelBounds->pMax.y = by[1]; } @@ -2157,8 +2157,7 @@ int makeequiarea(std::vector args) { if (2 * latlongImage.Resolution().y != latlongImage.Resolution().x) Warning("%s: esolution (%d, %d) doesn't have a 2:1 aspect ratio. " "It is doubtful that this is a lat-long environment map.", - inFilename, latlongImage.Resolution().x, - latlongImage.Resolution().y); + inFilename, latlongImage.Resolution().x, latlongImage.Resolution().y); if (resolution == 0) // resolution = 1.25f * latlongImage.Resolution().x * std::sqrt(2.f) / @@ -2499,12 +2498,14 @@ int denoise_optix(std::vector args) { } if (!desc[1]) { Warning("%s: image doesn't have Albedo.{R,G,B} channels. " - "Denoising quality may suffer.", inFilename); + "Denoising quality may suffer.", + inFilename); nLayers = 1; } if (!desc[2]) { Warning("%s: image doesn't have Nsx, Nsy, Nsz channels. " - "Denoising quality may suffer.", inFilename); + "Denoising quality may suffer.", + inFilename); nLayers = 1; } @@ -2512,8 +2513,7 @@ int denoise_optix(std::vector args) { size_t imageBytes = 3 * image.Resolution().x * image.Resolution().y * sizeof(float); - auto copyChannelsToGPU = [&](std::array ch, - bool flipZ = false) { + auto copyChannelsToGPU = [&](std::array ch, bool flipZ = false) { void *bufGPU; CUDA_CHECK(cudaMalloc(&bufGPU, imageBytes)); std::vector hostStaging(imageBytes / sizeof(float)); @@ -2529,8 +2529,8 @@ int denoise_optix(std::vector args) { for (int c = 0; c < 3; ++c) hostStaging[offset++] = v[c]; } - CUDA_CHECK(cudaMemcpy(bufGPU, hostStaging.data(), imageBytes, - cudaMemcpyHostToDevice)); + CUDA_CHECK( + cudaMemcpy(bufGPU, hostStaging.data(), imageBytes, cudaMemcpyHostToDevice)); return bufGPU; }; RGB *rgbGPU = (RGB *)copyChannelsToGPU({"R", "G", "B"}); @@ -2651,9 +2651,10 @@ int main(int argc, char *argv[]) { if (pixel[0] - width < 0 || pixel[0] + width >= image.Resolution().x || pixel[0] - width < 0 || pixel[0] + width >= image.Resolution().y) { - Error("%s: pixel (%d, %d) with width %d doesn't work with resolution (%d, %d).", - filename, pixel[0], pixel[0], width, image.Resolution().x, - image.Resolution().y); + Error( + "%s: pixel (%d, %d) with width %d doesn't work with resolution (%d, %d).", + filename, pixel[0], pixel[0], width, image.Resolution().x, + image.Resolution().y); return 1; } diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index 550fbc76a..c2fffd020 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -541,8 +541,9 @@ void LightPathIntegrator::EvaluatePixelSample(Point2i pPixel, int sampleIndex, light.L(les->intr->p(), les->intr->n, les->intr->uv, cs->wi, lambda); if (Le && Unoccluded(cs->pRef, cs->pLens)) { // Compute visible light's path contribution and add to film - SampledSpectrum L = Le * DistanceSquared(cs->pRef.p(), cs->pLens.p()) * cs->Wi / - (lightPDF * pdf * cs->pdf); + SampledSpectrum L = Le * + DistanceSquared(cs->pRef.p(), cs->pLens.p()) * + cs->Wi / (lightPDF * pdf * cs->pdf); camera.GetFilm().AddSplat(cs->pRaster, L, lambda); } } diff --git a/src/pbrt/cpu/integrators_test.cpp b/src/pbrt/cpu/integrators_test.cpp index 748640795..dfcc7b6f1 100644 --- a/src/pbrt/cpu/integrators_test.cpp +++ b/src/pbrt/cpu/integrators_test.cpp @@ -139,9 +139,8 @@ std::vector GetScenes() { // properly normalized (this is usually all handled inside *Light::Create()) ConstantSpectrum Le(1); Float scale = 0.5 / SpectrumToPhotometric(&Le); - Light areaLight = - new DiffuseAreaLight(identity, MediumInterface(), &Le, scale, sphere, nullptr, - Image(), nullptr, false); + Light areaLight = new DiffuseAreaLight(identity, MediumInterface(), &Le, scale, + sphere, nullptr, Image(), nullptr, false); std::vector lights; lights.push_back(areaLight); diff --git a/src/pbrt/film.cpp b/src/pbrt/film.cpp index 1e28313cc..14719c328 100644 --- a/src/pbrt/film.cpp +++ b/src/pbrt/film.cpp @@ -853,7 +853,8 @@ SpectralFilm::SpectralFilm(FilmBaseParameters p, Float lambdaMin, Float lambdaMa filterIntegral = filter.Integral(); CHECK(!pixelBounds.IsEmpty()); - filmPixelMemory += pixelBounds.Area() * (sizeof(Pixel) + 3 * nBuckets * sizeof(double)); + filmPixelMemory += + pixelBounds.Area() * (sizeof(Pixel) + 3 * nBuckets * sizeof(double)); // Allocate memory for the pixel buffers in big arrays. Note that it's // wasteful (but convenient) to be storing three pointers in each @@ -896,7 +897,8 @@ RGB SpectralFilm::GetPixelRGB(Point2i p, Float splatScale) const { return rgb; } -void SpectralFilm::AddSplat(Point2f p, SampledSpectrum L, const SampledWavelengths &lambda) { +void SpectralFilm::AddSplat(Point2f p, SampledSpectrum L, + const SampledWavelengths &lambda) { // This, too, is similar to RGBFilm::AddSplat(), with additions for // spectra. @@ -956,8 +958,8 @@ Image SpectralFilm::GetImage(ImageMetadata *metadata, Float splatScale) { for (int i = 0; i < nBuckets; ++i) { // The OpenEXR spectral layout takes the bucket center (and then // determines bucket widths based on the neighbor wavelengths). - std::string lambda = StringPrintf("%.3fnm", - Lerp((i + 0.5f) / nBuckets, lambdaMin, lambdaMax)); + std::string lambda = + StringPrintf("%.3fnm", Lerp((i + 0.5f) / nBuckets, lambdaMin, lambdaMax)); // Convert any '.' to ',' in the number since OpenEXR uses '.' for // separating layers. std::replace(lambda.begin(), lambda.end(), '.', ','); @@ -1017,14 +1019,16 @@ Image SpectralFilm::GetImage(ImageMetadata *metadata, Float splatScale) { } std::string SpectralFilm::ToString() const { - return StringPrintf( - "[ SpectralFilm %s lambdaMin: %f lambdaMax: %f nBuckets: %d writeFP16: %s maxComponentValue: %f ]", - BaseToString(), lambdaMin, lambdaMax, nBuckets, writeFP16, maxComponentValue); + return StringPrintf("[ SpectralFilm %s lambdaMin: %f lambdaMax: %f nBuckets: %d " + "writeFP16: %s maxComponentValue: %f ]", + BaseToString(), lambdaMin, lambdaMax, nBuckets, writeFP16, + maxComponentValue); } -SpectralFilm *SpectralFilm::Create(const ParameterDictionary ¶meters, Float exposureTime, - Filter filter, const RGBColorSpace *colorSpace, - const FileLoc *loc, Allocator alloc) { +SpectralFilm *SpectralFilm::Create(const ParameterDictionary ¶meters, + Float exposureTime, Filter filter, + const RGBColorSpace *colorSpace, const FileLoc *loc, + Allocator alloc) { PixelSensor *sensor = PixelSensor::Create(parameters, colorSpace, exposureTime, loc, alloc); FilmBaseParameters filmBaseParameters(parameters, filter, sensor, loc); @@ -1039,8 +1043,9 @@ SpectralFilm *SpectralFilm::Create(const ParameterDictionary ¶meters, Float Float lambdaMax = parameters.GetOneFloat("lambdamax", Lambda_max); Float maxComponentValue = parameters.GetOneFloat("maxcomponentvalue", Infinity); - return alloc.new_object(filmBaseParameters, lambdaMin, lambdaMax, nBuckets, - colorSpace, maxComponentValue, writeFP16, alloc); + return alloc.new_object(filmBaseParameters, lambdaMin, lambdaMax, + nBuckets, colorSpace, maxComponentValue, + writeFP16, alloc); } Film Film::Create(const std::string &name, const ParameterDictionary ¶meters, diff --git a/src/pbrt/film.h b/src/pbrt/film.h index 5b3bf37be..9f964e2fc 100644 --- a/src/pbrt/film.h +++ b/src/pbrt/film.h @@ -295,9 +295,7 @@ class RGBFilm : public FilmBase { return outputRGBFromSensorRGB * sensorRGB; } - PBRT_CPU_GPU void ResetPixel(Point2i p) { - std::memset(&pixels[p], 0, sizeof(Pixel)); - } + PBRT_CPU_GPU void ResetPixel(Point2i p) { std::memset(&pixels[p], 0, sizeof(Pixel)); } private: // RGBFilm::Pixel Definition @@ -371,9 +369,7 @@ class GBufferFilm : public FilmBase { std::string ToString() const; - PBRT_CPU_GPU void ResetPixel(Point2i p) { - std::memset(&pixels[p], 0, sizeof(Pixel)); - } + PBRT_CPU_GPU void ResetPixel(Point2i p) { std::memset(&pixels[p], 0, sizeof(Pixel)); } private: // GBufferFilm::Pixel Definition @@ -461,10 +457,9 @@ class SpectralFilm : public FilmBase { PBRT_CPU_GPU RGB GetPixelRGB(Point2i p, Float splatScale = 1) const; - SpectralFilm(FilmBaseParameters p, Float lambdaMin, Float lambdaMax, - int nBuckets, const RGBColorSpace *colorSpace, - Float maxComponentValue = Infinity, bool writeFP16 = true, - Allocator alloc = {}); + SpectralFilm(FilmBaseParameters p, Float lambdaMin, Float lambdaMax, int nBuckets, + const RGBColorSpace *colorSpace, Float maxComponentValue = Infinity, + bool writeFP16 = true, Allocator alloc = {}); static SpectralFilm *Create(const ParameterDictionary ¶meters, Float exposureTime, Filter filter, const RGBColorSpace *colorSpace, @@ -495,8 +490,8 @@ class SpectralFilm : public FilmBase { pix.rgbSum[0] = pix.rgbSum[1] = pix.rgbSum[2] = 0.; pix.rgbWeightSum = 0.; pix.rgbSplat[0] = pix.rgbSplat[1] = pix.rgbSplat[2] = 0.; - std::memset(pix.bucketSums, 0, nBuckets *sizeof(double)); - std::memset(pix.weightSums, 0, nBuckets *sizeof(double)); + std::memset(pix.bucketSums, 0, nBuckets * sizeof(double)); + std::memset(pix.weightSums, 0, nBuckets * sizeof(double)); std::memset(pix.bucketSplats, 0, nBuckets * sizeof(AtomicDouble)); } diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index e0436d496..8b8a76984 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -32,11 +32,11 @@ #ifdef NVTX #ifdef UNICODE #undef UNICODE -#endif // UNICODE +#endif // UNICODE #include #ifdef RGB #undef RGB -#endif // RGB +#endif // RGB #endif #define OPTIX_CHECK(EXPR) \ @@ -369,9 +369,8 @@ OptiXAggregate::BVH OptiXAggregate::buildBVHForTriangles( TriangleMesh *mesh = nullptr; if (shape.name == "trianglemesh") { - mesh = - Triangle::CreateMesh(shape.renderFromObject, shape.reverseOrientation, - shape.parameters, &shape.loc, alloc); + mesh = Triangle::CreateMesh(shape.renderFromObject, shape.reverseOrientation, + shape.parameters, &shape.loc, alloc); CHECK(mesh != nullptr); } else if (shape.name == "loopsubdiv") { // Copied from pbrt/shapes.cpp... :-p @@ -379,12 +378,12 @@ OptiXAggregate::BVH OptiXAggregate::buildBVHForTriangles( std::vector vertexIndices = shape.parameters.GetIntArray("indices"); if (vertexIndices.empty()) ErrorExit(&shape.loc, "Vertex indices \"indices\" not " - "provided for LoopSubdiv shape."); + "provided for LoopSubdiv shape."); std::vector P = shape.parameters.GetPoint3fArray("P"); if (P.empty()) ErrorExit(&shape.loc, "Vertex positions \"P\" not provided " - "for LoopSubdiv shape."); + "for LoopSubdiv shape."); // don't actually use this for now... std::string scheme = shape.parameters.GetOneString("scheme", "loop"); @@ -418,11 +417,11 @@ OptiXAggregate::BVH OptiXAggregate::buildBVHForTriangles( } mesh = alloc.new_object( - *shape.renderFromObject, shape.reverseOrientation, plyMesh.triIndices, - plyMesh.p, std::vector(), plyMesh.n, plyMesh.uv, - plyMesh.faceIndices, alloc); + *shape.renderFromObject, shape.reverseOrientation, plyMesh.triIndices, + plyMesh.p, std::vector(), plyMesh.n, plyMesh.uv, + plyMesh.faceIndices, alloc); } else - LOG_FATAL("Logic error in GPUAggregate::buildBVHForTriangles()"); + LOG_FATAL("Logic error in GPUAggregate::buildBVHForTriangles()"); Bounds3f bounds; for (size_t i = 0; i < mesh->nVertices; ++i) @@ -432,7 +431,6 @@ OptiXAggregate::BVH OptiXAggregate::buildBVHForTriangles( meshBounds[meshIndex] = bounds; }); - BVH bvh(nMeshes); std::vector optixBuildInputs(nMeshes); std::vector pDeviceDevicePtrs(nMeshes); @@ -1048,7 +1046,7 @@ OptixModule OptiXAggregate::createOptiXModule(OptixDeviceContext optixContext, moduleCompileOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_MODERATE; #else moduleCompileOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO; -#endif // OPTIX_VERSION +#endif // OPTIX_VERSION #else moduleCompileOptions.optLevel = OPTIX_COMPILE_OPTIMIZATION_DEFAULT; moduleCompileOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE; @@ -1161,7 +1159,7 @@ OptiXAggregate::OptiXAggregate( // kernel is running on the GPU to build a BVH... (Issue #164). if (Options->useGPU) DisableThreadPool(); -#endif // PBRT_IS_WINDOWS +#endif // PBRT_IS_WINDOWS ThreadLocal threadCUDAStreams([]() { cudaStream_t stream; @@ -1354,17 +1352,18 @@ OptiXAggregate::OptiXAggregate( AsyncJob *triJob = RunAsync([&]() { BVH triangleBVH = buildBVHForTriangles( scene.shapes, plyMeshes, optixContext, hitPGTriangle, anyhitPGShadowTriangle, - hitPGRandomHitTriangle, textures.floatTextures, namedMaterials, materials, media, - shapeIndexToAreaLights, threadAllocators, threadCUDAStreams); + hitPGRandomHitTriangle, textures.floatTextures, namedMaterials, materials, + media, shapeIndexToAreaLights, threadAllocators, threadCUDAStreams); int sbtOffset = addHGRecords(triangleBVH); return GAS{triangleBVH, sbtOffset}; }); AsyncJob *blpJob = RunAsync([&]() { - BVH blpBVH = buildBVHForBLPs( - scene.shapes, optixContext, hitPGBilinearPatch, anyhitPGShadowBilinearPatch, - hitPGRandomHitBilinearPatch, textures.floatTextures, namedMaterials, materials, - media, shapeIndexToAreaLights, threadAllocators, threadCUDAStreams); + BVH blpBVH = + buildBVHForBLPs(scene.shapes, optixContext, hitPGBilinearPatch, + anyhitPGShadowBilinearPatch, hitPGRandomHitBilinearPatch, + textures.floatTextures, namedMaterials, materials, media, + shapeIndexToAreaLights, threadAllocators, threadCUDAStreams); int bilinearSBTOffset = addHGRecords(blpBVH); return GAS{blpBVH, bilinearSBTOffset}; }); @@ -1372,8 +1371,8 @@ OptiXAggregate::OptiXAggregate( AsyncJob *quadricJob = RunAsync([&]() { BVH quadricBVH = buildBVHForQuadrics( scene.shapes, optixContext, hitPGQuadric, anyhitPGShadowQuadric, - hitPGRandomHitQuadric, textures.floatTextures, namedMaterials, materials, media, - shapeIndexToAreaLights, threadAllocators, threadCUDAStreams); + hitPGRandomHitQuadric, textures.floatTextures, namedMaterials, materials, + media, shapeIndexToAreaLights, threadAllocators, threadCUDAStreams); int quadricSBTOffset = addHGRecords(quadricBVH); return GAS{quadricBVH, quadricSBTOffset}; }); @@ -1459,7 +1458,8 @@ OptiXAggregate::OptiXAggregate( // Get the appropriate instanceMap iterator for each instance use, just // once, and in parallel. While we're at it, count the total number of // OptixInstances that will be added to iasInstances. - std::vector::const_iterator> + std::vector< + std::unordered_map::const_iterator> instanceMapIters(scene.instances.size()); std::atomic totalOptixInstances{0}; std::vector numValidHandles(scene.instances.size()); @@ -1617,8 +1617,8 @@ OptiXAggregate::OptiXAggregate( #ifdef PBRT_IS_WINDOWS if (Options->useGPU) - ReenableThreadPool(); -#endif // PBRT_IS_WINDOWS + ReenableThreadPool(); +#endif // PBRT_IS_WINDOWS } OptiXAggregate::ParamBufferState &OptiXAggregate::getParamBuffer( diff --git a/src/pbrt/gpu/cudagl.h b/src/pbrt/gpu/cudagl.h index 1543ad042..db6e055fc 100644 --- a/src/pbrt/gpu/cudagl.h +++ b/src/pbrt/gpu/cudagl.h @@ -166,7 +166,8 @@ static size_t pixelFormatSize(BufferImageFormat format) { } } -inline BufferDisplay::BufferDisplay(BufferImageFormat image_format) : m_image_format(image_format) { +inline BufferDisplay::BufferDisplay(BufferImageFormat image_format) + : m_image_format(image_format) { GLuint m_vertex_array; GL_CHECK(glGenVertexArrays(1, &m_vertex_array)); GL_CHECK(glBindVertexArray(m_vertex_array)); @@ -224,8 +225,9 @@ void main() } inline void BufferDisplay::display(const int32_t screen_res_x, const int32_t screen_res_y, - const int32_t framebuf_res_x, const int32_t framebuf_res_y, - const uint32_t pbo) const { + const int32_t framebuf_res_x, + const int32_t framebuf_res_y, + const uint32_t pbo) const { GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0)); GL_CHECK(glViewport(0, 0, framebuf_res_x, framebuf_res_y)); @@ -276,7 +278,7 @@ inline void BufferDisplay::display(const int32_t screen_res_x, const int32_t scr GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, m_quad_vertex_buffer)); GL_CHECK(glVertexAttribPointer(0, // attribute 0. No particular reason for 0, but // must match the layout in the shader. - 3, // size + 3, // size GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride @@ -288,7 +290,8 @@ inline void BufferDisplay::display(const int32_t screen_res_x, const int32_t scr else GL_CHECK(glDisable(GL_FRAMEBUFFER_SRGB)); - GL_CHECK(glDrawArrays(GL_TRIANGLES, 0, 6)); // 2*3 indices starting at 0 -> 2 triangles + GL_CHECK( + glDrawArrays(GL_TRIANGLES, 0, 6)); // 2*3 indices starting at 0 -> 2 triangles GL_CHECK(glDisableVertexAttribArray(0)); @@ -308,8 +311,7 @@ class CUDAOutputBuffer { const PIXEL_FORMAT *GetReadbackPixels(); void Draw(int windowWidth, int windowHeight) { - display->display(m_width, m_height, windowWidth, windowHeight, - getPBO()); + display->display(m_width, m_height, windowWidth, windowHeight, getPBO()); } PIXEL_FORMAT *Map(); diff --git a/src/pbrt/gpu/denoiser.cpp b/src/pbrt/gpu/denoiser.cpp index 20b42c5a4..db66c5f34 100644 --- a/src/pbrt/gpu/denoiser.cpp +++ b/src/pbrt/gpu/denoiser.cpp @@ -7,9 +7,9 @@ #include #include -#include #include #include +#include #include #include @@ -130,4 +130,4 @@ void Denoiser::Denoise(RGB *rgb, Normal3f *n, RGB *albedo, RGB *result) { #endif } -} // namespace pbrt +} // namespace pbrt diff --git a/src/pbrt/gpu/denoiser.h b/src/pbrt/gpu/denoiser.h index fbe8b81ef..6de5159c2 100644 --- a/src/pbrt/gpu/denoiser.h +++ b/src/pbrt/gpu/denoiser.h @@ -15,14 +15,14 @@ namespace pbrt { class Denoiser { - public: + public: Denoiser(Vector2i resolution, bool haveAlbedoAndNormal); // All pointers should be to GPU memory. // |n| and |albedo| should be nullptr iff \haveAlbedoAndNormal| is false. void Denoise(RGB *rgb, Normal3f *n, RGB *albedo, RGB *result); - private: + private: Vector2i resolution; bool haveAlbedoAndNormal; OptixDenoiser denoiserHandle; @@ -30,6 +30,6 @@ class Denoiser { void *denoiserState, *scratchBuffer, *intensity; }; -} // namespace pbrt +} // namespace pbrt -#endif // PBRT_GPU_DENOISER_H +#endif // PBRT_GPU_DENOISER_H diff --git a/src/pbrt/lights_test.cpp b/src/pbrt/lights_test.cpp index 8d7eedf5c..b25bb75ee 100644 --- a/src/pbrt/lights_test.cpp +++ b/src/pbrt/lights_test.cpp @@ -174,7 +174,8 @@ TEST(ProjectionLight, Sampling) { TEST(LightBounds, Basics) { LightBounds bounds(Bounds3f(Point3f(0, 0, 0), Point3f(.1, .1, .01)), - Vector3f(0, 0, 1), 1.f /* phi */, std::cos(0.f) /* theta_o: normal spread */, + Vector3f(0, 0, 1), 1.f /* phi */, + std::cos(0.f) /* theta_o: normal spread */, std::cos(Pi / 2) /* theta_e: falloff given visible normal */, false /* two-sided */); diff --git a/src/pbrt/lightsamplers_test.cpp b/src/pbrt/lightsamplers_test.cpp index 905c42105..dca86f65d 100644 --- a/src/pbrt/lightsamplers_test.cpp +++ b/src/pbrt/lightsamplers_test.cpp @@ -26,8 +26,7 @@ TEST(BVHLightSampling, OneSpot) { std::vector lights; ConstantSpectrum one(1.f); lights.push_back(new SpotLight(id, MediumInterface(), &one, 1.f /* scale */, - 45.f /* total width */, - 44.f /* falloff start */)); + 45.f /* total width */, 44.f /* falloff start */)); BVHLightSampler distrib(lights, Allocator()); RNG rng; @@ -96,8 +95,7 @@ TEST(BVHLightSampling, Point) { ASSERT_TRUE((bool)sampledLight); EXPECT_GT(sampledLight->p, 0); - sumWt[lightToIndex[sampledLight->light]] += - 1 / (sampledLight->p * nSamples); + sumWt[lightToIndex[sampledLight->light]] += 1 / (sampledLight->p * nSamples); EXPECT_FLOAT_EQ(sampledLight->p, distrib.PMF(intr, sampledLight->light)); } @@ -207,7 +205,8 @@ TEST(BVHLightSampling, OneTri) { std::vector lights; ConstantSpectrum one(1.f); lights.push_back(new DiffuseAreaLight(id, MediumInterface(), &one, 1.f, tris[0], - nullptr, Image(), nullptr, false /* two sided */)); + nullptr, Image(), nullptr, + false /* two sided */)); BVHLightSampler distrib(lights, Allocator()); @@ -233,8 +232,8 @@ TEST(BVHLightSampling, OneTri) { } } -static std::tuple, std::vector> randomLights( - int n, Allocator alloc) { +static std::tuple, std::vector> randomLights(int n, + Allocator alloc) { std::vector lights; std::vector allTris; RNG rng(6502); @@ -248,9 +247,8 @@ static std::tuple, std::vector> randomLights( std::vector p{Point3f{r(), r(), r()}, Point3f{r(), r(), r()}, Point3f{r(), r(), r()}}; // leaks... - TriangleMesh *mesh = new TriangleMesh(id, false /* rev orientation */, - indices, p, {}, {}, {}, {}, - Allocator()); + TriangleMesh *mesh = new TriangleMesh( + id, false /* rev orientation */, indices, p, {}, {}, {}, {}, Allocator()); auto tris = Triangle::CreateTriangles(mesh, Allocator()); CHECK_EQ(1, tris.size()); // EXPECT doesn't work since this is in a // function :-p diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index be6765bfd..7bc89b2ab 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -41,10 +41,11 @@ std::string NormalBumpEvalContext::ToString() const { // DielectricMaterial Method Definitions std::string DielectricMaterial::ToString() const { - return StringPrintf("[ DielectricMaterial displacement: %s normalMap: %s uRoughness: %s " - "vRoughness: %s eta: %s remapRoughness: %s ]", - displacement, normalMap ? normalMap->ToString() : std::string("(nullptr)"), - uRoughness, vRoughness, eta, remapRoughness); + return StringPrintf( + "[ DielectricMaterial displacement: %s normalMap: %s uRoughness: %s " + "vRoughness: %s eta: %s remapRoughness: %s ]", + displacement, normalMap ? normalMap->ToString() : std::string("(nullptr)"), + uRoughness, vRoughness, eta, remapRoughness); } DielectricMaterial *DielectricMaterial::Create( @@ -74,9 +75,9 @@ DielectricMaterial *DielectricMaterial::Create( // ThinDielectricMaterial Method Definitions std::string ThinDielectricMaterial::ToString() const { - return StringPrintf("[ ThinDielectricMaterial displacement: %s normalMap: %s eta: %s ]", - displacement, normalMap ? normalMap->ToString() - : std::string("(nullptr)"), eta); + return StringPrintf( + "[ ThinDielectricMaterial displacement: %s normalMap: %s eta: %s ]", displacement, + normalMap ? normalMap->ToString() : std::string("(nullptr)"), eta); } ThinDielectricMaterial *ThinDielectricMaterial::Create( @@ -182,10 +183,10 @@ HairMaterial *HairMaterial::Create(const TextureParameterDictionary ¶meters, // DiffuseMaterial Method Definitions std::string DiffuseMaterial::ToString() const { - return StringPrintf("[ DiffuseMaterial displacement: %s normapMap: %s reflectance: %s ]", - displacement, - normalMap ? normalMap->ToString() : std::string("(nullptr)"), - reflectance); + return StringPrintf( + "[ DiffuseMaterial displacement: %s normapMap: %s reflectance: %s ]", + displacement, normalMap ? normalMap->ToString() : std::string("(nullptr)"), + reflectance); } DiffuseMaterial *DiffuseMaterial::Create(const TextureParameterDictionary ¶meters, @@ -207,8 +208,8 @@ std::string ConductorMaterial::ToString() const { "k: %s reflectance: %s uRoughness: %s vRoughness: %s " "remapRoughness: %s ]", displacement, - normalMap ? normalMap->ToString() : std::string("(nullptr)"), - eta, k, reflectance, uRoughness, vRoughness, remapRoughness); + normalMap ? normalMap->ToString() : std::string("(nullptr)"), eta, + k, reflectance, uRoughness, vRoughness, remapRoughness); } ConductorMaterial *ConductorMaterial::Create(const TextureParameterDictionary ¶meters, @@ -291,8 +292,7 @@ std::string CoatedDiffuseMaterial::ToString() const { return StringPrintf( "[ CoatedDiffuseMaterial displacement: %s normalMap: %s reflectance: %s " "uRoughness: %s vRoughness: %s thickness: %s eta: %s remapRoughness: %s ]", - displacement, - normalMap ? normalMap->ToString() : std::string("(nullptr)"), + displacement, normalMap ? normalMap->ToString() : std::string("(nullptr)"), reflectance, uRoughness, vRoughness, thickness, eta, remapRoughness); } @@ -395,16 +395,16 @@ template CoatedConductorBxDF CoatedConductorMaterial::GetBxDF( SampledWavelengths &lambda) const; std::string CoatedConductorMaterial::ToString() const { - return StringPrintf("[ CoatedConductorMaterial displacement: %s normalMap: %s " - "interfaceURoughness: %s interfaceVRoughness: %s thickness: %s " - "interfaceEta: %s g: %s albedo: %s conductorURoughness: %s " - "conductorVRoughness: %s conductorEta: %s k: %s " - "conductorReflectance: %s remapRoughness: %s maxDepth: %d nSamples: %d ]", - displacement, - normalMap ? normalMap->ToString() : std::string("(nullptr)"), - interfaceURoughness, interfaceVRoughness, thickness, - interfaceEta, g, albedo, conductorURoughness, conductorVRoughness, - conductorEta, k, reflectance, remapRoughness, maxDepth, nSamples); + return StringPrintf( + "[ CoatedConductorMaterial displacement: %s normalMap: %s " + "interfaceURoughness: %s interfaceVRoughness: %s thickness: %s " + "interfaceEta: %s g: %s albedo: %s conductorURoughness: %s " + "conductorVRoughness: %s conductorEta: %s k: %s " + "conductorReflectance: %s remapRoughness: %s maxDepth: %d nSamples: %d ]", + displacement, normalMap ? normalMap->ToString() : std::string("(nullptr)"), + interfaceURoughness, interfaceVRoughness, thickness, interfaceEta, g, albedo, + conductorURoughness, conductorVRoughness, conductorEta, k, reflectance, + remapRoughness, maxDepth, nSamples); } CoatedConductorMaterial *CoatedConductorMaterial::Create( diff --git a/src/pbrt/options.cpp b/src/pbrt/options.cpp index 9c7e522b3..ae931658e 100644 --- a/src/pbrt/options.cpp +++ b/src/pbrt/options.cpp @@ -36,18 +36,19 @@ std::string PBRTOptions::ToString() const { return StringPrintf( "[ PBRTOptions seed: %s quiet: %s disablePixelJitter: %s " "disableWavelengthJitter: %s disableTextureFiltering: %s forceDiffuse: %s " - "useGPU: %s wavefront: %s interactive: %s renderingSpace: %s nThreads: %s logLevel: %s logFile: " + "useGPU: %s wavefront: %s interactive: %s renderingSpace: %s nThreads: %s " + "logLevel: %s logFile: " "%s logUtilization: %s writePartialImages: %s recordPixelStatistics: %s " "printStatistics: %s pixelSamples: %s gpuDevice: %s quickRender: %s upgrade: %s " "imageFile: %s mseReferenceImage: %s mseReferenceOutput: %s debugStart: %s " "displayServer: %s cropWindow: %s pixelBounds: %s pixelMaterial: %s " "displacementEdgeScale: %f ]", seed, quiet, disablePixelJitter, disableWavelengthJitter, disableTextureFiltering, - forceDiffuse, useGPU, wavefront, interactive, renderingSpace, nThreads, logLevel, logFile, - logUtilization, writePartialImages, recordPixelStatistics, printStatistics, - pixelSamples, gpuDevice, quickRender, upgrade, imageFile, mseReferenceImage, - mseReferenceOutput, debugStart, displayServer, cropWindow, pixelBounds, - pixelMaterial, displacementEdgeScale); + forceDiffuse, useGPU, wavefront, interactive, renderingSpace, nThreads, logLevel, + logFile, logUtilization, writePartialImages, recordPixelStatistics, + printStatistics, pixelSamples, gpuDevice, quickRender, upgrade, imageFile, + mseReferenceImage, mseReferenceOutput, debugStart, displayServer, cropWindow, + pixelBounds, pixelMaterial, displacementEdgeScale); } } // namespace pbrt diff --git a/src/pbrt/parser.cpp b/src/pbrt/parser.cpp index 9a18a595d..4a6bb2439 100644 --- a/src/pbrt/parser.cpp +++ b/src/pbrt/parser.cpp @@ -220,7 +220,8 @@ std::unique_ptr Tokenizer::CreateFromFile( std::unique_ptr Tokenizer::CreateFromString( std::string str, std::function errorCallback) { - return std::make_unique(std::move(str), "", std::move(errorCallback)); + return std::make_unique(std::move(str), "", + std::move(errorCallback)); } Tokenizer::Tokenizer(std::string str, std::string filename, @@ -598,7 +599,8 @@ static ParsedParameterVector parseParameters( } void parse(ParserTarget *target, std::unique_ptr t) { - FormattingParserTarget *formattingTarget = dynamic_cast(target); + FormattingParserTarget *formattingTarget = + dynamic_cast(target); bool formatting = formattingTarget; static std::atomic warnedTransformBeginEndDeprecated{false}; @@ -644,7 +646,8 @@ void parse(ParserTarget *target, std::unique_ptr t) { // Swallow comments, unless --format or --toply was given, in // which case they're printed to stdout. if (formatting) - printf("%s%s\n", dynamic_cast(target)->indent().c_str(), + printf("%s%s\n", + dynamic_cast(target)->indent().c_str(), toString(tok->token).c_str()); return nextToken(flags); } else @@ -660,8 +663,8 @@ void parse(ParserTarget *target, std::unique_ptr t) { // Helper function for pbrt API entrypoints that take a single string // parameter and a ParameterVector (e.g. pbrtShape()). auto basicParamListEntrypoint = - [&](void (ParserTarget::*apiFunc)(const std::string &, - ParsedParameterVector, FileLoc), + [&](void (ParserTarget::*apiFunc)(const std::string &, ParsedParameterVector, + FileLoc), FileLoc loc) { Token t = *nextToken(TokenRequired); std::string_view dequoted = dequoteString(t); @@ -752,7 +755,8 @@ void parse(ParserTarget *target, std::unique_ptr t) { std::string filename = toString(dequoteString(filenameToken)); if (formatting) Printf("%sInclude \"%s\"\n", - dynamic_cast(target)->indent(), filename); + dynamic_cast(target)->indent(), + filename); else { filename = ResolveFilename(filename); std::unique_ptr tinc = @@ -769,12 +773,15 @@ void parse(ParserTarget *target, std::unique_ptr t) { std::string filename = toString(dequoteString(filenameToken)); if (formatting) Printf("%sImport \"%s\"\n", - dynamic_cast(target)->indent(), filename); + dynamic_cast(target)->indent(), + filename); else { - BasicSceneBuilder *builder = dynamic_cast(target); + BasicSceneBuilder *builder = + dynamic_cast(target); CHECK(builder); - if (builder->currentBlock != BasicSceneBuilder::BlockState::WorldBlock) + if (builder->currentBlock != + BasicSceneBuilder::BlockState::WorldBlock) ErrorExit(&tok->loc, "Import statement only allowed inside world " "definition block."); @@ -816,15 +823,14 @@ void parse(ParserTarget *target, std::unique_ptr t) { for (int i = 0; i < 9; ++i) v[i] = parseFloat(*nextToken(TokenRequired)); target->LookAt(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], - tok->loc); + tok->loc); } else syntaxError(*tok); break; case 'M': if (tok->token == "MakeNamedMaterial") - basicParamListEntrypoint(&ParserTarget::MakeNamedMaterial, - tok->loc); + basicParamListEntrypoint(&ParserTarget::MakeNamedMaterial, tok->loc); else if (tok->token == "MakeNamedMedium") basicParamListEntrypoint(&ParserTarget::MakeNamedMedium, tok->loc); else if (tok->token == "Material") @@ -1035,7 +1041,7 @@ FormattingParserTarget::~FormattingParserTarget() { } void FormattingParserTarget::Option(const std::string &name, const std::string &value, - FileLoc loc) { + FileLoc loc) { std::string nName = normalizeArg(name); Printf("%sOption \"%s\" %s\n", indent(), name, value); } @@ -1048,7 +1054,8 @@ void FormattingParserTarget::Translate(Float dx, Float dy, Float dz, FileLoc loc Printf("%sTranslate %f %f %f\n", indent(), dx, dy, dz); } -void FormattingParserTarget::Rotate(Float angle, Float ax, Float ay, Float az, FileLoc loc) { +void FormattingParserTarget::Rotate(Float angle, Float ax, Float ay, Float az, + FileLoc loc) { Printf("%sRotate %f %f %f %f\n", indent(), angle, ax, ay, az); } @@ -1056,8 +1063,8 @@ void FormattingParserTarget::Scale(Float sx, Float sy, Float sz, FileLoc loc) { Printf("%sScale %f %f %f\n", indent(), sx, sy, sz); } -void FormattingParserTarget::LookAt(Float ex, Float ey, Float ez, Float lx, Float ly, Float lz, - Float ux, Float uy, Float uz, FileLoc loc) { +void FormattingParserTarget::LookAt(Float ex, Float ey, Float ez, Float lx, Float ly, + Float lz, Float ux, Float uy, Float uz, FileLoc loc) { Printf("%sLookAt %f %f %f\n%s %f %f %f\n%s %f %f %f\n", indent(), ex, ey, ez, indent(), lx, ly, lz, indent(), ux, uy, uz); } @@ -1104,8 +1111,8 @@ void FormattingParserTarget::ColorSpace(const std::string &n, FileLoc loc) { Printf("%sColorSpace \"%s\"\n", indent(), n); } -void FormattingParserTarget::PixelFilter(const std::string &name, ParsedParameterVector params, - FileLoc loc) { +void FormattingParserTarget::PixelFilter(const std::string &name, + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(std::move(params), RGBColorSpace::sRGB); std::string extra; @@ -1136,7 +1143,7 @@ void FormattingParserTarget::PixelFilter(const std::string &name, ParsedParamete } void FormattingParserTarget::Film(const std::string &type, ParsedParameterVector params, - FileLoc loc) { + FileLoc loc) { ParameterDictionary dict(std::move(params), RGBColorSpace::sRGB); std::string extra; @@ -1161,8 +1168,8 @@ void FormattingParserTarget::Film(const std::string &type, ParsedParameterVector std::cout << extra << dict.ToParameterList(catIndentCount); } -void FormattingParserTarget::Sampler(const std::string &name, ParsedParameterVector params, - FileLoc loc) { +void FormattingParserTarget::Sampler(const std::string &name, + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(std::move(params), RGBColorSpace::sRGB); if (upgrade) { @@ -1179,16 +1186,16 @@ void FormattingParserTarget::Sampler(const std::string &name, ParsedParameterVec std::cout << dict.ToParameterList(catIndentCount); } -void FormattingParserTarget::Accelerator(const std::string &name, ParsedParameterVector params, - FileLoc loc) { +void FormattingParserTarget::Accelerator(const std::string &name, + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(std::move(params), RGBColorSpace::sRGB); Printf("%sAccelerator \"%s\"\n%s", indent(), name, dict.ToParameterList(catIndentCount)); } -void FormattingParserTarget::Integrator(const std::string &name, ParsedParameterVector params, - FileLoc loc) { +void FormattingParserTarget::Integrator(const std::string &name, + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(std::move(params), RGBColorSpace::sRGB); std::string extra; @@ -1223,7 +1230,7 @@ void FormattingParserTarget::Integrator(const std::string &name, ParsedParameter } void FormattingParserTarget::Camera(const std::string &name, ParsedParameterVector params, - FileLoc loc) { + FileLoc loc) { ParameterDictionary dict(std::move(params), RGBColorSpace::sRGB); if (upgrade && name == "environment") @@ -1238,7 +1245,7 @@ void FormattingParserTarget::Camera(const std::string &name, ParsedParameterVect } void FormattingParserTarget::MakeNamedMedium(const std::string &name, - ParsedParameterVector params, FileLoc loc) { + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(params, RGBColorSpace::sRGB); if (upgrade && name == "heterogeneous") Printf("%sMakeNamedMedium \"%s\"\n%s\n", indent(), "uniformgrid", @@ -1249,7 +1256,8 @@ void FormattingParserTarget::MakeNamedMedium(const std::string &name, } void FormattingParserTarget::MediumInterface(const std::string &insideName, - const std::string &outsideName, FileLoc loc) { + const std::string &outsideName, + FileLoc loc) { Printf("%sMediumInterface \"%s\" \"%s\"\n", indent(), insideName, outsideName); } @@ -1267,8 +1275,8 @@ void FormattingParserTarget::AttributeEnd(FileLoc loc) { Printf("%sAttributeEnd\n", indent()); } -void FormattingParserTarget::Attribute(const std::string &target, ParsedParameterVector params, - FileLoc loc) { +void FormattingParserTarget::Attribute(const std::string &target, + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(params, RGBColorSpace::sRGB); Printf("%sAttribute \"%s\" ", indent(), target); if (params.size() == 1) @@ -1291,8 +1299,8 @@ void FormattingParserTarget::TransformEnd(FileLoc loc) { } void FormattingParserTarget::Texture(const std::string &name, const std::string &type, - const std::string &texname, ParsedParameterVector params, - FileLoc loc) { + const std::string &texname, + ParsedParameterVector params, FileLoc loc) { if (upgrade) { if (definedTextures.find(name) != definedTextures.end()) { static int count = 0; @@ -1411,8 +1419,8 @@ void FormattingParserTarget::Texture(const std::string &name, const std::string } std::string FormattingParserTarget::upgradeMaterialIndex(const std::string &name, - ParameterDictionary *dict, - FileLoc loc) const { + ParameterDictionary *dict, + FileLoc loc) const { if (name != "glass" && name != "uber") return ""; @@ -1446,8 +1454,9 @@ std::string FormattingParserTarget::upgradeMaterialIndex(const std::string &name } } -std::string FormattingParserTarget::upgradeMaterial(std::string *name, ParameterDictionary *dict, - FileLoc loc) const { +std::string FormattingParserTarget::upgradeMaterial(std::string *name, + ParameterDictionary *dict, + FileLoc loc) const { std::string extra = upgradeMaterialIndex(*name, dict, loc); dict->RenameParameter("bumpmap", "displacement"); @@ -1589,8 +1598,8 @@ std::string FormattingParserTarget::upgradeMaterial(std::string *name, Parameter return extra; } -void FormattingParserTarget::Material(const std::string &name, ParsedParameterVector params, - FileLoc loc) { +void FormattingParserTarget::Material(const std::string &name, + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(params, RGBColorSpace::sRGB); if (upgrade) dict.RenameUsedTextures(definedTextures); @@ -1630,7 +1639,8 @@ void FormattingParserTarget::Material(const std::string &name, ParsedParameterVe } void FormattingParserTarget::MakeNamedMaterial(const std::string &name, - ParsedParameterVector params, FileLoc loc) { + ParsedParameterVector params, + FileLoc loc) { ParameterDictionary dict(params, RGBColorSpace::sRGB); if (upgrade) { @@ -1688,8 +1698,8 @@ static std::string upgradeMapname(const FormattingParserTarget &scene, return scene.indent(1) + StringPrintf("\"string filename\" \"%s\"\n", n); } -void FormattingParserTarget::LightSource(const std::string &name, ParsedParameterVector params, - FileLoc loc) { +void FormattingParserTarget::LightSource(const std::string &name, + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(params, RGBColorSpace::sRGB); Printf("%sLightSource \"%s\"\n", indent(), name); @@ -1744,7 +1754,7 @@ void FormattingParserTarget::LightSource(const std::string &name, ParsedParamete } void FormattingParserTarget::AreaLightSource(const std::string &name, - ParsedParameterVector params, FileLoc loc) { + ParsedParameterVector params, FileLoc loc) { ParameterDictionary dict(params, RGBColorSpace::sRGB); std::string extra; Float totalScale = 1; @@ -1810,7 +1820,7 @@ static std::string upgradeTriMeshUVs(const FormattingParserTarget &scene, } void FormattingParserTarget::Shape(const std::string &name, ParsedParameterVector params, - FileLoc loc) { + FileLoc loc) { ParameterDictionary dict(params, RGBColorSpace::sRGB); if (toPly && name == "trianglemesh") { diff --git a/src/pbrt/samplers_test.cpp b/src/pbrt/samplers_test.cpp index 140cc7a73..1081849b5 100644 --- a/src/pbrt/samplers_test.cpp +++ b/src/pbrt/samplers_test.cpp @@ -27,13 +27,15 @@ TEST(Sampler, ConsistentValues) { samplers.push_back(new PaddedSobolSampler(spp, RandomizeStrategy::FastOwen)); samplers.push_back(new PaddedSobolSampler(spp, RandomizeStrategy::Owen)); samplers.push_back(new ZSobolSampler(spp, resolution, RandomizeStrategy::None)); - samplers.push_back(new ZSobolSampler(spp, resolution, RandomizeStrategy::PermuteDigits)); + samplers.push_back( + new ZSobolSampler(spp, resolution, RandomizeStrategy::PermuteDigits)); samplers.push_back(new ZSobolSampler(spp, resolution, RandomizeStrategy::FastOwen)); samplers.push_back(new ZSobolSampler(spp, resolution, RandomizeStrategy::Owen)); samplers.push_back(new PMJ02BNSampler(spp)); samplers.push_back(new StratifiedSampler(rootSpp, rootSpp, true)); samplers.push_back(new SobolSampler(spp, resolution, RandomizeStrategy::None)); - samplers.push_back(new SobolSampler(spp, resolution, RandomizeStrategy::PermuteDigits)); + samplers.push_back( + new SobolSampler(spp, resolution, RandomizeStrategy::PermuteDigits)); samplers.push_back(new SobolSampler(spp, resolution, RandomizeStrategy::Owen)); samplers.push_back(new SobolSampler(spp, resolution, RandomizeStrategy::FastOwen)); @@ -97,8 +99,8 @@ static void checkElementary(const char *name, std::vector samples, } } -static void checkElementarySampler(const char *name, Sampler sampler, - int logSamples, int res = 1) { +static void checkElementarySampler(const char *name, Sampler sampler, int logSamples, + int res = 1) { // Get all of the samples for a pixel. int spp = sampler.SamplesPerPixel(); std::vector samples; @@ -116,8 +118,7 @@ static void checkElementarySampler(const char *name, Sampler sampler, // TODO: check Halton (where the elementary intervals are (2^i, 3^j)). TEST(PaddedSobolSampler, ElementaryIntervals) { - for (auto rand : - {RandomizeStrategy::None, RandomizeStrategy::PermuteDigits}) + for (auto rand : {RandomizeStrategy::None, RandomizeStrategy::PermuteDigits}) for (int logSamples = 2; logSamples <= 10; ++logSamples) checkElementarySampler("PaddedSobolSampler", new PaddedSobolSampler(1 << logSamples, rand), @@ -126,12 +127,12 @@ TEST(PaddedSobolSampler, ElementaryIntervals) { TEST(ZSobolSampler, ElementaryIntervals) { for (int seed : {0, 1, 5, 6, 10, 15}) - for (auto rand : - {RandomizeStrategy::None, RandomizeStrategy::PermuteDigits}) + for (auto rand : {RandomizeStrategy::None, RandomizeStrategy::PermuteDigits}) for (int logSamples = 2; logSamples <= 8; ++logSamples) - checkElementarySampler(StringPrintf("ZSobolSampler - %s - %d", rand, seed).c_str(), - new ZSobolSampler(1 << logSamples, Point2i(10, 10), rand, seed), - logSamples, 10); + checkElementarySampler( + StringPrintf("ZSobolSampler - %s - %d", rand, seed).c_str(), + new ZSobolSampler(1 << logSamples, Point2i(10, 10), rand, seed), + logSamples, 10); } TEST(SobolUnscrambledSampler, ElementaryIntervals) { @@ -144,10 +145,10 @@ TEST(SobolUnscrambledSampler, ElementaryIntervals) { TEST(SobolXORScrambledSampler, ElementaryIntervals) { for (int logSamples = 2; logSamples <= 10; ++logSamples) - checkElementarySampler( - "Sobol XOR Scrambled", - new SobolSampler(1 << logSamples, Point2i(1, 1), RandomizeStrategy::PermuteDigits), - logSamples); + checkElementarySampler("Sobol XOR Scrambled", + new SobolSampler(1 << logSamples, Point2i(1, 1), + RandomizeStrategy::PermuteDigits), + logSamples); } TEST(SobolOwenScrambledSampler, ElementaryIntervals) { diff --git a/src/pbrt/util/containers_test.cpp b/src/pbrt/util/containers_test.cpp index da5ac8c41..d6b9b14d2 100644 --- a/src/pbrt/util/containers_test.cpp +++ b/src/pbrt/util/containers_test.cpp @@ -190,7 +190,7 @@ TEST(InternCache, BadHash) { const int *p = cache.Lookup(ii); EXPECT_EQ(*p, ii); firstPass[ii] = p; - EXPECT_EQ(i+1, cache.size()); + EXPECT_EQ(i + 1, cache.size()); } for (int i = 0; i < n; ++i) { int ii = PermutationElement(i, n, 0xfeed00f5); diff --git a/src/pbrt/util/display.cpp b/src/pbrt/util/display.cpp index c0ff70da1..64f35a15c 100644 --- a/src/pbrt/util/display.cpp +++ b/src/pbrt/util/display.cpp @@ -486,8 +486,8 @@ void DisplayDynamic(std::string title, const Image &image, dynamicItems.push_back(GetImageDisplayItem(title, image, channelDesc)); } -void DisplayStatic(std::string title, Point2i resolution, - std::vector channelNames, +void DisplayStatic( + std::string title, Point2i resolution, std::vector channelNames, std::function>)> getTileValues) { DisplayItem item(title, resolution, channelNames, getTileValues); @@ -496,8 +496,8 @@ void DisplayStatic(std::string title, Point2i resolution, LOG_ERROR("Unable to display static content \"%s\".", title); } -void DisplayDynamic(std::string title, Point2i resolution, - std::vector channelNames, +void DisplayDynamic( + std::string title, Point2i resolution, std::vector channelNames, std::function>)> getTileValues) { std::lock_guard lock(mutex); dynamicItems.push_back(DisplayItem(title, resolution, channelNames, getTileValues)); diff --git a/src/pbrt/util/file.cpp b/src/pbrt/util/file.cpp index 87acb3213..f86d37942 100644 --- a/src/pbrt/util/file.cpp +++ b/src/pbrt/util/file.cpp @@ -160,24 +160,22 @@ std::string ReadDecompressedFileContents(std::string filename) { // A single libdeflate_decompressor * can't be used by multiple threads // concurrently, so make sure to do per-thread allocations of them. - static ThreadLocal decompressors([]() { - return libdeflate_alloc_decompressor(); - }); + static ThreadLocal decompressors( + []() { return libdeflate_alloc_decompressor(); }); libdeflate_decompressor *d = decompressors.Get(); std::string decompressed(size, '\0'); int retries = 0; while (true) { size_t actualOut; - libdeflate_result result = - libdeflate_gzip_decompress(d, compressed.data(), compressed.size(), - decompressed.data(), decompressed.size(), - &actualOut); + libdeflate_result result = libdeflate_gzip_decompress( + d, compressed.data(), compressed.size(), decompressed.data(), + decompressed.size(), &actualOut); switch (result) { case LIBDEFLATE_SUCCESS: CHECK_EQ(actualOut, decompressed.size()); - LOG_VERBOSE("Decompressed %s from %d to %d bytes", filename, compressed.size(), - decompressed.size()); + LOG_VERBOSE("Decompressed %s from %d to %d bytes", filename, + compressed.size(), decompressed.size()); return decompressed; case LIBDEFLATE_BAD_DATA: diff --git a/src/pbrt/util/float.h b/src/pbrt/util/float.h index 542933c79..b318442cb 100644 --- a/src/pbrt/util/float.h +++ b/src/pbrt/util/float.h @@ -54,8 +54,8 @@ static constexpr float OneMinusEpsilon = FloatOneMinusEpsilon; // Floating-point Inline Functions template -inline PBRT_CPU_GPU typename std::enable_if_t, bool> -IsNaN(T v) { +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsNaN( + T v) { #ifdef PBRT_IS_GPU_CODE return isnan(v); #else @@ -64,14 +64,13 @@ IsNaN(T v) { } template -inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsNaN( - T v) { +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsNaN(T v) { return false; } template -inline PBRT_CPU_GPU typename std::enable_if_t, bool> -IsInf(T v) { +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsInf( + T v) { #ifdef PBRT_IS_GPU_CODE return isinf(v); #else @@ -80,14 +79,13 @@ IsInf(T v) { } template -inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsInf( - T v) { +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsInf(T v) { return false; } template -inline PBRT_CPU_GPU typename std::enable_if_t, bool> -IsFinite(T v) { +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsFinite( + T v) { #ifdef PBRT_IS_GPU_CODE return isfinite(v); #else @@ -95,8 +93,7 @@ IsFinite(T v) { #endif } template -inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsFinite( - T v) { +inline PBRT_CPU_GPU typename std::enable_if_t, bool> IsFinite(T v) { return true; } diff --git a/src/pbrt/util/gui.cpp b/src/pbrt/util/gui.cpp index 94bed1911..6a54002c2 100644 --- a/src/pbrt/util/gui.cpp +++ b/src/pbrt/util/gui.cpp @@ -7,7 +7,7 @@ #include #ifdef PBRT_BUILD_GPU_RENDERER #include -#endif // PBRT_BUILD_GPU_RENDERER +#endif // PBRT_BUILD_GPU_RENDERER #include #include #include @@ -90,7 +90,8 @@ void GUI::keyboardCallback(GLFWwindow *window, int key, int scan, int action, in bool GUI::processMouse() { bool needsReset = false; double amount = 1.f; - if (!pressed) return false; + if (!pressed) + return false; if (xoffset < 0) { movingFromCamera = movingFromCamera * Rotate(-amount, Vector3f(0, 1, 0)); needsReset = true; @@ -178,30 +179,25 @@ bool GUI::processKeys() { return needsReset; } - static void glfwKeyCallback(GLFWwindow* window, int key, int scan, int action, int mods) { GUI* gui = (GUI*)glfwGetWindowUserPointer(window); gui->keyboardCallback(window, key, scan, action, mods); } - void GUI::mouseButtonCallback(GLFWwindow* window, int button, int action, int mods) { - if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) - { + if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { pressed = true; glfwGetCursorPos(window, &lastX, &lastY); } - if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) - { + if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) { pressed = false; } } -static void glfwMouseButtonCallback(GLFWwindow* window, int button, int action, int mods) -{ +static void glfwMouseButtonCallback(GLFWwindow* window, int button, int action, + int mods) { GUI* gui = (GUI*)glfwGetWindowUserPointer(window); gui->mouseButtonCallback(window, button, action, mods); - } static void glfwCursorPosCallback(GLFWwindow* window, double xpos, double ypos) { @@ -209,8 +205,7 @@ static void glfwCursorPosCallback(GLFWwindow* window, double xpos, double ypos) gui->cursorPosCallback(window, xpos, ypos); } -void GUI::cursorPosCallback(GLFWwindow* window, double xpos, double ypos) -{ +void GUI::cursorPosCallback(GLFWwindow* window, double xpos, double ypos) { xoffset = xpos - lastX; yoffset = lastY - ypos; lastX = xpos; @@ -300,12 +295,16 @@ DisplayState GUI::RefreshDisplay() { Image image(PixelFormat::Float, {width, height}, {"R", "G", "B"}); std::memcpy(image.RawPointer({0, 0}), fb, width * height * sizeof(RGB)); - RunAsync([](Image image, int frameNumber) { - // TODO: set metadata for e.g. current camera position... - ImageMetadata metadata; - image.Write(StringPrintf("pbrt-frame%05d.exr", frameNumber), metadata); - return 0; // FIXME: RunAsync() doesn't like lambdas that return void.. - }, std::move(image), frameNumber); + RunAsync( + [](Image image, int frameNumber) { + // TODO: set metadata for e.g. current camera position... + ImageMetadata metadata; + image.Write(StringPrintf("pbrt-frame%05d.exr", frameNumber), + metadata); + return 0; // FIXME: RunAsync() doesn't like lambdas that return + // void.. + }, + std::move(image), frameNumber); ++frameNumber; } diff --git a/src/pbrt/util/gui.h b/src/pbrt/util/gui.h index 32dc9693e..a115c5b99 100644 --- a/src/pbrt/util/gui.h +++ b/src/pbrt/util/gui.h @@ -55,7 +55,7 @@ class GUI { void keyboardCallback(GLFWwindow *window, int key, int scan, int action, int mods); void cursorPosCallback(GLFWwindow *window, double xpos, double ypos); - void mouseButtonCallback(GLFWwindow* window, int button, int action, int mods); + void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods); private: bool processKeys(); @@ -72,7 +72,7 @@ class GUI { Float xoffset = 0.f; Float yoffset = 0.f; double lastX = 0.f; - double lastY = 0.f;; + double lastY = 0.f; #ifdef PBRT_BUILD_GPU_RENDERER CUDAOutputBuffer *cudaFramebuffer = nullptr; diff --git a/src/pbrt/util/image.cpp b/src/pbrt/util/image.cpp index 9146d11e1..101808257 100644 --- a/src/pbrt/util/image.cpp +++ b/src/pbrt/util/image.cpp @@ -953,9 +953,10 @@ bool Image::Write(std::string name, const ImageMetadata &metadata) const { ImageChannelDesc desc = outImage.GetChannelDesc({"R", "G", "B", "A"}); if (!desc) // Still go for it. - Warning("%s: image has 4 channels but they are not R, G, B, and A. Image may be " - "garbled.", - name); + Warning( + "%s: image has 4 channels but they are not R, G, B, and A. Image may be " + "garbled.", + name); else // Reorder them as RGBA. outImage = outImage.SelectChannels(desc); @@ -1104,8 +1105,7 @@ static ImageAndMetadata ReadEXR(const std::string &name, Allocator alloc) { // Find any string or string vector attributes for (auto iter = file.header().begin(); iter != file.header().end(); ++iter) { if (strcmp(iter.attribute().typeName(), "string") == 0) { - Imf::StringAttribute &sv = - (Imf::StringAttribute &)iter.attribute(); + Imf::StringAttribute &sv = (Imf::StringAttribute &)iter.attribute(); metadata.strings[iter.name()] = sv.value(); } if (strcmp(iter.attribute().typeName(), "stringvector") == 0) { @@ -1427,7 +1427,8 @@ std::string Image::ToString() const { } std::unique_ptr Image::QuantizePixelsToU256(int *nOutOfGamut) const { - std::unique_ptr u256 = std::make_unique(NChannels() * resolution.x * resolution.y); + std::unique_ptr u256 = + std::make_unique(NChannels() * resolution.x * resolution.y); for (int y = 0; y < resolution.y; ++y) for (int x = 0; x < resolution.x; ++x) for (int c = 0; c < NChannels(); ++c) { @@ -1464,8 +1465,8 @@ bool Image::WritePNG(const std::string &filename, const ImageMetadata &metadata) } if (format == PixelFormat::U256) { - error = lodepng_encode_memory(&png, &pngSize, p8.data(), resolution.x, - resolution.y, pngColor, 8 /* bitdepth */); + error = lodepng_encode_memory(&png, &pngSize, p8.data(), resolution.x, + resolution.y, pngColor, 8 /* bitdepth */); } else { std::unique_ptr pix8 = QuantizePixelsToU256(&nOutOfGamut); error = lodepng_encode_memory(&png, &pngSize, pix8.get(), resolution.x, @@ -1503,7 +1504,8 @@ bool Image::WriteQOI(const std::string &filename, const ImageMetadata &metadata) desc.channels = NChannels(); if (Encoding() && !Encoding().Is() && !Encoding().Is()) { - Error("%s: only linear and sRGB encodings are supported by QOI.", Encoding().ToString()); //filename); + Error("%s: only linear and sRGB encodings are supported by QOI.", + Encoding().ToString()); // filename); return false; } desc.colorspace = Encoding().Is() ? QOI_LINEAR : QOI_SRGB; @@ -1536,7 +1538,8 @@ bool Image::WriteQOI(const std::string &filename, const ImageMetadata &metadata) qoiPixels = qoi_encode(rgba8.get(), &desc, &qoiSize); } - bool success = WriteFileContents(filename, std::string((const char *)qoiPixels, qoiSize)); + bool success = + WriteFileContents(filename, std::string((const char *)qoiPixels, qoiSize)); if (!success) Error("%s: error writing QOI file.", filename); @@ -1725,7 +1728,7 @@ static ImageAndMetadata ReadQOI(const std::string &filename, Allocator alloc) { std::string contents = ReadFileContents(filename); qoi_desc desc; void *pixels = qoi_decode(contents.data(), contents.size(), &desc, 0 /* channels */); - CHECK(pixels != nullptr); // qoi failure + CHECK(pixels != nullptr); // qoi failure ImageMetadata metadata; metadata.colorSpace = RGBColorSpace::sRGB; @@ -1737,18 +1740,19 @@ static ImageAndMetadata ReadQOI(const std::string &filename, Allocator alloc) { CHECK_EQ(3, desc.channels); CHECK(desc.colorspace == QOI_SRGB || desc.colorspace == QOI_LINEAR); - ColorEncoding encoding = (desc.colorspace == QOI_SRGB) ? ColorEncoding::sRGB : - ColorEncoding::Linear; + ColorEncoding encoding = + (desc.colorspace == QOI_SRGB) ? ColorEncoding::sRGB : ColorEncoding::Linear; - Image image(PixelFormat::U256, Point2i(desc.width, desc.height), channelNames, encoding, alloc); - std::memcpy(image.RawPointer({0, 0}), pixels, desc.width * desc.height * desc.channels); + Image image(PixelFormat::U256, Point2i(desc.width, desc.height), channelNames, + encoding, alloc); + std::memcpy(image.RawPointer({0, 0}), pixels, + desc.width * desc.height * desc.channels); free(pixels); return ImageAndMetadata{image, metadata}; } - bool Image::WritePFM(const std::string &filename, const ImageMetadata &metadata) const { FILE *fp = FOpenWrite(filename); if (!fp) { diff --git a/src/pbrt/util/image_test.cpp b/src/pbrt/util/image_test.cpp index 370750abd..f15b15446 100644 --- a/src/pbrt/util/image_test.cpp +++ b/src/pbrt/util/image_test.cpp @@ -480,8 +480,8 @@ TEST(Image, PngYIO) { for (int y = 0; y < res[1]; ++y) for (int x = 0; x < res[0]; ++x) - EXPECT_EQ(SRGB8ToLinear(rgbPixels[y * res[0] + x]), - read.image.GetChannel({x, y}, 0)) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[y * res[0] + x]), + read.image.GetChannel({x, y}, 0)) << " x " << x << ", y " << y << ", orig " << rgbPixels[y * res[0] + x]; EXPECT_TRUE(RemoveFile("test.png")); @@ -506,8 +506,8 @@ TEST(Image, PngRgbIO) { for (int y = 0; y < res[1]; ++y) for (int x = 0; x < res[0]; ++x) for (int c = 0; c < 3; ++c) { - EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), - image.GetChannel({x, y}, c)) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), + image.GetChannel({x, y}, c)) << " x " << x << ", y " << y << ", c " << c << ", orig " << rgbPixels[3 * y * res[0] + 3 * x + c]; } @@ -537,8 +537,8 @@ TEST(Image, PngEmojiIO) { for (int y = 0; y < res[1]; ++y) for (int x = 0; x < res[0]; ++x) for (int c = 0; c < 3; ++c) { - EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), - image.GetChannel({x, y}, c)) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), + image.GetChannel({x, y}, c)) << " x " << x << ", y " << y << ", c " << c << ", orig " << rgbPixels[3 * y * res[0] + 3 * x + c]; } @@ -565,8 +565,8 @@ TEST(Image, QoiRgbIO) { for (int y = 0; y < res[1]; ++y) for (int x = 0; x < res[0]; ++x) for (int c = 0; c < 3; ++c) { - EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), - image.GetChannel({x, y}, c)) + EXPECT_EQ(SRGB8ToLinear(rgbPixels[c + 3 * (y * res[0] + x)]), + image.GetChannel({x, y}, c)) << " x " << x << ", y " << y << ", c " << c << ", orig " << rgbPixels[3 * y * res[0] + 3 * x + c]; } diff --git a/src/pbrt/util/log.cpp b/src/pbrt/util/log.cpp index 442f57ab1..df730c028 100644 --- a/src/pbrt/util/log.cpp +++ b/src/pbrt/util/log.cpp @@ -115,7 +115,7 @@ void InitLogging(LogLevel level, std::string logFile, bool logUtilization, bool GetConsoleMode(hStdout, &consoleMode); consoleMode |= 0xc; // virtual terminal processing, disable newline auto return SetConsoleMode(hStdout, consoleMode); -#endif // PBRT_IS_WINDOWS +#endif // PBRT_IS_WINDOWS if (level == LogLevel::Invalid) ErrorExit("Invalid --log-level specified."); @@ -244,10 +244,10 @@ void InitLogging(LogLevel level, std::string logFile, bool logUtilization, bool // Report activity since last logging event. A value of 1 // represents all cores running at 100% utilization. - int64_t delta = (currentUsage.user + currentUsage.nice + - currentUsage.system + currentUsage.idle) - - (prevUsage.user + prevUsage.nice + - prevUsage.system + prevUsage.idle); + int64_t delta = + (currentUsage.user + currentUsage.nice + currentUsage.system + + currentUsage.idle) - + (prevUsage.user + prevUsage.nice + prevUsage.system + prevUsage.idle); LOG_VERBOSE("CPU: Memory used %d MB. " "Core activity: %.4f user %.4f nice %.4f system %.4f idle", GetCurrentRSS() / (1024 * 1024), @@ -255,11 +255,12 @@ void InitLogging(LogLevel level, std::string logFile, bool logUtilization, bool double(currentUsage.nice - prevUsage.nice) / delta, double(currentUsage.system - prevUsage.system) / delta, double(currentUsage.idle - prevUsage.idle) / delta); - LOG_VERBOSE("IO: read request %d read actual %d write request %d write actual %d", - currentUsage.readRequest - prevUsage.readRequest, - currentUsage.readActual - prevUsage.readActual, - currentUsage.writeRequest - prevUsage.writeRequest, - currentUsage.writeActual - prevUsage.writeActual); + LOG_VERBOSE( + "IO: read request %d read actual %d write request %d write actual %d", + currentUsage.readRequest - prevUsage.readRequest, + currentUsage.readActual - prevUsage.readActual, + currentUsage.writeRequest - prevUsage.writeRequest, + currentUsage.writeActual - prevUsage.writeActual); prevUsage = currentUsage; @@ -391,9 +392,9 @@ void Log(LogLevel level, const char *file, int line, const char *s) { #ifdef __NVCC__ // warning #1305-D: function declared with "noreturn" does return #ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ - #pragma nv_diag_suppress 1305 +#pragma nv_diag_suppress 1305 #else - #pragma diag_suppress 1305 +#pragma diag_suppress 1305 #endif #endif diff --git a/src/pbrt/util/parallel_test.cpp b/src/pbrt/util/parallel_test.cpp index ec7939e08..fc36a3399 100644 --- a/src/pbrt/util/parallel_test.cpp +++ b/src/pbrt/util/parallel_test.cpp @@ -56,7 +56,7 @@ TEST(ThreadLocal, Consistency) { for (int i = 0; i <= index; ++i) for (int j = 0; j <= index; ++j) f *= std::sqrt(f); - EXPECT_NE(f, 1.141f); // make sure it isn't optimized out + EXPECT_NE(f, 1.141f); // make sure it isn't optimized out }; ParallelFor(0, 1000, [&](int64_t index) { diff --git a/src/pbrt/util/print.h b/src/pbrt/util/print.h index 9a219a470..a9befae36 100644 --- a/src/pbrt/util/print.h +++ b/src/pbrt/util/print.h @@ -157,8 +157,7 @@ void stringPrintfRecursive(std::string *s, const char *fmt); std::string copyToFormatString(const char **fmt_ptr, std::string *s); template -inline typename std::enable_if_t>, - std::string> +inline typename std::enable_if_t>, std::string> formatOne(const char *fmt, T &&v) { // Figure out how much space we need to allocate; add an extra // character for the '\0'. @@ -171,9 +170,8 @@ formatOne(const char *fmt, T &&v) { } template -inline - typename std::enable_if_t>, std::string> - formatOne(const char *fmt, T &&v) { +inline typename std::enable_if_t>, std::string> +formatOne(const char *fmt, T &&v) { LOG_FATAL("Printf: Non-basic type %s passed for format string %s", typeid(v).name(), fmt); return ""; diff --git a/src/pbrt/util/pstd_test.cpp b/src/pbrt/util/pstd_test.cpp index d1402c14c..ddf8e6665 100644 --- a/src/pbrt/util/pstd_test.cpp +++ b/src/pbrt/util/pstd_test.cpp @@ -106,7 +106,7 @@ TEST(Optional, RunDestructors) { } class TrackingResource : public pstd::pmr::memory_resource { -public: + public: void *do_allocate(size_t bytes, size_t alignment) { void *ptr = new char[bytes]; allocs[ptr] = bytes; diff --git a/src/pbrt/util/string.cpp b/src/pbrt/util/string.cpp index 6a2486297..0ae5e8048 100644 --- a/src/pbrt/util/string.cpp +++ b/src/pbrt/util/string.cpp @@ -193,10 +193,11 @@ std::string NormalizeUTF8(std::string str) { utf8proc_option_t options = UTF8PROC_COMPOSE; utf8proc_uint8_t *result; - utf8proc_ssize_t length = utf8proc_map((const unsigned char *)str.data(), str.size(), - &result, options); + utf8proc_ssize_t length = + utf8proc_map((const unsigned char *)str.data(), str.size(), &result, options); if (length < 0) - ErrorExit("Unicode normalization error: %s: \"%s\"", utf8proc_errmsg(length), str); + ErrorExit("Unicode normalization error: %s: \"%s\"", utf8proc_errmsg(length), + str); str = std::string(result, result + length); free(result); diff --git a/src/pbrt/util/string_test.cpp b/src/pbrt/util/string_test.cpp index 11fc0ccd8..fe9698442 100644 --- a/src/pbrt/util/string_test.cpp +++ b/src/pbrt/util/string_test.cpp @@ -21,6 +21,6 @@ TEST(Unicode, BasicNormalization) { std::string nfd8 = UTF8FromUTF16(nfd16); EXPECT_NE(nfc8, nfd8); - EXPECT_EQ(nfc8, NormalizeUTF8(nfc8)); // nfc is already normalized - EXPECT_EQ(nfc8, NormalizeUTF8(nfd8)); // normalizing nfd should make it equal nfc + EXPECT_EQ(nfc8, NormalizeUTF8(nfc8)); // nfc is already normalized + EXPECT_EQ(nfc8, NormalizeUTF8(nfd8)); // normalizing nfd should make it equal nfc } diff --git a/src/pbrt/util/taggedptr.h b/src/pbrt/util/taggedptr.h index b0da7a4d9..9231de0f9 100644 --- a/src/pbrt/util/taggedptr.h +++ b/src/pbrt/util/taggedptr.h @@ -708,8 +708,7 @@ struct IsSameType { template struct IsSameType { - static constexpr bool value = - (std::is_same_v && IsSameType::value); + static constexpr bool value = (std::is_same_v && IsSameType::value); }; template @@ -859,7 +858,8 @@ class TaggedPointer { } private: - static_assert(sizeof(uintptr_t) <= sizeof(uint64_t), "Expected pointer size to be <= 64 bits"); + static_assert(sizeof(uintptr_t) <= sizeof(uint64_t), + "Expected pointer size to be <= 64 bits"); // TaggedPointer Private Members static constexpr int tagShift = 57; static constexpr int tagBits = 64 - tagShift; diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index 94738b5e3..f1ecc90ed 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -293,12 +293,15 @@ Float WavefrontPathIntegrator::Render() { GUI *gui = nullptr; // FIXME: camera animation; whatever... - Transform renderFromCamera = camera.GetCameraTransform().RenderFromCamera().startTransform; + Transform renderFromCamera = + camera.GetCameraTransform().RenderFromCamera().startTransform; Transform cameraFromRender = Inverse(renderFromCamera); - Transform cameraFromWorld = camera.GetCameraTransform().CameraFromWorld(camera.SampleTime(0.f)); + Transform cameraFromWorld = + camera.GetCameraTransform().CameraFromWorld(camera.SampleTime(0.f)); if (Options->interactive) { if (!Options->displayServer.empty()) - ErrorExit("--interactive and --display-server cannot be used at the same time."); + ErrorExit( + "--interactive and --display-server cannot be used at the same time."); gui = new GUI(film.GetFilename(), resolution, aggregate->Bounds()); } @@ -330,7 +333,8 @@ Float WavefrontPathIntegrator::Render() { ProgressReporter progress(lastSampleIndex - firstSampleIndex, "Rendering", Options->quiet || Options->interactive, Options->useGPU); - for (int sampleIndex = firstSampleIndex; sampleIndex < lastSampleIndex; ++sampleIndex) { + for (int sampleIndex = firstSampleIndex; sampleIndex < lastSampleIndex; + ++sampleIndex) { // Attempt to work around issue #145. #if !(defined(PBRT_IS_WINDOWS) && defined(PBRT_BUILD_GPU_RENDERER) && \ __CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ == 1) @@ -356,7 +360,8 @@ Float WavefrontPathIntegrator::Render() { Transform cameraMotion; if (gui) - cameraMotion = renderFromCamera * gui->GetCameraTransform() * cameraFromRender; + cameraMotion = + renderFromCamera * gui->GetCameraTransform() * cameraFromRender; GenerateCameraRays(y0, cameraMotion, sampleIndex); Do( "Update camera ray stats", @@ -436,7 +441,8 @@ Float WavefrontPathIntegrator::Render() { gui->UnmapFramebuffer(); if (gui->printCameraTransform) { - SquareMatrix<4> cfw = (Inverse(gui->GetCameraTransform()) * cameraFromWorld).GetMatrix(); + SquareMatrix<4> cfw = + (Inverse(gui->GetCameraTransform()) * cameraFromWorld).GetMatrix(); Printf("Current camera transform:\nTransform [ "); for (int i = 0; i < 16; ++i) Printf("%f ", cfw[i % 4][i / 4]); @@ -450,11 +456,12 @@ Float WavefrontPathIntegrator::Render() { break; else if (state == DisplayState::RESET) { sampleIndex = firstSampleIndex - 1; - ParallelFor("Reset pixels", resolution.x * resolution.y, - PBRT_CPU_GPU_LAMBDA(int i) { - int x = i % resolution.x, y = i / resolution.x; - film.ResetPixel(pixelBounds.pMin + Vector2i(x, y)); - }); + ParallelFor( + "Reset pixels", resolution.x * resolution.y, + PBRT_CPU_GPU_LAMBDA(int i) { + int x = i % resolution.x, y = i / resolution.x; + film.ResetPixel(pixelBounds.pMin + Vector2i(x, y)); + }); } } @@ -593,8 +600,7 @@ void WavefrontPathIntegrator::PrefetchGPUAllocations() { CUDA_CHECK(cudaGetDevice(&deviceIndex)); int hasConcurrentManagedAccess; CUDA_CHECK(cudaDeviceGetAttribute(&hasConcurrentManagedAccess, - cudaDevAttrConcurrentManagedAccess, - deviceIndex)); + cudaDevAttrConcurrentManagedAccess, deviceIndex)); // Copy all of the scene data structures over to GPU memory. This // ensures that there isn't a big performance hitch for the first batch @@ -607,8 +613,8 @@ void WavefrontPathIntegrator::PrefetchGPUAllocations() { // kernels according to what's in the scene...) CUDA_CHECK(cudaMemAdvise(this, sizeof(*this), cudaMemAdviseSetReadMostly, /* ignored argument */ 0)); - CUDA_CHECK(cudaMemAdvise(this, sizeof(*this), - cudaMemAdviseSetPreferredLocation, deviceIndex)); + CUDA_CHECK(cudaMemAdvise(this, sizeof(*this), cudaMemAdviseSetPreferredLocation, + deviceIndex)); // Copy all of the scene data structures over to GPU memory. This // ensures that there isn't a big performance hitch for the first batch @@ -623,7 +629,7 @@ void WavefrontPathIntegrator::PrefetchGPUAllocations() { // kernel sufficient? } } -#endif // PBRT_BUILD_GPU_RENDERER +#endif // PBRT_BUILD_GPU_RENDERER void WavefrontPathIntegrator::StartDisplayThread() { Bounds2i pixelBounds = film.PixelBounds(); @@ -677,43 +683,43 @@ void WavefrontPathIntegrator::StartDisplayThread() { // Now on the CPU side, give the display system a lambda that // copies values from |displayRGBHost| into its buffers used for // sending messages to the display program (i.e., tev). - DisplayDynamic(film.GetFilename(), {resolution.x, resolution.y}, - {"R", "G", "B"}, - [resolution, this](Bounds2i b, pstd::span> displayValue) { - int index = 0; - for (Point2i p : b) { - RGB rgb = displayRGBHost[p.x + p.y * resolution.x]; - displayValue[0][index] = rgb.r; - displayValue[1][index] = rgb.g; - displayValue[2][index] = rgb.b; - ++index; - } - }); + DisplayDynamic( + film.GetFilename(), {resolution.x, resolution.y}, {"R", "G", "B"}, + [resolution, this](Bounds2i b, pstd::span> displayValue) { + int index = 0; + for (Point2i p : b) { + RGB rgb = displayRGBHost[p.x + p.y * resolution.x]; + displayValue[0][index] = rgb.r; + displayValue[1][index] = rgb.g; + displayValue[2][index] = rgb.b; + ++index; + } + }); } else #endif // PBRT_BUILD_GPU_RENDERER - DisplayDynamic(film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, - [pixelBounds, this](Bounds2i b, - pstd::span> displayValue) { - int index = 0; - for (Point2i p : b) { - RGB rgb = - film.GetPixelRGB(pixelBounds.pMin + p, 1.f /* splat scale */); - for (int c = 0; c < 3; ++c) - displayValue[c][index] = rgb[c]; - ++index; - } - }); + DisplayDynamic( + film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, + [pixelBounds, this](Bounds2i b, pstd::span> displayValue) { + int index = 0; + for (Point2i p : b) { + RGB rgb = + film.GetPixelRGB(pixelBounds.pMin + p, 1.f /* splat scale */); + for (int c = 0; c < 3; ++c) + displayValue[c][index] = rgb[c]; + ++index; + } + }); } void WavefrontPathIntegrator::UpdateDisplayRGBFromFilm(Bounds2i pixelBounds) { #ifdef PBRT_BUILD_GPU_RENDERER Vector2i resolution = pixelBounds.Diagonal(); GPUParallelFor( - "Update Display RGB Buffer", resolution.x * resolution.y, - PBRT_CPU_GPU_LAMBDA(int index) { - Point2i p(index % resolution.x, index / resolution.x); - displayRGB[index] = film.GetPixelRGB(p + pixelBounds.pMin); - }); + "Update Display RGB Buffer", resolution.x * resolution.y, + PBRT_CPU_GPU_LAMBDA(int index) { + Point2i p(index % resolution.x, index / resolution.x); + displayRGB[index] = film.GetPixelRGB(p + pixelBounds.pMin); + }); #endif // PBRT_BUILD_GPU_RENDERER } @@ -736,14 +742,15 @@ void WavefrontPathIntegrator::StopDisplayThread() { #endif // PBRT_BUILD_GPU_RENDERER } -void WavefrontPathIntegrator::UpdateFramebufferFromFilm(Bounds2i pixelBounds, Float exposure, - RGB *rgb) { +void WavefrontPathIntegrator::UpdateFramebufferFromFilm(Bounds2i pixelBounds, + Float exposure, RGB *rgb) { Vector2i resolution = pixelBounds.Diagonal(); - ParallelFor("Update framebuffer", resolution.x * resolution.y, - PBRT_CPU_GPU_LAMBDA(int index) { - Point2i p(index % resolution.x, index / resolution.x); - rgb[index] = exposure * film.GetPixelRGB(p + film.PixelBounds().pMin); - }); + ParallelFor( + "Update framebuffer", resolution.x * resolution.y, + PBRT_CPU_GPU_LAMBDA(int index) { + Point2i p(index % resolution.x, index / resolution.x); + rgb[index] = exposure * film.GetPixelRGB(p + film.PixelBounds().pMin); + }); } } // namespace pbrt diff --git a/src/pbrt/wavefront/integrator.h b/src/pbrt/wavefront/integrator.h index ecfa5558e..ac00aaadd 100644 --- a/src/pbrt/wavefront/integrator.h +++ b/src/pbrt/wavefront/integrator.h @@ -59,8 +59,7 @@ class WavefrontPathIntegrator { // WavefrontPathIntegrator Public Methods Float Render(); - void GenerateCameraRays(int y0, Transform movingFromcamera, - int sampleIndex); + void GenerateCameraRays(int y0, Transform movingFromcamera, int sampleIndex); template void GenerateCameraRays(int y0, Transform movingFromCamera, int sampleIndex); diff --git a/src/pbrt/wavefront/samples.cpp b/src/pbrt/wavefront/samples.cpp index c53fe9871..20c72ccf2 100644 --- a/src/pbrt/wavefront/samples.cpp +++ b/src/pbrt/wavefront/samples.cpp @@ -11,7 +11,7 @@ #ifdef interface #undef interface -#endif // interface +#endif // interface namespace pbrt { diff --git a/src/pbrt/wavefront/surfscatter.cpp b/src/pbrt/wavefront/surfscatter.cpp index 3a6dafda7..b0b5d04fa 100644 --- a/src/pbrt/wavefront/surfscatter.cpp +++ b/src/pbrt/wavefront/surfscatter.cpp @@ -30,18 +30,21 @@ struct EvaluateMaterialCallback { template void operator()() { if constexpr (!std::is_same_v) - integrator->EvaluateMaterialAndBSDF(wavefrontDepth, movingFromCamera); + integrator->EvaluateMaterialAndBSDF(wavefrontDepth, + movingFromCamera); } }; // WavefrontPathIntegrator Surface Scattering Methods -void WavefrontPathIntegrator::EvaluateMaterialsAndBSDFs(int wavefrontDepth, Transform movingFromCamera) { +void WavefrontPathIntegrator::EvaluateMaterialsAndBSDFs(int wavefrontDepth, + Transform movingFromCamera) { ForEachType(EvaluateMaterialCallback{wavefrontDepth, this, movingFromCamera}, Material::Types()); } template -void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(int wavefrontDepth, Transform movingFromCamera) { +void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(int wavefrontDepth, + Transform movingFromCamera) { int index = Material::TypeIndex(); if (haveBasicEvalMaterial[index]) EvaluateMaterialAndBSDF( @@ -53,7 +56,8 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(int wavefrontDepth, Transf template void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQueue, - Transform movingFromCamera, int wavefrontDepth) { + Transform movingFromCamera, + int wavefrontDepth) { // Get BSDF for items in _evalQueue_ and sample illumination // Construct _desc_ for material/texture evaluation kernel std::string desc = StringPrintf( @@ -73,8 +77,7 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue if (!GetOptions().disableTextureFiltering) { Point3f pc = movingFromCamera.ApplyInverse(Point3f(w.pi)); Normal3f nc = movingFromCamera.ApplyInverse(w.n); - camera.Approximate_dp_dxy(pc, nc, w.time, samplesPerPixel, - &dpdx, &dpdy); + camera.Approximate_dp_dxy(pc, nc, w.time, samplesPerPixel, &dpdx, &dpdy); Vector3f dpdu = w.dpdu, dpdv = w.dpdv; // Estimate screen-space change in $(u,v)$ // Compute $\transpose{\XFORM{A}} \XFORM{A}$ and its determinant From ca6b91c86da353f7d5c728bd9a63adcb8edd2511 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 27 May 2022 15:41:21 -0700 Subject: [PATCH 049/149] HairMaterial: rename "color" parameter to "reflectance" (Still accept "color" for backwards compatibility.) --- src/pbrt/materials.cpp | 24 +++++++++++++----------- src/pbrt/parser.cpp | 2 ++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index 7bc89b2ab..9df634f8f 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -136,34 +136,36 @@ HairMaterial *HairMaterial::Create(const TextureParameterDictionary ¶meters, const FileLoc *loc, Allocator alloc) { SpectrumTexture sigma_a = parameters.GetSpectrumTextureOrNull("sigma_a", SpectrumType::Unbounded, alloc); - SpectrumTexture color = - parameters.GetSpectrumTextureOrNull("color", SpectrumType::Albedo, alloc); + SpectrumTexture reflectance = + parameters.GetSpectrumTextureOrNull("reflectance", SpectrumType::Albedo, alloc); + if (!reflectance) + reflectance = parameters.GetSpectrumTextureOrNull("color", SpectrumType::Albedo, alloc); FloatTexture eumelanin = parameters.GetFloatTextureOrNull("eumelanin", alloc); FloatTexture pheomelanin = parameters.GetFloatTextureOrNull("pheomelanin", alloc); if (sigma_a) { - if (color) - Warning(loc, R"(Ignoring "color" parameter since "sigma_a" was provided.)"); + if (reflectance) + Warning(loc, R"(Ignoring "reflectance" parameter since "sigma_a" was provided.)"); if (eumelanin) Warning(loc, "Ignoring \"eumelanin\" parameter since \"sigma_a\" was " "provided."); if (pheomelanin) Warning(loc, "Ignoring \"pheomelanin\" parameter since \"sigma_a\" was " "provided."); - } else if (color) { + } else if (reflectance) { if (sigma_a) - Warning(loc, R"(Ignoring "sigma_a" parameter since "color" was provided.)"); + Warning(loc, R"(Ignoring "sigma_a" parameter since "reflectance" was provided.)"); if (eumelanin) - Warning(loc, "Ignoring \"eumelanin\" parameter since \"color\" was " + Warning(loc, "Ignoring \"eumelanin\" parameter since \"reflectance\" was " "provided."); if (pheomelanin) - Warning(loc, "Ignoring \"pheomelanin\" parameter since \"color\" was " + Warning(loc, "Ignoring \"pheomelanin\" parameter since \"reflectance\" was " "provided."); } else if (eumelanin || pheomelanin) { if (sigma_a) Warning(loc, "Ignoring \"sigma_a\" parameter since " "\"eumelanin\"/\"pheomelanin\" was provided."); - if (color) - Warning(loc, "Ignoring \"color\" parameter since " + if (reflectance) + Warning(loc, "Ignoring \"reflectance\" parameter since " "\"eumelanin\"/\"pheomelanin\" was provided."); } else { // Default: brown-ish hair. @@ -177,7 +179,7 @@ HairMaterial *HairMaterial::Create(const TextureParameterDictionary ¶meters, FloatTexture beta_n = parameters.GetFloatTexture("beta_n", 0.3f, alloc); FloatTexture alpha = parameters.GetFloatTexture("alpha", 2.f, alloc); - return alloc.new_object(sigma_a, color, eumelanin, pheomelanin, eta, + return alloc.new_object(sigma_a, reflectance, eumelanin, pheomelanin, eta, beta_m, beta_n, alpha); } diff --git a/src/pbrt/parser.cpp b/src/pbrt/parser.cpp index 4a6bb2439..3b11144ba 100644 --- a/src/pbrt/parser.cpp +++ b/src/pbrt/parser.cpp @@ -1592,6 +1592,8 @@ std::string FormattingParserTarget::upgradeMaterial(std::string *name, } else if (*name == "disney") { *name = "diffuse"; dict->RenameParameter("color", "reflectance"); + } else if (*name == "hair") { + dict->RenameParameter("color", "reflectance"); } else if (name->empty() || *name == "none") *name = "interface"; From e6a13b27bf1cf9448543793dcf480fdfb31f6fe1 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 27 May 2022 15:41:41 -0700 Subject: [PATCH 050/149] Rename plymesh "displacement.edgelength" parameter to "edgelength" --- src/pbrt/shapes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/shapes.cpp b/src/pbrt/shapes.cpp index ca0c068fe..2b81df572 100644 --- a/src/pbrt/shapes.cpp +++ b/src/pbrt/shapes.cpp @@ -1418,7 +1418,7 @@ pstd::vector Shape::Create( std::string filename = ResolveFilename(parameters.GetOneString("filename", "")); TriQuadMesh plyMesh = TriQuadMesh::ReadPLY(filename); - Float edgeLength = parameters.GetOneFloat("displacement.edgelength", 1.f); + Float edgeLength = parameters.GetOneFloat("edgelength", 1.f); edgeLength *= Options->displacementEdgeScale; std::string displacementTexName = parameters.GetTexture("displacement"); From 08b9d33b34e9a6038e569b526d9cd3ddde49f78b Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 27 May 2022 16:04:40 -0700 Subject: [PATCH 051/149] Small fixes to PBRT_DBG calls in pbrt/wavefront/ --- src/pbrt/wavefront/film.cpp | 2 +- src/pbrt/wavefront/integrator.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pbrt/wavefront/film.cpp b/src/pbrt/wavefront/film.cpp index 006f1ad3b..c96e7f29e 100644 --- a/src/pbrt/wavefront/film.cpp +++ b/src/pbrt/wavefront/film.cpp @@ -22,7 +22,7 @@ void WavefrontPathIntegrator::UpdateFilm() { SampledSpectrum Lw = SampledSpectrum(pixelSampleState.L[pixelIndex]) * pixelSampleState.cameraRayWeight[pixelIndex]; - PBRT_DBG("Adding Lw %f %f %f %f at pixel (%d, %d)", Lw[0], Lw[1], Lw[2], + PBRT_DBG("Adding Lw %f %f %f %f at pixel (%d, %d)\n", Lw[0], Lw[1], Lw[2], Lw[3], pPixel.x, pPixel.y); // Provide sample radiance value to film SampledWavelengths lambda = pixelSampleState.lambda[pixelIndex]; diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index f1ecc90ed..140605ecf 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -498,12 +498,14 @@ void WavefrontPathIntegrator::HandleEscapedRays() { for (const auto &light : *infiniteLights) { if (SampledSpectrum Le = light.Le(Ray(w.rayo, w.rayd), w.lambda); Le) { // Compute path radiance contribution from infinite light - PBRT_DBG("L %f %f %f %f beta %f %f %f %f Le %f %f %f %f", L[0], L[1], + PBRT_DBG("L %f %f %f %f beta %f %f %f %f Le %f %f %f %f\n", L[0], L[1], L[2], L[3], w.beta[0], w.beta[1], w.beta[2], w.beta[3], Le[0], Le[1], Le[2], Le[3]); - PBRT_DBG("pdf uni %f %f %f %f pdf nee %f %f %f %f", w.inv_w_u[0], - w.inv_w_u[1], w.inv_w_u[2], w.inv_w_u[3], w.inv_w_l[0], - w.inv_w_l[1], w.inv_w_l[2], w.inv_w_l[3]); + PBRT_DBG("depth %d specularBounce %d pdf uni %f %f %f %f " + "pdf nee %f %f %f %f\n", + w.depth, w.specularBounce, + w.inv_w_u[0], w.inv_w_u[1], w.inv_w_u[2], w.inv_w_u[3], + w.inv_w_l[0], w.inv_w_l[1], w.inv_w_l[2], w.inv_w_l[3]); if (w.depth == 0 || w.specularBounce) { L += w.beta * Le / w.inv_w_u.Average(); From dbd005ac5274614b579fb5c2072c6ba22c3106a8 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 27 May 2022 16:07:17 -0700 Subject: [PATCH 052/149] Fix bug in updateMaterialNeeds()'s detection of interface materials *haveMedia would never be set to true due to a check for a nullptr material at the start of the function... In turn, this led to the wavefront integrator not detecting the case of interface materials without participating media, which still requires special handling for direct lighting to come out right. This should fix #271. --- src/pbrt/wavefront/integrator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index 140605ecf..c2ec69d49 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -48,6 +48,7 @@ static void updateMaterialNeeds( Material m, pstd::array *haveBasicEvalMaterial, pstd::array *haveUniversalEvalMaterial, bool *haveSubsurface, bool *haveMedia) { + *haveMedia |= (m == nullptr); // interface material if (!m) return; @@ -67,7 +68,6 @@ static void updateMaterialNeeds( } *haveSubsurface |= m.HasSubsurfaceScattering(); - *haveMedia |= (m == nullptr); // interface material FloatTexture displace = m.GetDisplacement(); if (m.CanEvaluateTextures(BasicTextureEvaluator()) && From cdccb71cb1e153b63e538f624efcc13ab0f9bda2 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 27 May 2022 16:08:52 -0700 Subject: [PATCH 053/149] Fix handling of interface materials in Path and SimplePath integrators For these, if a ray goes through an interface we need to treat the interface as specular. (This is needed since the shadow ray test used in these integrators does not handle interfaces but just returns false for shadow rays that hit them.) Related to #271. --- src/pbrt/cpu/integrators.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index c2fffd020..64eaf983b 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -420,6 +420,7 @@ SampledSpectrum SimplePathIntegrator::Li(RayDifferential ray, SampledWavelengths // Get BSDF and skip over medium boundaries BSDF bsdf = isect.GetBSDF(ray, lambda, camera, scratchBuffer, sampler); if (!bsdf) { + specularBounce = true; isect.SkipIntersection(&ray, si->tHit); continue; } @@ -677,6 +678,7 @@ SampledSpectrum PathIntegrator::Li(RayDifferential ray, SampledWavelengths &lamb // Get BSDF and skip over medium boundaries BSDF bsdf = isect.GetBSDF(ray, lambda, camera, scratchBuffer, sampler); if (!bsdf) { + specularBounce = true; // disable MIS if the indirect ray hits a light isect.SkipIntersection(&ray, si->tHit); continue; } From e6894bee497d7eb55a6e8c4f56e38d77265a17d2 Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Mon, 30 May 2022 10:06:11 +0200 Subject: [PATCH 054/149] Silent MSVC warnings --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c668696c4..68396cdcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,7 @@ target_compile_options ( "$<$:$<$:SHELL:-Xcompiler >/wd4843>" # double -> float conversion "$<$:$<$:SHELL:-Xcompiler >/wd26451>" # arithmetic on 4-byte value, then cast to 8-byte "$<$:$<$:SHELL:-Xcompiler >/wd26495>" # uninitialized member variable + "$<$:$<$:SHELL:-Xcompiler >/wd4334>" # 32 to 64 bit displacement ) add_library (pbrt_opt INTERFACE) From 0a6c13678646f7711100f02b7b9102469f981f3f Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Mon, 30 May 2022 10:08:36 +0200 Subject: [PATCH 055/149] Silent MSVC warnings for a dependencies --- src/ext/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ext/CMakeLists.txt b/src/ext/CMakeLists.txt index f2d4a7500..3c6324bba 100644 --- a/src/ext/CMakeLists.txt +++ b/src/ext/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required (VERSION 3.12) if (MSVC) - add_definitions(/D _CRT_SECURE_NO_WARNINGS) + add_definitions(/D _CRT_SECURE_NO_WARNINGS /Dstrdup=_strdup + /wd4018 /wd4100 /wd4101 /wd4127 /wd4146 /wd4232 /wd4242 /wd4244 /wd4245 /wd4267 /wd4305 /wd4309 + /wd4310 /wd4334 /wd4456 /wd4464 /wd4668 /wd4701 /wd4703 /wd4711 /wd4756 /wd4820 /wd5045 /wd5250) endif () ########################################################################### From d7bce5a6801d3eba0cc85b8b9b39c4afe55bdea5 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 30 May 2022 07:22:57 -0700 Subject: [PATCH 056/149] Prohibit "interface" materials as elements of MixMaterial It's not clear what this would mean and this case isn't handled by integrators in any case. (cc #271) --- src/pbrt/materials.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index 9df634f8f..82f1cf1f8 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -671,6 +671,10 @@ Material Material::Create(const std::string &name, if (iter == namedMaterials.end()) ErrorExit("%s: named material not found.", materialNames[i]); materials[i] = iter->second; + + if (materials[i] == nullptr) + ErrorExit("%s: an \"interface\" material cannot be used as an element of " + "the \"mix\" material.", materialNames[i]); } material = MixMaterial::Create(materials, parameters, loc, alloc); } else From 82f2356a179413523813875ab1d8d6f36e0813ea Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 4 Jun 2022 08:58:49 -0700 Subject: [PATCH 057/149] Change SafeSqrt() to std::sqrt() in Refract() Opportunity noted by @star-hengxing, issue #238. --- src/pbrt/util/scattering.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/util/scattering.h b/src/pbrt/util/scattering.h index 6d7828e86..70af44310 100644 --- a/src/pbrt/util/scattering.h +++ b/src/pbrt/util/scattering.h @@ -36,7 +36,7 @@ PBRT_CPU_GPU inline bool Refract(Vector3f wi, Normal3f n, Float eta, Float *etap if (sin2Theta_t >= 1) return false; - Float cosTheta_t = SafeSqrt(1 - sin2Theta_t); + Float cosTheta_t = std::sqrt(1 - sin2Theta_t); *wt = -wi / eta + (cosTheta_i / eta - cosTheta_t) * Vector3f(n); // Provide relative IOR along ray to caller From e273b3d81ef019977936278d64ed28e95ac55332 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 4 Jun 2022 17:14:01 -0700 Subject: [PATCH 058/149] Fix bug in WeightedReservoirSampler::Merge(): reservoirWeight wasn't being set correctly. Found by @guoxx, issue #250. --- src/pbrt/util/sampling.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pbrt/util/sampling.h b/src/pbrt/util/sampling.h index 41b65aff9..e5caf7831 100644 --- a/src/pbrt/util/sampling.h +++ b/src/pbrt/util/sampling.h @@ -532,28 +532,31 @@ class WeightedReservoirSampler { void Seed(uint64_t seed) { rng.SetSequence(seed); } PBRT_CPU_GPU - void Add(const T &sample, Float weight) { + bool Add(const T &sample, Float weight) { weightSum += weight; // Randomly add _sample_ to reservoir Float p = weight / weightSum; if (rng.Uniform() < p) { reservoir = sample; reservoirWeight = weight; + return true; } - DCHECK_LT(weightSum, 1e80); + return false; } template - PBRT_CPU_GPU void Add(F func, Float weight) { + PBRT_CPU_GPU bool Add(F func, Float weight) { // Process weighted reservoir sample via callback weightSum += weight; Float p = weight / weightSum; if (rng.Uniform() < p) { reservoir = func(); reservoirWeight = weight; + return true; } DCHECK_LT(weightSum, 1e80); + return false; } PBRT_CPU_GPU @@ -578,8 +581,8 @@ class WeightedReservoirSampler { PBRT_CPU_GPU void Merge(const WeightedReservoirSampler &wrs) { DCHECK_LE(weightSum + wrs.WeightSum(), 1e80); - if (wrs.HasSample()) - Add(wrs.reservoir, wrs.weightSum); + if (wrs.HasSample() && Add(wrs.reservoir, wrs.weightSum)) + reservoirWeight = wrs.reservoirWeight; } std::string ToString() const { From 5e0884f7b7094b273a720a22c5f261ce2e894299 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 8 Jun 2022 09:37:36 -0700 Subject: [PATCH 059/149] NanoVDBMedium: rename "temperaturecutoff" parameter to "temperatureoffset" And similarly for the corresponding member variable. "temperaturecutoff" is still accepted for backwards compatibility. --- src/pbrt/media.cpp | 15 ++++++++------- src/pbrt/media.h | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/pbrt/media.cpp b/src/pbrt/media.cpp index baba8a590..19c266dfa 100644 --- a/src/pbrt/media.cpp +++ b/src/pbrt/media.cpp @@ -504,7 +504,7 @@ NanoVDBMedium::NanoVDBMedium(const Transform &renderFromMedium, Spectrum sigma_a Spectrum sigma_s, Float sigmaScale, Float g, nanovdb::GridHandle dg, nanovdb::GridHandle tg, Float LeScale, - Float temperatureCutoff, Float temperatureScale, + Float temperatureOffset, Float temperatureScale, Allocator alloc) : renderFromMedium(renderFromMedium), sigma_a_spec(sigma_a, alloc), @@ -514,7 +514,7 @@ NanoVDBMedium::NanoVDBMedium(const Transform &renderFromMedium, Spectrum sigma_a densityGrid(std::move(dg)), temperatureGrid(std::move(tg)), LeScale(LeScale), - temperatureCutoff(temperatureCutoff), + temperatureOffset(temperatureOffset), temperatureScale(temperatureScale) { densityFloatGrid = densityGrid.grid(); @@ -613,8 +613,8 @@ NanoVDBMedium::NanoVDBMedium(const Transform &renderFromMedium, Spectrum sigma_a std::string NanoVDBMedium::ToString() const { return StringPrintf("[ NanoVDBMedium bounds: %s LeScale: %f " - "temperatureCutoff: %f temperatureScale: %f (grids elided) ]", - bounds, LeScale, temperatureCutoff, temperatureScale); + "temperatureOffset: %f temperatureScale: %f (grids elided) ]", + bounds, LeScale, temperatureOffset, temperatureScale); } NanoVDBMedium *NanoVDBMedium::Create(const ParameterDictionary ¶meters, @@ -632,8 +632,9 @@ NanoVDBMedium *NanoVDBMedium::Create(const ParameterDictionary ¶meters, nanovdb::GridHandle temperatureGrid; temperatureGrid = readGrid(filename, "temperature", loc, alloc); - Float LeScale = parameters.GetOneFloat("LeScale", 1.f); - Float temperatureCutoff = parameters.GetOneFloat("temperaturecutoff", 0.f); + Float LeScale = parameters.GetOneFloat("Lescale", 1.f); + Float temperatureOffset = parameters.GetOneFloat("temperatureoffset", + parameters.GetOneFloat("temperaturecutoff", 0.f)); Float temperatureScale = parameters.GetOneFloat("temperaturescale", 1.f); Float g = parameters.GetOneFloat("g", 0.); @@ -649,7 +650,7 @@ NanoVDBMedium *NanoVDBMedium::Create(const ParameterDictionary ¶meters, return alloc.new_object( renderFromMedium, sigma_a, sigma_s, sigmaScale, g, std::move(densityGrid), - std::move(temperatureGrid), LeScale, temperatureCutoff, temperatureScale, alloc); + std::move(temperatureGrid), LeScale, temperatureOffset, temperatureScale, alloc); } Medium Medium::Create(const std::string &name, const ParameterDictionary ¶meters, diff --git a/src/pbrt/media.h b/src/pbrt/media.h index 24179a227..fdf88418e 100644 --- a/src/pbrt/media.h +++ b/src/pbrt/media.h @@ -602,7 +602,7 @@ class NanoVDBMedium { NanoVDBMedium(const Transform &renderFromMedium, Spectrum sigma_a, Spectrum sigma_s, Float sigmaScale, Float g, nanovdb::GridHandle dg, nanovdb::GridHandle tg, Float LeScale, - Float temperatureCutoff, Float temperatureScale, Allocator alloc); + Float temperatureOffset, Float temperatureScale, Allocator alloc); PBRT_CPU_GPU bool IsEmissive() const { return temperatureFloatGrid && LeScale > 0; } @@ -652,7 +652,7 @@ class NanoVDBMedium { temperatureFloatGrid->worldToIndexF(nanovdb::Vec3(p.x, p.y, p.z)); using Sampler = nanovdb::SampleFromVoxels; Float temp = Sampler(temperatureFloatGrid->tree())(pIndex); - temp = (temp - temperatureCutoff) * temperatureScale; + temp = (temp - temperatureOffset) * temperatureScale; if (temp <= 100.f) return SampledSpectrum(0.f); return LeScale * BlackbodySpectrum(temp).Sample(lambda); @@ -668,7 +668,7 @@ class NanoVDBMedium { nanovdb::GridHandle temperatureGrid; const nanovdb::FloatGrid *densityFloatGrid = nullptr; const nanovdb::FloatGrid *temperatureFloatGrid = nullptr; - Float LeScale, temperatureCutoff, temperatureScale; + Float LeScale, temperatureOffset, temperatureScale; }; inline Float PhaseFunction::p(Vector3f wo, Vector3f wi) const { From 6743986a374d563b19314b1a88f74a499d8ad38f Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 8 Jun 2022 09:38:09 -0700 Subject: [PATCH 060/149] RGBGridMedium: rename "LeScale" parameter to "Lescale" Make it consistent with how it's specified with the other media.. --- src/pbrt/media.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/media.cpp b/src/pbrt/media.cpp index 19c266dfa..0311cbec7 100644 --- a/src/pbrt/media.cpp +++ b/src/pbrt/media.cpp @@ -435,7 +435,7 @@ RGBGridMedium *RGBGridMedium::Create(const ParameterDictionary ¶meters, Point3f p0 = parameters.GetOnePoint3f("p0", Point3f(0.f, 0.f, 0.f)); Point3f p1 = parameters.GetOnePoint3f("p1", Point3f(1.f, 1.f, 1.f)); - Float LeScale = parameters.GetOneFloat("LeScale", 1.f); + Float LeScale = parameters.GetOneFloat("Lescale", 1.f); Float g = parameters.GetOneFloat("g", 0.f); Float sigmaScale = parameters.GetOneFloat("scale", 1.f); From 2701ba602261a6c9221fa1c35d5d83660aae3bd0 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 8 Jun 2022 09:39:24 -0700 Subject: [PATCH 061/149] SPPMIntegrator: set default seed via Options->seed --- src/pbrt/cpu/integrators.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index 64eaf983b..0bf9486d4 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -3295,7 +3295,7 @@ std::unique_ptr SPPMIntegrator::Create( int maxDepth = parameters.GetOneInt("maxdepth", 5); int photonsPerIter = parameters.GetOneInt("photonsperiteration", -1); Float radius = parameters.GetOneFloat("radius", 1.f); - int seed = parameters.GetOneInt("seed", 6502); + int seed = parameters.GetOneInt("seed", Options->seed); return std::make_unique(camera, sampler, aggregate, lights, photonsPerIter, maxDepth, radius, seed, colorSpace); From 7fb4ce0629d925c5c3f0ae6a27cc4308eff813ea Mon Sep 17 00:00:00 2001 From: jim price Date: Mon, 27 Jun 2022 14:23:00 -0700 Subject: [PATCH 062/149] Check to see if a filepath exists before making absolute One approach to solving issue #280 --- src/pbrt/util/file.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pbrt/util/file.cpp b/src/pbrt/util/file.cpp index f86d37942..51ce74623 100644 --- a/src/pbrt/util/file.cpp +++ b/src/pbrt/util/file.cpp @@ -69,8 +69,11 @@ std::string RemoveExtension(std::string filename) { std::string ResolveFilename(std::string filename) { if (searchDirectory.empty() || filename.empty() || IsAbsolutePath(filename)) return filename; - else - return (searchDirectory / filesystem::path(filename)).make_absolute().str(); + + filesystem::path filepath = searchDirectory / filesystem::path(filename); + if (filepath.exists()) + return filepath.make_absolute().str(); + return filename; } std::vector MatchingFilenames(std::string filenameBase) { From 3763f6698a1b8134ab781a27cb5f07104552d697 Mon Sep 17 00:00:00 2001 From: jim price Date: Mon, 27 Jun 2022 17:22:48 -0700 Subject: [PATCH 063/149] Only resolve aperture as a file if not a builtin name --- src/pbrt/cameras.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/cameras.cpp b/src/pbrt/cameras.cpp index 7007199ad..49b2d960b 100644 --- a/src/pbrt/cameras.cpp +++ b/src/pbrt/cameras.cpp @@ -1333,7 +1333,7 @@ RealisticCamera *RealisticCamera::Create(const ParameterDictionary ¶meters, return image; }; - std::string apertureName = ResolveFilename(parameters.GetOneString("aperture", "")); + std::string apertureName = parameters.GetOneString("aperture", ""); Image apertureImage(alloc); if (!apertureName.empty()) { // built-in diaphragm shapes @@ -1380,7 +1380,7 @@ RealisticCamera *RealisticCamera::Create(const ParameterDictionary ¶meters, std::reverse(vert.begin(), vert.end()); apertureImage = rasterize(vert); } else { - ImageAndMetadata im = Image::Read(apertureName, alloc); + ImageAndMetadata im = Image::Read(ResolveFilename(apertureName), alloc); apertureImage = std::move(im.image); if (apertureImage.NChannels() > 1) { ImageChannelDesc rgbDesc = apertureImage.GetChannelDesc({"R", "G", "B"}); From c8684684400d786eb409567a4dd1afd598134fa5 Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Sun, 3 Jul 2022 02:05:36 +0200 Subject: [PATCH 064/149] Avoid Clang 14 error compiling under Windows Build with Clang 14 under Windows show this error ``` clang-14: error: no such file or directory: '/D' clang-14: error: no such file or directory: 'PTEX_STATIC' ``` This commit fix this and is also OK for MSVC --- src/ext/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ext/CMakeLists.txt b/src/ext/CMakeLists.txt index 3c6324bba..fee478525 100644 --- a/src/ext/CMakeLists.txt +++ b/src/ext/CMakeLists.txt @@ -110,7 +110,7 @@ set (PTEX_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE) set (CMAKE_MACOSX_RPATH 1) if (WIN32) - add_definitions (/D PTEX_STATIC) + add_definitions (/DPTEX_STATIC) endif () add_subdirectory (ptex) From 8e128c18a664d5a5e83aa93511338532515dce5c Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 5 Jul 2022 06:43:53 -0700 Subject: [PATCH 065/149] TrowbridgeReitzDistribution: enforce minimum roughness for anisotropic Previously, we'd get NaN values with anisotropic surfaces with zero roughness in one direction and non-zero roughness in the other. Fixes issue #283. --- src/pbrt/util/scattering.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pbrt/util/scattering.h b/src/pbrt/util/scattering.h index 70af44310..8dc0239e1 100644 --- a/src/pbrt/util/scattering.h +++ b/src/pbrt/util/scattering.h @@ -105,8 +105,16 @@ class TrowbridgeReitzDistribution { // TrowbridgeReitzDistribution Public Methods TrowbridgeReitzDistribution() = default; PBRT_CPU_GPU - TrowbridgeReitzDistribution(Float alpha_x, Float alpha_y) - : alpha_x(alpha_x), alpha_y(alpha_y) {} + TrowbridgeReitzDistribution(Float ax, Float ay) + : alpha_x(ax), alpha_y(ay) { + if (!EffectivelySmooth()) { + // If one direction has some roughness, then the other can't + // have zero (or very low) roughness; the computation of |e| in + // D() blows up in that case. + alpha_x = std::max(alpha_x, 1e-4f); + alpha_y = std::max(alpha_y, 1e-4f); + } + } PBRT_CPU_GPU inline Float D(Vector3f wm) const { Float tan2Theta = Tan2Theta(wm); From 1e734de4e5c830a588ca6d6c5097474bac793dca Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Thu, 7 Jul 2022 09:30:01 +0200 Subject: [PATCH 066/149] Add a option to use arbitrary names for grids Sometimes .nvdb files use arbitrary names for grids. This change adds two options for the user to specify different names for 'density' and 'temperature' grids. --- src/pbrt/media.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pbrt/media.cpp b/src/pbrt/media.cpp index baba8a590..3c066c32d 100644 --- a/src/pbrt/media.cpp +++ b/src/pbrt/media.cpp @@ -625,11 +625,14 @@ NanoVDBMedium *NanoVDBMedium::Create(const ParameterDictionary ¶meters, ErrorExit(loc, "Must supply \"filename\" to \"nanovdb\" medium."); nanovdb::GridHandle densityGrid; - densityGrid = readGrid(filename, "density", loc, alloc); + std::string gridname = parameters.GetOneString("gridname", "density"); + densityGrid = readGrid(filename, gridname, loc, alloc); if (!densityGrid) ErrorExit(loc, "%s: didn't find \"density\" grid.", filename); nanovdb::GridHandle temperatureGrid; + std::string temperaturename = + parameters.GetOneString("temperaturename", "temperature"); temperatureGrid = readGrid(filename, "temperature", loc, alloc); Float LeScale = parameters.GetOneFloat("LeScale", 1.f); From c15e109950436d2db7e7071927f0ad02694dcdd7 Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Thu, 7 Jul 2022 09:42:02 +0200 Subject: [PATCH 067/149] Fix issue using the new 'temperaturename' option --- src/pbrt/media.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/media.cpp b/src/pbrt/media.cpp index 3c066c32d..ecebfe7c5 100644 --- a/src/pbrt/media.cpp +++ b/src/pbrt/media.cpp @@ -633,7 +633,7 @@ NanoVDBMedium *NanoVDBMedium::Create(const ParameterDictionary ¶meters, nanovdb::GridHandle temperatureGrid; std::string temperaturename = parameters.GetOneString("temperaturename", "temperature"); - temperatureGrid = readGrid(filename, "temperature", loc, alloc); + temperatureGrid = readGrid(filename, temperaturename, loc, alloc); Float LeScale = parameters.GetOneFloat("LeScale", 1.f); Float temperatureCutoff = parameters.GetOneFloat("temperaturecutoff", 0.f); From d013ea7e9df5c10553cce5a8c98a0169b8fbc201 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 7 Jul 2022 05:43:16 -0700 Subject: [PATCH 068/149] Issue a more-friendly error if an unsupported camera is used with a bidir integrator. There's no need for the user to see a fatal error, which should be reserved for an actual internal error rather than a problem with the scene as specified... Issue #279. --- src/pbrt/cpu/integrators.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index 0bf9486d4..88e7f487c 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -606,6 +606,9 @@ std::string LightPathIntegrator::ToString() const { std::unique_ptr LightPathIntegrator::Create( const ParameterDictionary ¶meters, Camera camera, Sampler sampler, Primitive aggregate, std::vector lights, const FileLoc *loc) { + if (!camera.Is()) + ErrorExit("Only the \"perspective\" camera is currently supported with the " + "\"lightpath\" integrator."); int maxDepth = parameters.GetOneInt("maxdepth", 5); return std::make_unique(maxDepth, camera, sampler, aggregate, lights); @@ -2424,6 +2427,9 @@ std::string BDPTIntegrator::ToString() const { std::unique_ptr BDPTIntegrator::Create( const ParameterDictionary ¶meters, Camera camera, Sampler sampler, Primitive aggregate, std::vector lights, const FileLoc *loc) { + if (!camera.Is()) + ErrorExit("Only the \"perspective\" camera is currently supported with the " + "\"bdpt\" integrator."); int maxDepth = parameters.GetOneInt("maxdepth", 5); bool visualizeStrategies = parameters.GetOneBool("visualizestrategies", false); bool visualizeWeights = parameters.GetOneBool("visualizeweights", false); @@ -2695,6 +2701,9 @@ std::string MLTIntegrator::ToString() const { std::unique_ptr MLTIntegrator::Create( const ParameterDictionary ¶meters, Camera camera, Primitive aggregate, std::vector lights, const FileLoc *loc) { + if (!camera.Is()) + ErrorExit("Only the \"perspective\" camera is currently supported with the " + "\"mlt\" integrator."); int maxDepth = parameters.GetOneInt("maxdepth", 5); int nBootstrap = parameters.GetOneInt("bootstrapsamples", 100000); int64_t nChains = parameters.GetOneInt("chains", 1000); From 14e5cf4b478b1f21a10946d4c1277e96a5ed920f Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 7 Jul 2022 06:29:16 -0700 Subject: [PATCH 069/149] Update README.md with book release information. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9794fc37..54320e063 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,11 @@ pbrt, Version 4 (Early Release) This is an early release of pbrt-v4, the rendering system that will be described in the forthcoming fourth edition of *Physically Based Rendering: -From Theory to Implementation*. (We hope to have printed books available -in Spring of 2022 and there will again be a free online version of the -book.) +From Theory to Implementation*. (The printed book will be available in +mid-February 2023; a few chapters will be made available in late Fall of +2022; and the full contents of the book will be freely available six months +after the book's release, like the [third edition](https://pbr-book.org) is +already.) We are making this code available for hardy adventurers; it's not yet extensively documented, but if you are familiar with previous versions of From 3a756e200f335d8e54f457da32568dec706bb146 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 11 Jul 2022 03:57:20 -0700 Subject: [PATCH 070/149] Remove medium samples from RaySamples used in wavefront integrator. The previous implementation would inadvertently reuse the same sample value for medium distance sampling when rays passed through interfaces between different scattering media. In turn, this led to significant errors in rendered images. See issue #221... --- src/pbrt/wavefront/media.cpp | 4 ++-- src/pbrt/wavefront/samples.cpp | 8 -------- src/pbrt/wavefront/workitems.h | 16 +--------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/pbrt/wavefront/media.cpp b/src/pbrt/wavefront/media.cpp index f4ef6a76c..9c440a753 100644 --- a/src/pbrt/wavefront/media.cpp +++ b/src/pbrt/wavefront/media.cpp @@ -55,8 +55,8 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { bool scattered = false; RaySamples raySamples = pixelSampleState.samples[w.pixelIndex]; - Float uDist = raySamples.media.uDist; - Float uMode = raySamples.media.uMode; + Float uDist = rng.Uniform(); + Float uMode = rng.Uniform(); SampledSpectrum T_maj = SampleT_maj( ray, tMax, uDist, rng, lambda, diff --git a/src/pbrt/wavefront/samples.cpp b/src/pbrt/wavefront/samples.cpp index 20c72ccf2..ecb02d0e0 100644 --- a/src/pbrt/wavefront/samples.cpp +++ b/src/pbrt/wavefront/samples.cpp @@ -39,8 +39,6 @@ void WavefrontPathIntegrator::GenerateRaySamples(int wavefrontDepth, int sampleI int dimension = 6 + 7 * w.depth; if (haveSubsurface) dimension += 3 * w.depth; - if (haveMedia) - dimension += 2 * w.depth; // Initialize _Sampler_ for pixel, sample index, and dimension ConcreteSampler pixelSampler = *sampler.Cast(); @@ -62,12 +60,6 @@ void WavefrontPathIntegrator::GenerateRaySamples(int wavefrontDepth, int sampleI rs.subsurface.u = pixelSampler.Get2D(); } - rs.haveMedia = haveMedia; - if (haveMedia) { - rs.media.uDist = pixelSampler.Get1D(); - rs.media.uMode = pixelSampler.Get1D(); - } - // Store _RaySamples_ in pixel sample state pixelSampleState.samples[w.pixelIndex] = rs; }); diff --git a/src/pbrt/wavefront/workitems.h b/src/pbrt/wavefront/workitems.h index 982a8f6f1..b568a27fb 100644 --- a/src/pbrt/wavefront/workitems.h +++ b/src/pbrt/wavefront/workitems.h @@ -35,10 +35,6 @@ struct RaySamples { Float uc; Point2f u; } subsurface; - bool haveMedia; - struct { - Float uDist, uMode; - } media; }; template <> @@ -62,7 +58,6 @@ struct SOA { rs.direct.uc = dir.v[2]; rs.haveSubsurface = int(dir.v[3]) & 1; - rs.haveMedia = int(dir.v[3]) & 2; Float4 ind = Load4(indirect + i); rs.indirect.uc = ind.v[0]; @@ -75,11 +70,6 @@ struct SOA { rs.subsurface.u = Point2f(ss.v[1], ss.v[2]); } - if (rs.haveMedia) { - rs.media.uDist = mediaDist[i]; - rs.media.uMode = mediaMode[i]; - } - return rs; } @@ -89,7 +79,7 @@ struct SOA { PBRT_CPU_GPU void operator=(RaySamples rs) { - int flags = (rs.haveSubsurface ? 1 : 0) | (rs.haveMedia ? 2 : 0); + int flags = rs.haveSubsurface ? 1 : 0; soa->direct[index] = Float4{rs.direct.u[0], rs.direct.u[1], rs.direct.uc, Float(flags)}; soa->indirect[index] = Float4{rs.indirect.uc, rs.indirect.rr, @@ -97,10 +87,6 @@ struct SOA { if (rs.haveSubsurface) soa->subsurface[index] = Float4{rs.subsurface.uc, rs.subsurface.u.x, rs.subsurface.u.y, 0.f}; - if (rs.haveMedia) { - soa->mediaDist[index] = rs.media.uDist; - soa->mediaMode[index] = rs.media.uMode; - } } SOA *soa; From 3e197af29fa8314fef91c78e907c4501f8856e4e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 17 Jul 2022 13:52:32 -0700 Subject: [PATCH 071/149] Small fixes from book copyedits. --- src/pbrt/bxdfs.cpp | 2 +- src/pbrt/bxdfs.h | 12 ++++++------ src/pbrt/util/lowdiscrepancy.h | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pbrt/bxdfs.cpp b/src/pbrt/bxdfs.cpp index 691264353..a8ff0b8fa 100644 --- a/src/pbrt/bxdfs.cpp +++ b/src/pbrt/bxdfs.cpp @@ -78,7 +78,7 @@ pstd::optional DielectricBxDF::Sample_f( Vector3f wo, Float uc, Point2f u, TransportMode mode, BxDFReflTransFlags sampleFlags) const { if (eta == 1 || mfDistrib.EffectivelySmooth()) { - // Sample perfectly specular dielectric BSDF + // Sample perfect specular dielectric BSDF Float R = FrDielectric(CosTheta(wo), eta), T = 1 - R; // Compute probabilities _pr_ and _pt_ for sampling reflection and transmission Float pr = R, pt = T; diff --git a/src/pbrt/bxdfs.h b/src/pbrt/bxdfs.h index c14ba07af..33254357e 100644 --- a/src/pbrt/bxdfs.h +++ b/src/pbrt/bxdfs.h @@ -299,7 +299,7 @@ class ConductorBxDF { if (!(sampleFlags & BxDFReflTransFlags::Reflection)) return {}; if (mfDistrib.EffectivelySmooth()) { - // Sample perfectly specular conductor BRDF + // Sample perfect specular conductor BRDF Vector3f wi(-wo.x, -wo.y, wo.z); SampledSpectrum f = FrComplex(AbsCosTheta(wi), eta, k) / AbsCosTheta(wi); return BSDFSample(f, wi, 1, BxDFFlags::SpecularReflection); @@ -359,12 +359,12 @@ class ConductorBxDF { if (mfDistrib.EffectivelySmooth()) return 0; // Evaluate sampling PDF of rough conductor BRDF - Vector3f wh = wo + wi; - CHECK_RARE(1e-5f, LengthSquared(wh) == 0); - if (LengthSquared(wh) == 0) + Vector3f wm = wo + wi; + CHECK_RARE(1e-5f, LengthSquared(wm) == 0); + if (LengthSquared(wm) == 0) return 0; - wh = FaceForward(Normalize(wh), Normal3f(0, 0, 1)); - return mfDistrib.PDF(wo, wh) / (4 * AbsDot(wo, wh)); + wm = FaceForward(Normalize(wm), Normal3f(0, 0, 1)); + return mfDistrib.PDF(wo, wm) / (4 * AbsDot(wo, wm)); } PBRT_CPU_GPU diff --git a/src/pbrt/util/lowdiscrepancy.h b/src/pbrt/util/lowdiscrepancy.h index 60cd71d61..9ce4abab1 100644 --- a/src/pbrt/util/lowdiscrepancy.h +++ b/src/pbrt/util/lowdiscrepancy.h @@ -88,17 +88,17 @@ PBRT_CPU_GPU inline Float RadicalInverse(int baseIndex, uint64_t a) { // We have to stop once reversedDigits is >= limit since otherwise the // next digit of |a| may cause reversedDigits to overflow. uint64_t limit = ~0ull / base - base; - Float invBase = (Float)1 / (Float)base, invBaseN = 1; + Float invBase = (Float)1 / (Float)base, invBaseM = 1; uint64_t reversedDigits = 0; while (a && reversedDigits < limit) { // Extract least significant digit from _a_ and update _reversedDigits_ uint64_t next = a / base; uint64_t digit = a - next * base; reversedDigits = reversedDigits * base + digit; - invBaseN *= invBase; + invBaseM *= invBase; a = next; } - return std::min(reversedDigits * invBaseN, OneMinusEpsilon); + return std::min(reversedDigits * invBaseM, OneMinusEpsilon); } PBRT_CPU_GPU inline uint64_t InverseRadicalInverse(uint64_t inverse, int base, From edaa80a13fe7e2b00c13d84b96eb498ece229be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Kov=C3=A1=C5=99?= Date: Sat, 6 Aug 2022 17:45:59 +0200 Subject: [PATCH 072/149] Corrected denoiseAlpha parameter type --- src/pbrt/gpu/denoiser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/gpu/denoiser.cpp b/src/pbrt/gpu/denoiser.cpp index db66c5f34..ccb6783f9 100644 --- a/src/pbrt/gpu/denoiser.cpp +++ b/src/pbrt/gpu/denoiser.cpp @@ -101,7 +101,7 @@ void Denoiser::Denoise(RGB *rgb, Normal3f *n, RGB *albedo, RGB *result) { CUdeviceptr(scratchBuffer), memorySizes.withoutOverlapScratchSizeInBytes)); OptixDenoiserParams params = {}; - params.denoiseAlpha = 0; + params.denoiseAlpha = OPTIX_DENOISER_ALPHA_MODE_COPY; params.hdrIntensity = CUdeviceptr(intensity); params.blendFactor = 0; // TODO what should this be?? From 692cc6d03988e215172527e30614f71542b4b575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Kov=C3=A1=C5=99?= Date: Mon, 15 Aug 2022 19:11:51 +0200 Subject: [PATCH 073/149] Added OptiX version control to the denoise alpha mode --- src/pbrt/gpu/denoiser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pbrt/gpu/denoiser.cpp b/src/pbrt/gpu/denoiser.cpp index ccb6783f9..c593c207e 100644 --- a/src/pbrt/gpu/denoiser.cpp +++ b/src/pbrt/gpu/denoiser.cpp @@ -101,7 +101,11 @@ void Denoiser::Denoise(RGB *rgb, Normal3f *n, RGB *albedo, RGB *result) { CUdeviceptr(scratchBuffer), memorySizes.withoutOverlapScratchSizeInBytes)); OptixDenoiserParams params = {}; +#if (OPTIX_VERSION >= 70500) params.denoiseAlpha = OPTIX_DENOISER_ALPHA_MODE_COPY; +#else + params.denoiseAlpha = 0; +#endif params.hdrIntensity = CUdeviceptr(intensity); params.blendFactor = 0; // TODO what should this be?? From 8f2d8527af2bad5f99d31706c5f580178bf8d569 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 15 Aug 2022 15:58:02 -0700 Subject: [PATCH 074/149] Add optix 7.5 to github actions build test --- .github/workflows/ci-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index 3ae44e799..66f850a16 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - optix: [ optix-7.1.0, optix-7.2.0, optix-7.3.0, optix-7.4.0 ] + optix: [ optix-7.1.0, optix-7.2.0, optix-7.3.0, optix-7.4.0 optix-7.5.0 ] cuda: [ '11.2.2', '11.4.3', '11.5.2', '11.6.1', '11.7.0' ] # 11.3.0 fails for unclear reasons os: [ ubuntu-20.04, windows-latest ] From f13448d4ea9cc98672b461491fcc7112fcedeee8 Mon Sep 17 00:00:00 2001 From: jim price Date: Fri, 26 Aug 2022 12:11:49 -0700 Subject: [PATCH 075/149] Fix nullptr access reported in issue #293 --- src/pbrt/lights.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/lights.cpp b/src/pbrt/lights.cpp index c3adaae13..e059b8bc7 100644 --- a/src/pbrt/lights.cpp +++ b/src/pbrt/lights.cpp @@ -916,13 +916,13 @@ DiffuseAreaLight *DiffuseAreaLight::Create(const Transform &renderFromLight, // radiance such that the user-defined power will be the actual power // emitted by the light. Float k_e = 1; - // Get the appropriate luminance vector from the image colour space - RGB lum = imageColorSpace->LuminanceVector(); // we need to know which channels correspond to R, G and B // we know that the channelDesc is valid as we would have exited in the // block above otherwise ImageChannelDesc channelDesc = image.GetChannelDesc({"R", "G", "B"}); if (image) { + // Get the appropriate luminance vector from the image colour space + RGB lum = imageColorSpace->LuminanceVector(); k_e = 0; // Assume no distortion in the mapping, FWIW... for (int y = 0; y < image.Resolution().y; ++y) From f8643db0e493404c832da3b0873651f901b0cc44 Mon Sep 17 00:00:00 2001 From: jim price Date: Fri, 26 Aug 2022 16:04:50 -0700 Subject: [PATCH 076/149] Remove unused channelDesc variable. --- src/pbrt/lights.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pbrt/lights.cpp b/src/pbrt/lights.cpp index e059b8bc7..af1f66748 100644 --- a/src/pbrt/lights.cpp +++ b/src/pbrt/lights.cpp @@ -916,10 +916,6 @@ DiffuseAreaLight *DiffuseAreaLight::Create(const Transform &renderFromLight, // radiance such that the user-defined power will be the actual power // emitted by the light. Float k_e = 1; - // we need to know which channels correspond to R, G and B - // we know that the channelDesc is valid as we would have exited in the - // block above otherwise - ImageChannelDesc channelDesc = image.GetChannelDesc({"R", "G", "B"}); if (image) { // Get the appropriate luminance vector from the image colour space RGB lum = imageColorSpace->LuminanceVector(); From accfbcba62b44d364774954805757fa1dc28760c Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 31 Aug 2022 15:57:58 -0700 Subject: [PATCH 077/149] Attempt to enable compute 5.2 for NVIDIA GPU support Issue #292. --- cmake/checkcuda.cu | 2 +- src/pbrt/util/float.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/checkcuda.cu b/cmake/checkcuda.cu index cc6463d2b..f12b79098 100644 --- a/cmake/checkcuda.cu +++ b/cmake/checkcuda.cu @@ -5,7 +5,7 @@ int main(int argc, char **argv){ cudaDeviceProp dP; - float min_cc = 5.3; // We need half floats... + float min_cc = 5.2; int rc = cudaGetDeviceProperties(&dP, 0); if(rc != cudaSuccess) { diff --git a/src/pbrt/util/float.h b/src/pbrt/util/float.h index b318442cb..f0df1fbf9 100644 --- a/src/pbrt/util/float.h +++ b/src/pbrt/util/float.h @@ -499,7 +499,7 @@ class Half { PBRT_CPU_GPU bool operator==(const Half &v) const { -#ifdef PBRT_IS_GPU_CODE +#if defined(PBRT_IS_GPU_CODE) && __CUDA_ARCH__ >= 530 return __ushort_as_half(h) == __ushort_as_half(v.h); #else if (Bits() == v.Bits()) From 88f324c33771199863b3be54c357744c91061baa Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Tue, 1 Nov 2022 13:32:03 +0100 Subject: [PATCH 078/149] Fix denoise issues This patch fix a issue using denoise because a Variance channel names exposed here: https://github.com/mmp/pbrt-v4/issues/300 --- src/pbrt/cmd/imgtool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index e8e65b403..8f7656b6a 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -2424,8 +2424,8 @@ int denoise(std::vector args) { checkForChannels(nsDesc, "Nsx,Nsy,Nsz"); ImageChannelDesc albedoDesc = in.GetChannelDesc({"Albedo.R", "Albedo.G", "Albedo.B"}); checkForChannels(albedoDesc, "Albedo.R,Albedo.G,Albedo.B"); - ImageChannelDesc varianceDesc = in.GetChannelDesc({"rgbVariance"}); - checkForChannels(varianceDesc, "rgbVariance"); + ImageChannelDesc varianceDesc = in.GetChannelDesc({"Variance.R", "Variance.G", "Variance.B"}); + checkForChannels(varianceDesc, "Variance.R,Variance.G,Variance.B"); ImageChannelDesc jointDesc = in.GetChannelDesc({"Pz", "Nx", "Ny", "Nz"}); ImageChannelValues jointSigmaIndir(4, 1); From da416c8ba11efdfc26dce54fc224ebb68adde1f8 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 5 Nov 2022 12:52:27 -0700 Subject: [PATCH 079/149] Fix visualize strategies/weights for the BDPTIntegrator Issue #299. --- src/pbrt/cpu/integrators.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index 88e7f487c..e2bdb3056 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -2279,14 +2279,31 @@ SampledSpectrum BDPTIntegrator::Li(RayDifferential ray, SampledWavelengths &lamb StringPrintf("Connect bdpt s: %d, t: %d, Lpath: %s, misWeight: %f\n", s, t, Lpath, misWeight) .c_str()); - if (pFilmNew && (visualizeStrategies || visualizeWeights)) { + if (Lpath && (visualizeStrategies || visualizeWeights)) { SampledSpectrum value; if (visualizeStrategies) value = misWeight == 0 ? SampledSpectrum(0.) : Lpath / misWeight; if (visualizeWeights) value = Lpath; - CHECK(pFilmNew.has_value()); - weightFilms[BufferIndex(s, t)].AddSplat(*pFilmNew, value, lambda); + if (pFilmNew) + weightFilms[BufferIndex(s, t)].AddSplat(*pFilmNew, value, lambda); + else { + // Unfortunately we no longer have the pixel + // coordinates of the sample easily available, so we + // need to go back to the camera and ask for them; here + // we take a point a little bit along the camera ray + // and ask the camera to reproject that for us. + // + // Double unfortunately, this doesn't quite work for + // scenes where the camera has a finite aperture, since + // we don't have the CameraSample either so just have + // to pass (0.5,0.5) in for the lens sample... + pstd::optional cs = + camera.SampleWi(Interaction(ray(100.f), nullptr), Point2f(0.5f, 0.5f), lambda); + CHECK_RARE(1e-3, !cs); + if (cs) + weightFilms[BufferIndex(s, t)].AddSplat(cs->pRaster, value, lambda); + } } if (t != 1) L += Lpath; From 96e6028a295d07e9bd25c0aa05ebe64efe59284a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 6 Nov 2022 06:24:20 -0800 Subject: [PATCH 080/149] --interactive: don't exit once specified spp are taken Now the event loop continues running so that the camera can be moved further, etc., though we don't take more samples than specified since many samplers give unexpected / not useful results in that case. --- src/pbrt/wavefront/integrator.cpp | 161 +++++++++++++++--------------- 1 file changed, 83 insertions(+), 78 deletions(-) diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index c2ec69d49..1d1df3c2e 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -333,7 +333,7 @@ Float WavefrontPathIntegrator::Render() { ProgressReporter progress(lastSampleIndex - firstSampleIndex, "Rendering", Options->quiet || Options->interactive, Options->useGPU); - for (int sampleIndex = firstSampleIndex; sampleIndex < lastSampleIndex; + for (int sampleIndex = firstSampleIndex; sampleIndex < lastSampleIndex || gui; ++sampleIndex) { // Attempt to work around issue #145. #if !(defined(PBRT_IS_WINDOWS) && defined(PBRT_BUILD_GPU_RENDERER) && \ @@ -345,95 +345,101 @@ Float WavefrontPathIntegrator::Render() { }); #endif - // Render image for sample _sampleIndex_ - LOG_VERBOSE("Starting to submit work for sample %d", sampleIndex); - for (int y0 = pixelBounds.pMin.y; y0 < pixelBounds.pMax.y; - y0 += scanlinesPerPass) { - // Generate camera rays for current scanline range - RayQueue *cameraRayQueue = CurrentRayQueue(0); - Do( - "Reset ray queue", PBRT_CPU_GPU_LAMBDA() { - PBRT_DBG("Starting scanlines at y0 = %d, sample %d / %d\n", y0, - sampleIndex, samplesPerPixel); - cameraRayQueue->Reset(); - }); - - Transform cameraMotion; - if (gui) - cameraMotion = - renderFromCamera * gui->GetCameraTransform() * cameraFromRender; - GenerateCameraRays(y0, cameraMotion, sampleIndex); - Do( - "Update camera ray stats", - PBRT_CPU_GPU_LAMBDA() { stats->cameraRays += cameraRayQueue->Size(); }); - - // Trace rays and estimate radiance up to maximum ray depth - for (int wavefrontDepth = 0; true; ++wavefrontDepth) { - // Reset queues before tracing rays - RayQueue *nextQueue = NextRayQueue(wavefrontDepth); + // Keep running the outer for loop but don't take more samples if + // the GUI is being used so that the user can move the camera, etc. + if (sampleIndex < lastSampleIndex) { + // Render image for sample _sampleIndex_ + LOG_VERBOSE("Starting to submit work for sample %d", sampleIndex); + for (int y0 = pixelBounds.pMin.y; y0 < pixelBounds.pMax.y; + y0 += scanlinesPerPass) { + // Generate camera rays for current scanline range + RayQueue *cameraRayQueue = CurrentRayQueue(0); Do( - "Reset queues before tracing rays", PBRT_CPU_GPU_LAMBDA() { - nextQueue->Reset(); - // Reset queues before tracing next batch of rays - if (mediumSampleQueue) - mediumSampleQueue->Reset(); - if (mediumScatterQueue) - mediumScatterQueue->Reset(); - - if (escapedRayQueue) - escapedRayQueue->Reset(); - hitAreaLightQueue->Reset(); - - basicEvalMaterialQueue->Reset(); - universalEvalMaterialQueue->Reset(); - - if (bssrdfEvalQueue) - bssrdfEvalQueue->Reset(); - if (subsurfaceScatterQueue) - subsurfaceScatterQueue->Reset(); - }); - - // Follow active ray paths and accumulate radiance estimates - GenerateRaySamples(wavefrontDepth, sampleIndex); - - // Find closest intersections along active rays - aggregate->IntersectClosest( - maxQueueSize, CurrentRayQueue(wavefrontDepth), escapedRayQueue, - hitAreaLightQueue, basicEvalMaterialQueue, universalEvalMaterialQueue, - mediumSampleQueue, NextRayQueue(wavefrontDepth)); + "Reset ray queue", PBRT_CPU_GPU_LAMBDA() { + PBRT_DBG("Starting scanlines at y0 = %d, sample %d / %d\n", y0, + sampleIndex, samplesPerPixel); + cameraRayQueue->Reset(); + }); + + Transform cameraMotion; + if (gui) + cameraMotion = + renderFromCamera * gui->GetCameraTransform() * cameraFromRender; + GenerateCameraRays(y0, cameraMotion, sampleIndex); + Do( + "Update camera ray stats", + PBRT_CPU_GPU_LAMBDA() { stats->cameraRays += cameraRayQueue->Size(); }); - if (wavefrontDepth > 0) { - // As above, with the indexing... - RayQueue *statsQueue = CurrentRayQueue(wavefrontDepth); + // Trace rays and estimate radiance up to maximum ray depth + for (int wavefrontDepth = 0; true; ++wavefrontDepth) { + // Reset queues before tracing rays + RayQueue *nextQueue = NextRayQueue(wavefrontDepth); Do( - "Update indirect ray stats", PBRT_CPU_GPU_LAMBDA() { - stats->indirectRays[wavefrontDepth] += statsQueue->Size(); - }); - } + "Reset queues before tracing rays", PBRT_CPU_GPU_LAMBDA() { + nextQueue->Reset(); + // Reset queues before tracing next batch of rays + if (mediumSampleQueue) + mediumSampleQueue->Reset(); + if (mediumScatterQueue) + mediumScatterQueue->Reset(); + + if (escapedRayQueue) + escapedRayQueue->Reset(); + hitAreaLightQueue->Reset(); + + basicEvalMaterialQueue->Reset(); + universalEvalMaterialQueue->Reset(); + + if (bssrdfEvalQueue) + bssrdfEvalQueue->Reset(); + if (subsurfaceScatterQueue) + subsurfaceScatterQueue->Reset(); + }); + + // Follow active ray paths and accumulate radiance estimates + GenerateRaySamples(wavefrontDepth, sampleIndex); + + // Find closest intersections along active rays + aggregate->IntersectClosest( + maxQueueSize, CurrentRayQueue(wavefrontDepth), escapedRayQueue, + hitAreaLightQueue, basicEvalMaterialQueue, universalEvalMaterialQueue, + mediumSampleQueue, NextRayQueue(wavefrontDepth)); + + if (wavefrontDepth > 0) { + // As above, with the indexing... + RayQueue *statsQueue = CurrentRayQueue(wavefrontDepth); + Do( + "Update indirect ray stats", PBRT_CPU_GPU_LAMBDA() { + stats->indirectRays[wavefrontDepth] += statsQueue->Size(); + }); + } + + SampleMediumInteraction(wavefrontDepth); - SampleMediumInteraction(wavefrontDepth); + HandleEscapedRays(); - HandleEscapedRays(); + HandleEmissiveIntersection(); - HandleEmissiveIntersection(); + if (wavefrontDepth == maxDepth) + break; - if (wavefrontDepth == maxDepth) - break; + EvaluateMaterialsAndBSDFs(wavefrontDepth, cameraMotion); - EvaluateMaterialsAndBSDFs(wavefrontDepth, cameraMotion); + // Do immediately so that we have space for shadow rays for subsurface.. + TraceShadowRays(wavefrontDepth); - // Do immediately so that we have space for shadow rays for subsurface.. - TraceShadowRays(wavefrontDepth); + SampleSubsurface(wavefrontDepth); + } - SampleSubsurface(wavefrontDepth); + UpdateFilm(); } - UpdateFilm(); - } + // Copy updated film pixels to buffer for the display server. + if (Options->useGPU && !Options->displayServer.empty()) + UpdateDisplayRGBFromFilm(pixelBounds); - // Copy updated film pixels to buffer for the display server. - if (Options->useGPU && !Options->displayServer.empty()) - UpdateDisplayRGBFromFilm(pixelBounds); + progress.Update(); + } if (gui) { RGB *rgb = gui->MapFramebuffer(); @@ -465,7 +471,6 @@ Float WavefrontPathIntegrator::Render() { } } - progress.Update(); } if (gui) { From c2f454103e1c039ba3d2c9348a486b581c3778d7 Mon Sep 17 00:00:00 2001 From: Gon Solo Date: Thu, 10 Nov 2022 09:50:08 +0100 Subject: [PATCH 081/149] Fix crash on Wayland. --- src/pbrt/gpu/cudagl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pbrt/gpu/cudagl.h b/src/pbrt/gpu/cudagl.h index db6e055fc..8fe1cd2b4 100644 --- a/src/pbrt/gpu/cudagl.h +++ b/src/pbrt/gpu/cudagl.h @@ -352,9 +352,10 @@ CUDAOutputBuffer::CUDAOutputBuffer(int32_t width, int32_t height) CUDA_CHECK(cudaGetDevice(¤t_device)); CUDA_CHECK(cudaDeviceGetAttribute(&is_display_device, cudaDevAttrKernelExecTimeout, current_device)); - if (!is_display_device) - LOG_FATAL("GL interop is only available on display device."); - + if (getenv("XDG_SESSION_TYPE") != std::string("wayland")) { + if (!is_display_device) + LOG_FATAL("GL interop is only available on display device."); + } CUDA_CHECK(cudaGetDevice(&m_device_idx)); m_width = width; From 703026e31c836b2b8b80770f829c21e6fd3a42db Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 10 Nov 2022 05:58:54 -0800 Subject: [PATCH 082/149] Update cudagl.h Avoid segfault if XDG_SESSION_TYPE is unset --- src/pbrt/gpu/cudagl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/gpu/cudagl.h b/src/pbrt/gpu/cudagl.h index 8fe1cd2b4..2695844f2 100644 --- a/src/pbrt/gpu/cudagl.h +++ b/src/pbrt/gpu/cudagl.h @@ -352,7 +352,7 @@ CUDAOutputBuffer::CUDAOutputBuffer(int32_t width, int32_t height) CUDA_CHECK(cudaGetDevice(¤t_device)); CUDA_CHECK(cudaDeviceGetAttribute(&is_display_device, cudaDevAttrKernelExecTimeout, current_device)); - if (getenv("XDG_SESSION_TYPE") != std::string("wayland")) { + if (getenv("XDG_SESSION_TYPE") == nullptr || getenv("XDG_SESSION_TYPE") != std::string("wayland")) { if (!is_display_device) LOG_FATAL("GL interop is only available on display device."); } From 1344f26abca8ff05c3bdbf732085685ba8eb714d Mon Sep 17 00:00:00 2001 From: Gon Solo Date: Thu, 10 Nov 2022 19:25:49 +0100 Subject: [PATCH 083/149] Enable fullscreen rendering. --- src/pbrt/cmd/pbrt.cpp | 6 ++++++ src/pbrt/film.cpp | 13 +++++++++++-- src/pbrt/options.cpp | 4 ++-- src/pbrt/options.h | 1 + src/pbrt/pbrt.cpp | 3 +++ src/pbrt/util/gui.cpp | 21 ++++++++++++++++++--- src/pbrt/util/gui.h | 3 +++ 7 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/pbrt/cmd/pbrt.cpp b/src/pbrt/cmd/pbrt.cpp index d9634df6b..aec8dd46e 100644 --- a/src/pbrt/cmd/pbrt.cpp +++ b/src/pbrt/cmd/pbrt.cpp @@ -55,6 +55,7 @@ Rendering options: R"( --help Print this help text. --interactive Enable interactive rendering mode. + --fullscreen Render fullscreen. Only possible with interactive. --mse-reference-image Filename for reference image to use for MSE computation. --mse-reference-out File to write MSE error vs spp results. --nthreads Use specified number of threads for rendering. @@ -178,6 +179,7 @@ int main(int argc, char *argv[]) { onError) || ParseArg(&iter, args.end(), "log-file", &options.logFile, onError) || ParseArg(&iter, args.end(), "interactive", &options.interactive, onError) || + ParseArg(&iter, args.end(), "fullscreen", &options.fullscreen, onError) || ParseArg(&iter, args.end(), "mse-reference-image", &options.mseReferenceImage, onError) || ParseArg(&iter, args.end(), "mse-reference-out", &options.mseReferenceOutput, @@ -254,6 +256,10 @@ int main(int argc, char *argv[]) { ErrorExit("The --interactive option is only supported with the --gpu " "and --wavefront integrators."); + if (options.fullscreen && !options.interactive) { + ErrorExit("The --fullscreen option is only supported in interactive mode"); + } + options.logLevel = LogLevelFromString(logLevel); // Initialize pbrt diff --git a/src/pbrt/film.cpp b/src/pbrt/film.cpp index 14719c328..f1d21d187 100644 --- a/src/pbrt/film.cpp +++ b/src/pbrt/film.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -78,8 +79,16 @@ FilmBaseParameters::FilmBaseParameters(const ParameterDictionary ¶meters, } else if (filename.empty()) filename = "pbrt.exr"; - fullResolution = Point2i(parameters.GetOneInt("xresolution", 1280), - parameters.GetOneInt("yresolution", 720)); + if (Options->fullscreen) { + fullResolution = GUI::GetResolution(); + + // Omit unused parameter error + auto unusedX = parameters.GetOneInt("xresolution", 1280); + auto unusedY = parameters.GetOneInt("yresolution", 720); + } else { + fullResolution = Point2i(parameters.GetOneInt("xresolution", 1280), + parameters.GetOneInt("yresolution", 720)); + } if (Options->quickRender) { fullResolution.x = std::max(1, fullResolution.x / 4); fullResolution.y = std::max(1, fullResolution.y / 4); diff --git a/src/pbrt/options.cpp b/src/pbrt/options.cpp index ae931658e..e01da78d1 100644 --- a/src/pbrt/options.cpp +++ b/src/pbrt/options.cpp @@ -36,7 +36,7 @@ std::string PBRTOptions::ToString() const { return StringPrintf( "[ PBRTOptions seed: %s quiet: %s disablePixelJitter: %s " "disableWavelengthJitter: %s disableTextureFiltering: %s forceDiffuse: %s " - "useGPU: %s wavefront: %s interactive: %s renderingSpace: %s nThreads: %s " + "useGPU: %s wavefront: %s interactive: %s fullscreen: %s renderingSpace: %s nThreads: %s " "logLevel: %s logFile: " "%s logUtilization: %s writePartialImages: %s recordPixelStatistics: %s " "printStatistics: %s pixelSamples: %s gpuDevice: %s quickRender: %s upgrade: %s " @@ -44,7 +44,7 @@ std::string PBRTOptions::ToString() const { "displayServer: %s cropWindow: %s pixelBounds: %s pixelMaterial: %s " "displacementEdgeScale: %f ]", seed, quiet, disablePixelJitter, disableWavelengthJitter, disableTextureFiltering, - forceDiffuse, useGPU, wavefront, interactive, renderingSpace, nThreads, logLevel, + forceDiffuse, useGPU, wavefront, interactive, fullscreen, renderingSpace, nThreads, logLevel, logFile, logUtilization, writePartialImages, recordPixelStatistics, printStatistics, pixelSamples, gpuDevice, quickRender, upgrade, imageFile, mseReferenceImage, mseReferenceOutput, debugStart, displayServer, cropWindow, diff --git a/src/pbrt/options.h b/src/pbrt/options.h index 3f1a4be37..7e79d2487 100644 --- a/src/pbrt/options.h +++ b/src/pbrt/options.h @@ -28,6 +28,7 @@ struct BasicPBRTOptions { bool useGPU = false; bool wavefront = false; bool interactive = false; + bool fullscreen = false; RenderingCoordinateSystem renderingSpace = RenderingCoordinateSystem::CameraWorld; }; diff --git a/src/pbrt/pbrt.cpp b/src/pbrt/pbrt.cpp index 79f239a20..2ddb03bd9 100644 --- a/src/pbrt/pbrt.cpp +++ b/src/pbrt/pbrt.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,8 @@ void InitPBRT(const PBRTOptions &opt) { InitBufferCaches(); + GUI::Initialize(); + if (!Options->displayServer.empty()) ConnectToDisplayServer(Options->displayServer); } diff --git a/src/pbrt/util/gui.cpp b/src/pbrt/util/gui.cpp index 6a54002c2..51d219f28 100644 --- a/src/pbrt/util/gui.cpp +++ b/src/pbrt/util/gui.cpp @@ -194,6 +194,17 @@ void GUI::mouseButtonCallback(GLFWwindow* window, int button, int action, int mo } } +void GUI::Initialize() { + if (!glfwInit()) + LOG_FATAL("Unable to initialize GLFW"); +} + +Point2i GUI::GetResolution() { + auto monitor = glfwGetPrimaryMonitor(); + auto videoMode = glfwGetVideoMode(monitor); + return Point2i(videoMode->width, videoMode->height); +} + static void glfwMouseButtonCallback(GLFWwindow* window, int button, int action, int mods) { GUI* gui = (GUI*)glfwGetWindowUserPointer(window); @@ -214,12 +225,16 @@ void GUI::cursorPosCallback(GLFWwindow* window, double xpos, double ypos) { GUI::GUI(std::string title, Vector2i resolution, Bounds3f sceneBounds) : resolution(resolution) { + moveScale = Length(sceneBounds.Diagonal()) / 1000.f; glfwSetErrorCallback(glfwErrorCallback); - if (!glfwInit()) - LOG_FATAL("Unable to initialize GLFW"); - window = glfwCreateWindow(resolution.x, resolution.y, "pbrt", NULL, NULL); + if (Options->fullscreen) { + window = glfwCreateWindow(resolution.x, resolution.y, "pbrt", glfwGetPrimaryMonitor(), NULL); + } else { + window = glfwCreateWindow(resolution.x, resolution.y, "pbrt", NULL, NULL); + } + if (!window) { glfwTerminate(); LOG_FATAL("Unable to create GLFW window"); diff --git a/src/pbrt/util/gui.h b/src/pbrt/util/gui.h index a115c5b99..7983e8eb6 100644 --- a/src/pbrt/util/gui.h +++ b/src/pbrt/util/gui.h @@ -57,6 +57,9 @@ class GUI { void cursorPosCallback(GLFWwindow *window, double xpos, double ypos); void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods); + static void Initialize(); + static Point2i GetResolution(); + private: bool processKeys(); bool processMouse(); From 5e76a015669b575ef611d0814b84d2b024f26ab1 Mon Sep 17 00:00:00 2001 From: Gon Solo Date: Fri, 11 Nov 2022 09:05:17 +0100 Subject: [PATCH 084/149] Initialize GUI only in interactive mode. --- src/pbrt/pbrt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pbrt/pbrt.cpp b/src/pbrt/pbrt.cpp index 2ddb03bd9..e3e57142d 100644 --- a/src/pbrt/pbrt.cpp +++ b/src/pbrt/pbrt.cpp @@ -124,7 +124,9 @@ void InitPBRT(const PBRTOptions &opt) { InitBufferCaches(); - GUI::Initialize(); + if (Options->interactive) { + GUI::Initialize(); + } if (!Options->displayServer.empty()) ConnectToDisplayServer(Options->displayServer); From 32fcbfa100340b848127e8c12c3178eae1a143f7 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 16 Nov 2022 12:46:18 -0800 Subject: [PATCH 085/149] Add --disable-image-textures option --- src/pbrt/cmd/pbrt.cpp | 3 +++ src/pbrt/options.cpp | 12 ++++++------ src/pbrt/options.h | 1 + src/pbrt/util/mipmap.cpp | 6 ++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pbrt/cmd/pbrt.cpp b/src/pbrt/cmd/pbrt.cpp index d9634df6b..c7eeb6767 100644 --- a/src/pbrt/cmd/pbrt.cpp +++ b/src/pbrt/cmd/pbrt.cpp @@ -39,6 +39,7 @@ Rendering options: --debugstart Inform the Integrator where to start rendering for faster debugging. ( are Integrator-specific and come from error message text.) + --disable-image-textures Always return the average value of image textures. --disable-pixel-jitter Always sample pixels at their centers. --disable-texture-filtering Point-sample all textures. --disable-wavelength-jitter Always sample the same %d wavelengths of light. @@ -160,6 +161,8 @@ int main(int argc, char *argv[]) { ParseArg(&iter, args.end(), "gpu-device", &options.gpuDevice, onError) || #endif ParseArg(&iter, args.end(), "debugstart", &options.debugStart, onError) || + ParseArg(&iter, args.end(), "disable-image-textures", + &options.disableImageTextures, onError) || ParseArg(&iter, args.end(), "disable-pixel-jitter", &options.disablePixelJitter, onError) || ParseArg(&iter, args.end(), "disable-texture-filtering", diff --git a/src/pbrt/options.cpp b/src/pbrt/options.cpp index ae931658e..bdc41647b 100644 --- a/src/pbrt/options.cpp +++ b/src/pbrt/options.cpp @@ -35,17 +35,17 @@ std::string ToString(const RenderingCoordinateSystem &r) { std::string PBRTOptions::ToString() const { return StringPrintf( "[ PBRTOptions seed: %s quiet: %s disablePixelJitter: %s " - "disableWavelengthJitter: %s disableTextureFiltering: %s forceDiffuse: %s " - "useGPU: %s wavefront: %s interactive: %s renderingSpace: %s nThreads: %s " - "logLevel: %s logFile: " - "%s logUtilization: %s writePartialImages: %s recordPixelStatistics: %s " + "disableWavelengthJitter: %s disableTextureFiltering: %s disableImageTextures: %s " + "forceDiffuse: %s useGPU: %s wavefront: %s interactive: %s renderingSpace: %s " + "nThreads: %s logLevel: %s logFile: %s logUtilization: %s writePartialImages: %s " + "recordPixelStatistics: %s " "printStatistics: %s pixelSamples: %s gpuDevice: %s quickRender: %s upgrade: %s " "imageFile: %s mseReferenceImage: %s mseReferenceOutput: %s debugStart: %s " "displayServer: %s cropWindow: %s pixelBounds: %s pixelMaterial: %s " "displacementEdgeScale: %f ]", seed, quiet, disablePixelJitter, disableWavelengthJitter, disableTextureFiltering, - forceDiffuse, useGPU, wavefront, interactive, renderingSpace, nThreads, logLevel, - logFile, logUtilization, writePartialImages, recordPixelStatistics, + disableImageTextures, forceDiffuse, useGPU, wavefront, interactive, renderingSpace, + nThreads, logLevel, logFile, logUtilization, writePartialImages, recordPixelStatistics, printStatistics, pixelSamples, gpuDevice, quickRender, upgrade, imageFile, mseReferenceImage, mseReferenceOutput, debugStart, displayServer, cropWindow, pixelBounds, pixelMaterial, displacementEdgeScale); diff --git a/src/pbrt/options.h b/src/pbrt/options.h index 3f1a4be37..8cc8bb061 100644 --- a/src/pbrt/options.h +++ b/src/pbrt/options.h @@ -24,6 +24,7 @@ struct BasicPBRTOptions { bool quiet = false; bool disablePixelJitter = false, disableWavelengthJitter = false; bool disableTextureFiltering = false; + bool disableImageTextures = false; bool forceDiffuse = false; bool useGPU = false; bool wavefront = false; diff --git a/src/pbrt/util/mipmap.cpp b/src/pbrt/util/mipmap.cpp index 336358978..9c834ade1 100644 --- a/src/pbrt/util/mipmap.cpp +++ b/src/pbrt/util/mipmap.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -195,6 +196,11 @@ MIPMap::MIPMap(Image image, const RGBColorSpace *colorSpace, WrapMode wrapMode, : colorSpace(colorSpace), wrapMode(wrapMode), options(options) { CHECK(colorSpace); pyramid = Image::GeneratePyramid(std::move(image), wrapMode, alloc); + if (Options->disableImageTextures) { + Image top = pyramid.back(); + pyramid.clear(); + pyramid.push_back(top); + } std::for_each(pyramid.begin(), pyramid.end(), [](const Image &im) { imageMapBytes += im.BytesUsed(); }); } From fcc230f785fa7408844ca8c7499f98873b3aaef8 Mon Sep 17 00:00:00 2001 From: Gon Solo Date: Wed, 16 Nov 2022 22:12:40 +0100 Subject: [PATCH 086/149] Do not allow --quick in interactive mode. --- src/pbrt/cmd/pbrt.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pbrt/cmd/pbrt.cpp b/src/pbrt/cmd/pbrt.cpp index aec8dd46e..9ccd2a91d 100644 --- a/src/pbrt/cmd/pbrt.cpp +++ b/src/pbrt/cmd/pbrt.cpp @@ -260,6 +260,10 @@ int main(int argc, char *argv[]) { ErrorExit("The --fullscreen option is only supported in interactive mode"); } + if (options.interactive && options.quickRender) { + ErrorExit("The --quick option is not supported in interactive mode"); + } + options.logLevel = LogLevelFromString(logLevel); // Initialize pbrt From 23607d4268a029d99cc4190862df557f646c9914 Mon Sep 17 00:00:00 2001 From: Gon Solo Date: Wed, 16 Nov 2022 22:20:34 +0100 Subject: [PATCH 087/149] Ignore screenwindow in fullscreen mode. --- src/pbrt/cameras.cpp | 57 ++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/src/pbrt/cameras.cpp b/src/pbrt/cameras.cpp index 49b2d960b..20428ac88 100644 --- a/src/pbrt/cameras.cpp +++ b/src/pbrt/cameras.cpp @@ -383,13 +383,18 @@ OrthographicCamera *OrthographicCamera::Create(const ParameterDictionary ¶me } std::vector sw = parameters.GetFloatArray("screenwindow"); if (!sw.empty()) { - if (sw.size() == 4) { - screen.pMin.x = sw[0]; - screen.pMax.x = sw[1]; - screen.pMin.y = sw[2]; - screen.pMax.y = sw[3]; - } else - Error("\"screenwindow\" should have four values"); + if (Options->fullscreen) { + Warning("\"screenwindow\" is ignored in fullscreen mode"); + } else { + if (sw.size() == 4) { + screen.pMin.x = sw[0]; + screen.pMax.x = sw[1]; + screen.pMin.y = sw[2]; + screen.pMax.y = sw[3]; + } else { + Error("\"screenwindow\" should have four values"); + } + } } return alloc.new_object(cameraBaseParameters, screen, lensradius, focaldistance); @@ -504,13 +509,18 @@ PerspectiveCamera *PerspectiveCamera::Create(const ParameterDictionary ¶mete } std::vector sw = parameters.GetFloatArray("screenwindow"); if (!sw.empty()) { - if (sw.size() == 4) { - screen.pMin.x = sw[0]; - screen.pMax.x = sw[1]; - screen.pMin.y = sw[2]; - screen.pMax.y = sw[3]; - } else - Error(loc, "\"screenwindow\" should have four values"); + if (Options->fullscreen) { + Warning("\"screenwindow\" is ignored in fullscreen mode"); + } else { + if (sw.size() == 4) { + screen.pMin.x = sw[0]; + screen.pMax.x = sw[1]; + screen.pMin.y = sw[2]; + screen.pMax.y = sw[3]; + } else { + Error(loc, "\"screenwindow\" should have four values"); + } + } } Float fov = parameters.GetOneFloat("fov", 90.); return alloc.new_object(cameraBaseParameters, fov, screen, @@ -645,13 +655,18 @@ SphericalCamera *SphericalCamera::Create(const ParameterDictionary ¶meters, } std::vector sw = parameters.GetFloatArray("screenwindow"); if (!sw.empty()) { - if (sw.size() == 4) { - screen.pMin.x = sw[0]; - screen.pMax.x = sw[1]; - screen.pMin.y = sw[2]; - screen.pMax.y = sw[3]; - } else - Error(loc, "\"screenwindow\" should have four values"); + if (Options->fullscreen) { + Warning("\"screenwindow\" is ignored in fullscreen mode"); + } else { + if (sw.size() == 4) { + screen.pMin.x = sw[0]; + screen.pMax.x = sw[1]; + screen.pMin.y = sw[2]; + screen.pMax.y = sw[3]; + } else { + Error(loc, "\"screenwindow\" should have four values"); + } + } } (void)lensradius; // don't need this (void)focaldistance; // don't need this From 9fb41b22cf002636f2bbb73a052fa0e5fd9f81dc Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 16 Nov 2022 16:06:05 -0800 Subject: [PATCH 088/149] Reword --fullscreen text, alphabetize it in the usage message --- src/pbrt/cmd/pbrt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/cmd/pbrt.cpp b/src/pbrt/cmd/pbrt.cpp index 1514d823e..0b3affd6c 100644 --- a/src/pbrt/cmd/pbrt.cpp +++ b/src/pbrt/cmd/pbrt.cpp @@ -48,6 +48,7 @@ Rendering options: --display-server Connect to display server at given address and port to display the image as it's being rendered. --force-diffuse Convert all materials to be diffuse.)" + --fullscreen Render fullscreen. Only supported with --interactive. #ifdef PBRT_BUILD_GPU_RENDERER R"( --gpu Use the GPU for rendering. (Default: disabled) @@ -56,7 +57,6 @@ Rendering options: R"( --help Print this help text. --interactive Enable interactive rendering mode. - --fullscreen Render fullscreen. Only possible with interactive. --mse-reference-image Filename for reference image to use for MSE computation. --mse-reference-out File to write MSE error vs spp results. --nthreads Use specified number of threads for rendering. From 274a8641ebdaee705ee292a8ae3491aa14c4c654 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 16 Nov 2022 16:10:33 -0800 Subject: [PATCH 089/149] Fix build break from bad edit of raw string constant. --- src/pbrt/cmd/pbrt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/cmd/pbrt.cpp b/src/pbrt/cmd/pbrt.cpp index 0b3affd6c..2cc9d6122 100644 --- a/src/pbrt/cmd/pbrt.cpp +++ b/src/pbrt/cmd/pbrt.cpp @@ -47,8 +47,8 @@ Rendering options: (Default: 1) --display-server Connect to display server at given address and port to display the image as it's being rendered. - --force-diffuse Convert all materials to be diffuse.)" - --fullscreen Render fullscreen. Only supported with --interactive. + --force-diffuse Convert all materials to be diffuse.) + --fullscreen Render fullscreen. Only supported with --interactive.)" #ifdef PBRT_BUILD_GPU_RENDERER R"( --gpu Use the GPU for rendering. (Default: disabled) From 6aa009b7b1b650407867c8f84c1f1bbc7601ea93 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 18 Nov 2022 17:10:31 -0800 Subject: [PATCH 090/149] Fix a few integer overflows with very high-res images. --- src/pbrt/util/image.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pbrt/util/image.cpp b/src/pbrt/util/image.cpp index 101808257..5ee5862c1 100644 --- a/src/pbrt/util/image.cpp +++ b/src/pbrt/util/image.cpp @@ -393,12 +393,12 @@ Image::Image(PixelFormat format, Point2i resolution, p16(alloc), p32(alloc) { if (Is8Bit(format)) { - p8.resize(NChannels() * resolution[0] * resolution[1]); + p8.resize(NChannels() * size_t(resolution[0]) * size_t(resolution[1])); CHECK(encoding); } else if (Is16Bit(format)) - p16.resize(NChannels() * resolution[0] * resolution[1]); + p16.resize(NChannels() * size_t(resolution[0]) * size_t(resolution[1])); else if (Is32Bit(format)) - p32.resize(NChannels() * resolution[0] * resolution[1]); + p32.resize(NChannels() * size_t(resolution[0]) * size_t(resolution[1])); else LOG_FATAL("Unhandled format in Image::Image()"); } @@ -568,7 +568,7 @@ ImageChannelValues Image::MAE(const ImageChannelDesc &desc, const Image &ref, ImageChannelValues error(desc.size()); for (int c = 0; c < desc.size(); ++c) - error[c] = sumError[c] / (Resolution().x * Resolution().y); + error[c] = sumError[c] / (Float(Resolution().x) * Float(Resolution().y)); return error; } @@ -602,7 +602,7 @@ ImageChannelValues Image::MSE(const ImageChannelDesc &desc, const Image &ref, ImageChannelValues mse(desc.size()); for (int c = 0; c < desc.size(); ++c) - mse[c] = sumSE[c] / (Resolution().x * Resolution().y); + mse[c] = sumSE[c] / (Float(Resolution().x) * Float(Resolution().y)); return mse; } @@ -634,7 +634,7 @@ ImageChannelValues Image::MRSE(const ImageChannelDesc &desc, const Image &ref, ImageChannelValues mrse(desc.size()); for (int c = 0; c < desc.size(); ++c) - mrse[c] = sumRSE[c] / (Resolution().x * Resolution().y); + mrse[c] = sumRSE[c] / (Float(Resolution().x) * Float(Resolution().y)); return mrse; } @@ -650,7 +650,7 @@ ImageChannelValues Image::Average(const ImageChannelDesc &desc) const { ImageChannelValues average(desc.size()); for (int c = 0; c < desc.size(); ++c) - average[c] = sum[c] / (Resolution().x * Resolution().y); + average[c] = sum[c] / (Float(Resolution().x) * Float(Resolution().y)); return average; } @@ -922,7 +922,7 @@ ImageAndMetadata Image::Read(std::string name, Allocator alloc, ColorEncoding en bool Image::Write(std::string name, const ImageMetadata &metadata) const { if (metadata.pixelBounds) - CHECK_EQ(metadata.pixelBounds->Area(), resolution.x * resolution.y); + CHECK_EQ(metadata.pixelBounds->Area(), size_t(resolution.x) * size_t(resolution.y)); if (HasExtension(name, "exr")) return WriteEXR(name, metadata); @@ -1428,7 +1428,7 @@ std::string Image::ToString() const { std::unique_ptr Image::QuantizePixelsToU256(int *nOutOfGamut) const { std::unique_ptr u256 = - std::make_unique(NChannels() * resolution.x * resolution.y); + std::make_unique(NChannels() * size_t(resolution.x) * size_t(resolution.y)); for (int y = 0; y < resolution.y; ++y) for (int x = 0; x < resolution.x; ++x) for (int c = 0; c < NChannels(); ++c) { @@ -1614,7 +1614,7 @@ static int readWord(FILE *fp, char *buffer, int bufferLength) { static ImageAndMetadata ReadPFM(const std::string &filename, Allocator alloc) { pstd::vector rgb32(alloc); char buffer[BUFFER_SIZE]; - unsigned int nFloats; + size_t nFloats; int nChannels, width, height; float scale; bool fileLittleEndian; @@ -1656,7 +1656,7 @@ static ImageAndMetadata ReadPFM(const std::string &filename, Allocator alloc) { ErrorExit("%s: unable to decode scale \"%s\"", filename, buffer); // read the data - nFloats = nChannels * width * height; + nFloats = nChannels * size_t(width) * size_t(height); rgb32.resize(nFloats); for (int y = height - 1; y >= 0; --y) if (fread(&rgb32[nChannels * y * width], sizeof(float), nChannels * width, fp) != @@ -1700,7 +1700,7 @@ static ImageAndMetadata ReadHDR(const std::string &filename, Allocator alloc) { if (!data) ErrorExit("%s: %s", filename, stbi_failure_reason()); - pstd::vector pixels(data, data + x * y * n, alloc); + pstd::vector pixels(data, data + size_t(x) * size_t(y) * size_t(n), alloc); stbi_image_free(data); switch (n) { @@ -1746,7 +1746,7 @@ static ImageAndMetadata ReadQOI(const std::string &filename, Allocator alloc) { Image image(PixelFormat::U256, Point2i(desc.width, desc.height), channelNames, encoding, alloc); std::memcpy(image.RawPointer({0, 0}), pixels, - desc.width * desc.height * desc.channels); + size_t(desc.width) * size_t(desc.height) * desc.channels); free(pixels); From 4437d22630ace64571c78524b6746397ae8a975b Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 21 Dec 2022 06:42:41 -0800 Subject: [PATCH 091/149] Use consistent parameter name on CPU/GPU for displacment edge length --- src/pbrt/gpu/aggregate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index 8b8a76984..fd5785007 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -268,7 +268,7 @@ std::map OptiXAggregate::PreparePLYMeshes( plyMesh.ConvertToOnlyTriangles(); Float edgeLength = - shape.parameters.GetOneFloat("displacement.edgelength", 1.f); + shape.parameters.GetOneFloat("edgelength", 1.f); edgeLength *= Options->displacementEdgeScale; std::string displacementTexName = shape.parameters.GetTexture("displacement"); From 7c8b9ffd7a74efc409c453873cd27ee2a3f7c483 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 20 Nov 2022 11:21:22 -0800 Subject: [PATCH 092/149] Fix bug in ParameterDictionary::lookupSingle() error check --- src/pbrt/paramdict.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/paramdict.cpp b/src/pbrt/paramdict.cpp index 91f4ccd54..4024fb1fc 100644 --- a/src/pbrt/paramdict.cpp +++ b/src/pbrt/paramdict.cpp @@ -217,7 +217,7 @@ typename ParameterTypeTraits::ReturnType ParameterDictionary::lookupSingle( // Issue error if an incorrect number of parameter values were provided if (values.empty()) ErrorExit(&p->loc, "No values provided for parameter \"%s\".", name); - if (values.size() > traits::nPerItem) + if (values.size() != traits::nPerItem) ErrorExit(&p->loc, "Expected %d values for parameter \"%s\".", traits::nPerItem, name); From f8f260fe3126acabaa58caeffed96dc901f6e55c Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 20 Nov 2022 11:22:35 -0800 Subject: [PATCH 093/149] wavefront/intersect.h: fix variable naming consistency i.e., match the r_u/r_l notation used in the book and in VolPathIntegrator. --- src/pbrt/wavefront/integrator.cpp | 20 ++++---- src/pbrt/wavefront/intersect.h | 67 +++++++++++++-------------- src/pbrt/wavefront/media.cpp | 74 +++++++++++++++--------------- src/pbrt/wavefront/subsurface.cpp | 52 ++++++++++----------- src/pbrt/wavefront/surfscatter.cpp | 46 +++++++++---------- src/pbrt/wavefront/workitems.h | 54 +++++++++++----------- src/pbrt/wavefront/workitems.soa | 18 ++++---- 7 files changed, 164 insertions(+), 167 deletions(-) diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index 1d1df3c2e..385c0fcc0 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -509,18 +509,18 @@ void WavefrontPathIntegrator::HandleEscapedRays() { PBRT_DBG("depth %d specularBounce %d pdf uni %f %f %f %f " "pdf nee %f %f %f %f\n", w.depth, w.specularBounce, - w.inv_w_u[0], w.inv_w_u[1], w.inv_w_u[2], w.inv_w_u[3], - w.inv_w_l[0], w.inv_w_l[1], w.inv_w_l[2], w.inv_w_l[3]); + w.r_u[0], w.r_u[1], w.r_u[2], w.r_u[3], + w.r_l[0], w.r_l[1], w.r_l[2], w.r_l[3]); if (w.depth == 0 || w.specularBounce) { - L += w.beta * Le / w.inv_w_u.Average(); + L += w.beta * Le / w.r_u.Average(); } else { // Compute MIS-weighted radiance contribution from infinite light LightSampleContext ctx = w.prevIntrCtx; Float lightChoicePDF = lightSampler.PMF(ctx, light); - SampledSpectrum inv_w_l = - w.inv_w_l * lightChoicePDF * light.PDF_Li(ctx, w.rayd, true); - L += w.beta * Le / (w.inv_w_u + inv_w_l).Average(); + SampledSpectrum r_l = + w.r_l * lightChoicePDF * light.PDF_Li(ctx, w.rayd, true); + L += w.beta * Le / (w.r_u + r_l).Average(); } } } @@ -550,7 +550,7 @@ void WavefrontPathIntegrator::HandleEmissiveIntersection() { // Compute area light's weighted radiance contribution to the path SampledSpectrum L(0.f); if (w.depth == 0 || w.specularBounce) { - L = w.beta * Le / w.inv_w_u.Average(); + L = w.beta * Le / w.r_u.Average(); } else { // Compute MIS-weighted radiance contribution from area light Vector3f wi = -w.wo; @@ -558,9 +558,9 @@ void WavefrontPathIntegrator::HandleEmissiveIntersection() { Float lightChoicePDF = lightSampler.PMF(ctx, w.areaLight); Float lightPDF = lightChoicePDF * w.areaLight.PDF_Li(ctx, wi, true); - SampledSpectrum inv_w_u = w.inv_w_u; - SampledSpectrum inv_w_l = w.inv_w_l * lightPDF; - L = w.beta * Le / (inv_w_u + inv_w_l).Average(); + SampledSpectrum r_u = w.r_u; + SampledSpectrum r_l = w.r_l * lightPDF; + L = w.beta * Le / (r_u + r_l).Average(); } PBRT_DBG("Added L %f %f %f %f for pixel index %d\n", L[0], L[1], L[2], L[3], diff --git a/src/pbrt/wavefront/intersect.h b/src/pbrt/wavefront/intersect.h index 421002e34..310173a1e 100644 --- a/src/pbrt/wavefront/intersect.h +++ b/src/pbrt/wavefront/intersect.h @@ -35,12 +35,11 @@ inline PBRT_CPU_GPU void RecordShadowRayResult(const ShadowRayWorkItem w, PBRT_DBG("Shadow ray was occluded\n"); return; } - SampledSpectrum Ld = w.Ld / (w.inv_w_u + w.inv_w_l).Average(); + SampledSpectrum Ld = w.Ld / (w.r_u + w.r_l).Average(); PBRT_DBG("Unoccluded shadow ray. Final Ld %f %f %f %f " - "(sr.Ld %f %f %f %f inv_w_u %f %f %f %f inv_w_l %f %f %f %f)\n", - Ld[0], Ld[1], Ld[2], Ld[3], w.Ld[0], w.Ld[1], w.Ld[2], w.Ld[3], w.inv_w_u[0], - w.inv_w_u[1], w.inv_w_u[2], w.inv_w_u[3], w.inv_w_l[0], w.inv_w_l[1], - w.inv_w_l[2], w.inv_w_l[3]); + "(sr.Ld %f %f %f %f r_u %f %f %f %f r_l %f %f %f %f)\n", + Ld[0], Ld[1], Ld[2], Ld[3], w.Ld[0], w.Ld[1], w.Ld[2], w.Ld[3], w.r_u[0], + w.r_u[1], w.r_u[2], w.r_u[3], w.r_l[0], w.r_l[1], w.r_l[2], w.r_l[3]); SampledSpectrum Lpixel = pixelSampleState->L[w.pixelIndex]; pixelSampleState->L[w.pixelIndex] = Lpixel + Ld; @@ -62,8 +61,8 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection( tMax, r.lambda, r.beta, - r.inv_w_u, - r.inv_w_l, + r.r_u, + r.r_l, r.pixelIndex, r.prevIntrCtx, r.specularBounce, @@ -101,8 +100,8 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection( PBRT_DBG("Enqueuing into medium transition queue: pixel index %d \n", r.pixelIndex); Ray newRay = intr.SpawnRay(r.ray.d); - nextRayQueue->PushIndirectRay(newRay, r.depth, r.prevIntrCtx, r.beta, r.inv_w_u, - r.inv_w_l, r.lambda, r.etaScale, r.specularBounce, + nextRayQueue->PushIndirectRay(newRay, r.depth, r.prevIntrCtx, r.beta, r.r_u, + r.r_l, r.lambda, r.etaScale, r.specularBounce, r.anyNonSpecularBounces, r.pixelIndex); return; } @@ -113,7 +112,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection( // TODO: intr.wo == -ray.d? hitAreaLightQueue->Push(HitAreaLightWorkItem{ intr.areaLight, intr.p(), intr.n, intr.uv, intr.wo, r.lambda, r.depth, r.beta, - r.inv_w_u, r.inv_w_l, r.prevIntrCtx, (int)r.specularBounce, r.pixelIndex}); + r.r_u, r.r_l, r.prevIntrCtx, (int)r.specularBounce, r.pixelIndex}); } FloatTexture displacement = material.GetDisplacement(); @@ -147,7 +146,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection( r.anyNonSpecularBounces, intr.wo, r.beta, - r.inv_w_u, + r.r_u, r.etaScale, mediumInterface}); }; @@ -176,7 +175,7 @@ inline PBRT_CPU_GPU void TraceTransmittance(ShadowRayWorkItem sr, RNG rng(Hash(ray.o), Hash(ray.d)); SampledSpectrum T_ray(1.f); - SampledSpectrum inv_w_u(1.f), inv_w_l(1.f); + SampledSpectrum r_u(1.f), r_l(1.f); while (ray.d != Vector3f(0, 0, 0)) { PBRT_DBG( @@ -208,11 +207,11 @@ inline PBRT_CPU_GPU void TraceTransmittance(ShadowRayWorkItem sr, // ratio-tracking: only evaluate null scattering Float pr = T_maj[0] * sigma_maj[0]; T_ray *= T_maj * sigma_n / pr; - inv_w_l *= T_maj * sigma_maj / pr; - inv_w_u *= T_maj * sigma_n / pr; + r_l *= T_maj * sigma_maj / pr; + r_u *= T_maj * sigma_n / pr; // Possibly terminate transmittance computation using Russian roulette - SampledSpectrum Tr = T_ray / (inv_w_l + inv_w_u).Average(); + SampledSpectrum Tr = T_ray / (r_l + r_u).Average(); if (Tr.MaxComponentValue() < 0.05f) { Float q = 0.75f; if (rng.Uniform() < q) @@ -227,10 +226,9 @@ inline PBRT_CPU_GPU void TraceTransmittance(ShadowRayWorkItem sr, sigma_n[2], sigma_n[3], sigma_maj[0], sigma_maj[1], sigma_maj[2], sigma_maj[3]); PBRT_DBG( - "T_ray %f %f %f %f inv_w_l %f %f %f %f inv_w_u %f %f %f %f\n", - T_ray[0], T_ray[1], T_ray[2], T_ray[3], inv_w_l[0], inv_w_l[1], - inv_w_l[2], inv_w_l[3], inv_w_u[0], inv_w_u[1], inv_w_u[2], - inv_w_u[3]); + "T_ray %f %f %f %f r_l %f %f %f %f r_u %f %f %f %f\n", + T_ray[0], T_ray[1], T_ray[2], T_ray[3], r_l[0], r_l[1], + r_l[2], r_l[3], r_u[0], r_u[1], r_u[2], r_u[3]); if (!T_ray) return false; @@ -238,8 +236,8 @@ inline PBRT_CPU_GPU void TraceTransmittance(ShadowRayWorkItem sr, return true; }); T_ray *= T_maj / T_maj[0]; - inv_w_l *= T_maj / T_maj[0]; - inv_w_u *= T_maj / T_maj[0]; + r_l *= T_maj / T_maj[0]; + r_u *= T_maj / T_maj[0]; } if (!result.hit || !T_ray) @@ -249,24 +247,23 @@ inline PBRT_CPU_GPU void TraceTransmittance(ShadowRayWorkItem sr, ray = spawnTo(pLight); } - PBRT_DBG("Final T_ray %.9g %.9g %.9g %.9g sr.inv_w_u %.9g %.9g %.9g %.9g inv_w_u " - "%.9g %.9g %.9g %.9g\n", - T_ray[0], T_ray[1], T_ray[2], T_ray[3], sr.inv_w_u[0], sr.inv_w_u[1], - sr.inv_w_u[2], sr.inv_w_u[3], inv_w_u[0], inv_w_u[1], inv_w_u[2], - inv_w_u[3]); - PBRT_DBG("sr.inv_w_l %.9g %.9g %.9g %.9g inv_w_l %.9g %.9g %.9g %.9g\n", - sr.inv_w_l[0], sr.inv_w_l[1], sr.inv_w_l[2], sr.inv_w_l[3], inv_w_l[0], - inv_w_l[1], inv_w_l[2], inv_w_l[3]); + PBRT_DBG("Final T_ray %.9g %.9g %.9g %.9g sr.r_u %.9g %.9g %.9g %.9g " + "r_u %.9g %.9g %.9g %.9g\n", + T_ray[0], T_ray[1], T_ray[2], T_ray[3], sr.r_u[0], sr.r_u[1], + sr.r_u[2], sr.r_u[3], r_u[0], r_u[1], r_u[2], r_u[3]); + PBRT_DBG("sr.r_l %.9g %.9g %.9g %.9g r_l %.9g %.9g %.9g %.9g\n", + sr.r_l[0], sr.r_l[1], sr.r_l[2], sr.r_l[3], r_l[0], + r_l[1], r_l[2], r_l[3]); PBRT_DBG("scaled throughput %.9g %.9g %.9g %.9g\n", - T_ray[0] / (sr.inv_w_u * inv_w_u + sr.inv_w_l * inv_w_l).Average(), - T_ray[1] / (sr.inv_w_u * inv_w_u + sr.inv_w_l * inv_w_l).Average(), - T_ray[2] / (sr.inv_w_u * inv_w_u + sr.inv_w_l * inv_w_l).Average(), - T_ray[3] / (sr.inv_w_u * inv_w_u + sr.inv_w_l * inv_w_l).Average()); + T_ray[0] / (sr.r_u * r_u + sr.r_l * r_l).Average(), + T_ray[1] / (sr.r_u * r_u + sr.r_l * r_l).Average(), + T_ray[2] / (sr.r_u * r_u + sr.r_l * r_l).Average(), + T_ray[3] / (sr.r_u * r_u + sr.r_l * r_l).Average()); if (T_ray) { - // FIXME/reconcile: this takes inv_w_l as input while + // FIXME/reconcile: this takes r_l as input while // e.g. VolPathIntegrator::SampleLd() does not... - Ld *= T_ray / (sr.inv_w_u * inv_w_u + sr.inv_w_l * inv_w_l).Average(); + Ld *= T_ray / (sr.r_u * r_u + sr.r_l * r_l).Average(); PBRT_DBG("Setting final Ld for shadow ray pixel index %d = as %f %f %f %f\n", sr.pixelIndex, Ld[0], Ld[1], Ld[2], Ld[3]); diff --git a/src/pbrt/wavefront/media.cpp b/src/pbrt/wavefront/media.cpp index 9c440a753..ffcc0405c 100644 --- a/src/pbrt/wavefront/media.cpp +++ b/src/pbrt/wavefront/media.cpp @@ -38,17 +38,17 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { SampledWavelengths lambda = w.lambda; SampledSpectrum beta = w.beta; - SampledSpectrum inv_w_u = w.inv_w_u; - SampledSpectrum inv_w_l = w.inv_w_l; + SampledSpectrum r_u = w.r_u; + SampledSpectrum r_l = w.r_l; SampledSpectrum L(0.f); RNG rng(Hash(ray.o, tMax), Hash(ray.d)); PBRT_DBG("Lambdas %f %f %f %f\n", lambda[0], lambda[1], lambda[2], lambda[3]); - PBRT_DBG("Medium sample beta %f %f %f %f inv_w_u %f %f %f %f inv_w_l %f %f " + PBRT_DBG("Medium sample beta %f %f %f %f r_u %f %f %f %f r_l %f %f " "%f %f\n", - beta[0], beta[1], beta[2], beta[3], inv_w_u[0], inv_w_u[1], - inv_w_u[2], inv_w_u[3], inv_w_l[0], inv_w_l[1], inv_w_l[2], - inv_w_l[3]); + beta[0], beta[1], beta[2], beta[3], r_u[0], r_u[1], + r_u[2], r_u[3], r_l[0], r_l[1], r_l[2], + r_l[3]); // Sample the medium according to T_maj, the homogeneous // transmission function based on the majorant. @@ -74,12 +74,12 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { // (without scaling) at absorption events. if (w.depth < maxDepth && mp.Le) { Float pr = sigma_maj[0] * T_maj[0]; - SampledSpectrum inv_w_e = inv_w_u * sigma_maj * T_maj / pr; + SampledSpectrum r_e = r_u * sigma_maj * T_maj / pr; // Update _L_ for medium emission - if (inv_w_e) + if (r_e) L += beta * mp.sigma_a * T_maj * mp.Le / - (pr * inv_w_e.Average()); + (pr * r_e.Average()); } // Compute probabilities for each type of scattering. @@ -103,18 +103,18 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { PBRT_DBG("scattered\n"); Float pr = T_maj[0] * mp.sigma_s[0]; beta *= T_maj * mp.sigma_s / pr; - inv_w_u *= T_maj * mp.sigma_s / pr; + r_u *= T_maj * mp.sigma_s / pr; // Enqueue medium scattering work. auto enqueue = [=](auto ptr) { using PhaseFunction = typename std::remove_const_t< std::remove_reference_t>; mediumScatterQueue->Push(MediumScatterWorkItem{ - p, w.depth, lambda, beta, inv_w_u, ptr, -ray.d, ray.time, + p, w.depth, lambda, beta, r_u, ptr, -ray.d, ray.time, w.etaScale, ray.medium, w.pixelIndex}); }; DCHECK_RARE(1e-6f, !beta); - if (beta && inv_w_u) + if (beta && r_u) mp.phase.Dispatch(enqueue); scattered = true; @@ -130,25 +130,25 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { beta *= T_maj * sigma_n / pr; if (pr == 0) beta = SampledSpectrum(0.f); - inv_w_u *= T_maj * sigma_n / pr; - inv_w_l *= T_maj * sigma_maj / pr; + r_u *= T_maj * sigma_n / pr; + r_l *= T_maj * sigma_maj / pr; uMode = rng.Uniform(); - return beta && inv_w_u; + return beta && r_u; } }); if (!scattered && beta) { beta *= T_maj / T_maj[0]; - inv_w_u *= T_maj / T_maj[0]; - inv_w_l *= T_maj / T_maj[0]; + r_u *= T_maj / T_maj[0]; + r_l *= T_maj / T_maj[0]; } PBRT_DBG("Post ray medium sample L %f %f %f %f beta %f %f %f %f\n", L[0], L[1], L[2], L[3], beta[0], beta[1], beta[2], beta[3]); - PBRT_DBG("Post ray medium sample inv_w_u %f %f %f %f inv_w_l %f %f %f %f\n", - inv_w_u[0], inv_w_u[1], inv_w_u[2], inv_w_u[3], inv_w_l[0], - inv_w_l[1], inv_w_l[2], inv_w_l[3]); + PBRT_DBG("Post ray medium sample r_u %f %f %f %f r_l %f %f %f %f\n", + r_u[0], r_u[1], r_u[2], r_u[3], r_l[0], + r_l[1], r_l[2], r_l[3]); // Add any emission found to its pixel sample's L value. if (L) { @@ -160,7 +160,7 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { // There's no more work to do if there was a scattering event in // the medium. - if (scattered || !beta || !inv_w_u || w.depth == maxDepth) + if (scattered || !beta || !r_u || w.depth == maxDepth) return; // Otherwise, enqueue bump and medium stuff... @@ -172,7 +172,7 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { w.pixelIndex, w.depth); escapedRayQueue->Push(EscapedRayWorkItem{ ray.o, ray.d, w.depth, lambda, w.pixelIndex, beta, - (int)w.specularBounce, inv_w_u, inv_w_l, w.prevIntrCtx}); + (int)w.specularBounce, r_u, r_l, w.prevIntrCtx}); } return; } @@ -194,7 +194,7 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { intr.mediumInterface = &w.mediumInterface; Ray newRay = intr.SpawnRay(ray.d); nextRayQueue->PushIndirectRay( - newRay, w.depth, w.prevIntrCtx, beta, inv_w_u, inv_w_l, lambda, + newRay, w.depth, w.prevIntrCtx, beta, r_u, r_l, lambda, w.etaScale, w.specularBounce, w.anyNonSpecularBounces, w.pixelIndex); return; } @@ -206,7 +206,7 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { w.pixelIndex, w.depth); hitAreaLightQueue->Push(HitAreaLightWorkItem{ w.areaLight, Point3f(w.pi), w.n, w.uv, -ray.d, lambda, w.depth, beta, - inv_w_u, inv_w_l, w.prevIntrCtx, w.specularBounce, w.pixelIndex}); + r_u, r_l, w.prevIntrCtx, w.specularBounce, w.pixelIndex}); } FloatTexture displacement = material.GetDisplacement(); @@ -242,7 +242,7 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) { w.anyNonSpecularBounces, -ray.d, beta, - inv_w_u, + r_u, w.etaScale, w.mediumInterface}); }; @@ -293,23 +293,23 @@ void WavefrontPathIntegrator::SampleMediumScattering(int wavefrontDepth) { Float lightPDF = ls->pdf * sampledLight->p; Float phasePDF = IsDeltaLight(light.Type()) ? 0.f : w.phase->PDF(wo, wi); - SampledSpectrum inv_w_u = w.inv_w_u * phasePDF; - SampledSpectrum inv_w_l = w.inv_w_u * lightPDF; + SampledSpectrum r_u = w.r_u * phasePDF; + SampledSpectrum r_l = w.r_u * lightPDF; SampledSpectrum Ld = beta * ls->L; Ray ray(w.p, ls->pLight.p() - w.p, w.time, w.medium); // Enqueue shadow ray shadowRayQueue->Push(ShadowRayWorkItem{ray, 1 - ShadowEpsilon, - w.lambda, Ld, inv_w_u, inv_w_l, + w.lambda, Ld, r_u, r_l, w.pixelIndex}); PBRT_DBG("Enqueued medium shadow ray depth %d " - "Ld %f %f %f %f inv_w_u %f %f %f %f " - "inv_w_l %f %f %f %f pixel index %d\n", - w.depth, Ld[0], Ld[1], Ld[2], Ld[3], inv_w_u[0], inv_w_u[1], - inv_w_u[2], inv_w_u[3], inv_w_l[0], inv_w_l[1], inv_w_l[2], - inv_w_l[3], w.pixelIndex); + "Ld %f %f %f %f r_u %f %f %f %f " + "r_l %f %f %f %f pixel index %d\n", + w.depth, Ld[0], Ld[1], Ld[2], Ld[3], r_u[0], r_u[1], + r_u[2], r_u[3], r_l[0], r_l[1], r_l[2], + r_l[3], w.pixelIndex); } } @@ -320,14 +320,14 @@ void WavefrontPathIntegrator::SampleMediumScattering(int wavefrontDepth) { return; SampledSpectrum beta = w.beta * phaseSample->p / phaseSample->pdf; - SampledSpectrum inv_w_u = w.inv_w_u; - SampledSpectrum inv_w_l = w.inv_w_u / phaseSample->pdf; + SampledSpectrum r_u = w.r_u; + SampledSpectrum r_l = w.r_u / phaseSample->pdf; // Russian roulette // TODO: should we even bother? Generally beta is one here, // due to the way scattering events are scattered and because we're // sampling exactly from the phase function's distribution... - SampledSpectrum rrBeta = beta * w.etaScale / inv_w_u.Average(); + SampledSpectrum rrBeta = beta * w.etaScale / r_u.Average(); if (rrBeta.MaxComponentValue() < 1 && w.depth >= 1) { Float q = std::max(0, 1 - rrBeta.MaxComponentValue()); if (raySamples.indirect.rr < q) { @@ -343,7 +343,7 @@ void WavefrontPathIntegrator::SampleMediumScattering(int wavefrontDepth) { bool anyNonSpecularBounces = true; // Spawn indirect ray. - nextRayQueue->PushIndirectRay(ray, w.depth + 1, ctx, beta, inv_w_u, inv_w_l, + nextRayQueue->PushIndirectRay(ray, w.depth + 1, ctx, beta, r_u, r_l, w.lambda, w.etaScale, specularBounce, anyNonSpecularBounces, w.pixelIndex); PBRT_DBG("Enqueuing indirect medium ray at depth %d pixel index %d\n", diff --git a/src/pbrt/wavefront/subsurface.cpp b/src/pbrt/wavefront/subsurface.cpp index b4678ce31..0d9ae9d41 100644 --- a/src/pbrt/wavefront/subsurface.cpp +++ b/src/pbrt/wavefront/subsurface.cpp @@ -37,7 +37,7 @@ void WavefrontPathIntegrator::SampleSubsurface(int wavefrontDepth) { pstd::optional probeSeg = bssrdf.SampleSp(uc, u); if (probeSeg) subsurfaceScatterQueue->Push(probeSeg->p0, probeSeg->p1, w.depth, - material, bssrdf, lambda, w.beta, w.inv_w_u, + material, bssrdf, lambda, w.beta, w.r_u, w.mediumInterface, w.etaScale, w.pixelIndex); }); @@ -62,7 +62,7 @@ void WavefrontPathIntegrator::SampleSubsurface(int wavefrontDepth) { Float pr = w.reservoirPDF * bssrdfSample.pdf[0]; SampledSpectrum betap = w.beta * bssrdfSample.Sp / pr; - SampledSpectrum inv_w_u = w.inv_w_u * bssrdfSample.pdf / bssrdfSample.pdf[0]; + SampledSpectrum r_u = w.r_u * bssrdfSample.pdf / bssrdfSample.pdf[0]; SampledWavelengths lambda = w.lambda; RaySamples raySamples = pixelSampleState.samples[w.pixelIndex]; Vector3f wo = bssrdfSample.wo; @@ -83,25 +83,25 @@ void WavefrontPathIntegrator::SampleSubsurface(int wavefrontDepth) { Vector3f wi = bsdfSample->wi; SampledSpectrum beta = betap * bsdfSample->f * AbsDot(wi, intr.ns) / bsdfSample->pdf; - SampledSpectrum indir_inv_w_u = inv_w_u; + SampledSpectrum indir_r_u = r_u; PBRT_DBG("%s f*cos[0] %f bsdfSample->pdf %f f*cos/pdf %f\n", ConcreteBxDF::Name(), bsdfSample->f[0] * AbsDot(wi, intr.ns), bsdfSample->pdf, bsdfSample->f[0] * AbsDot(wi, intr.ns) / bsdfSample->pdf); - SampledSpectrum inv_w_l; + SampledSpectrum r_l; if (bsdfSample->pdfIsProportional) - inv_w_l = inv_w_u / bsdf.PDF(wo, bsdfSample->wi); + r_l = r_u / bsdf.PDF(wo, bsdfSample->wi); else - inv_w_l = inv_w_u / bsdfSample->pdf; + r_l = r_u / bsdfSample->pdf; Float etaScale = w.etaScale; if (bsdfSample->IsTransmission()) etaScale *= Sqr(bsdfSample->eta); // Russian roulette - SampledSpectrum rrBeta = beta * etaScale / indir_inv_w_u.Average(); + SampledSpectrum rrBeta = beta * etaScale / indir_r_u.Average(); if (rrBeta.MaxComponentValue() < 1 && w.depth > 1) { Float q = std::max(0, 1 - rrBeta.MaxComponentValue()); if (raySamples.indirect.rr < q) { @@ -125,23 +125,23 @@ void WavefrontPathIntegrator::SampleSubsurface(int wavefrontDepth) { LightSampleContext ctx(intr.pi, intr.n, intr.ns); nextRayQueue->PushIndirectRay( - ray, w.depth + 1, ctx, beta, indir_inv_w_u, inv_w_l, lambda, + ray, w.depth + 1, ctx, beta, indir_r_u, r_l, lambda, etaScale, bsdfSample->IsSpecular(), anyNonSpecularBounces, w.pixelIndex); PBRT_DBG("Spawned indirect ray at depth %d. " - "Specular %d beta %f %f %f %f indir_inv_w_u %f %f %f %f " - "inv_w_l %f " + "Specular %d beta %f %f %f %f indir_r_u %f %f %f %f " + "r_l %f " "%f %f %f " - "beta/indir_inv_w_u %f %f %f %f\n", + "beta/indir_r_u %f %f %f %f\n", w.depth + 1, int(bsdfSample->IsSpecular()), beta[0], - beta[1], beta[2], beta[3], indir_inv_w_u[0], - indir_inv_w_u[1], indir_inv_w_u[2], indir_inv_w_u[3], - inv_w_l[0], inv_w_l[1], inv_w_l[2], inv_w_l[3], - SafeDiv(beta, indir_inv_w_u)[0], - SafeDiv(beta, indir_inv_w_u)[1], - SafeDiv(beta, indir_inv_w_u)[2], - SafeDiv(beta, indir_inv_w_u)[3]); + beta[1], beta[2], beta[3], indir_r_u[0], + indir_r_u[1], indir_r_u[2], indir_r_u[3], + r_l[0], r_l[1], r_l[2], r_l[3], + SafeDiv(beta, indir_r_u)[0], + SafeDiv(beta, indir_r_u)[1], + SafeDiv(beta, indir_r_u)[2], + SafeDiv(beta, indir_r_u)[3]); } } } @@ -174,22 +174,22 @@ void WavefrontPathIntegrator::SampleSubsurface(int wavefrontDepth) { ls->L[0], ls->L[1], ls->L[2], ls->L[3], ls->pdf); Float lightPDF = ls->pdf * sampledLight->p; - // This causes inv_w_u to be zero for the shadow ray, so that + // This causes r_u to be zero for the shadow ray, so that // part of MIS just becomes a no-op. Float bsdfPDF = IsDeltaLight(light.Type()) ? 0.f : bsdf.PDF(wo, wi); - SampledSpectrum inv_w_l = inv_w_u * lightPDF; - inv_w_u *= bsdfPDF; + SampledSpectrum r_l = r_u * lightPDF; + r_u *= bsdfPDF; SampledSpectrum Ld = beta * ls->L; PBRT_DBG("depth %d Ld %f %f %f %f " "new beta %f %f %f %f beta/uni %f %f %f %f Ld/uni %f %f %f %f\n", w.depth, Ld[0], Ld[1], Ld[2], Ld[3], beta[0], beta[1], beta[2], - beta[3], SafeDiv(beta, inv_w_u)[0], SafeDiv(beta, inv_w_u)[1], - SafeDiv(beta, inv_w_u)[2], SafeDiv(beta, inv_w_u)[3], - SafeDiv(Ld, inv_w_u)[0], SafeDiv(Ld, inv_w_u)[1], - SafeDiv(Ld, inv_w_u)[2], SafeDiv(Ld, inv_w_u)[3]); + beta[3], SafeDiv(beta, r_u)[0], SafeDiv(beta, r_u)[1], + SafeDiv(beta, r_u)[2], SafeDiv(beta, r_u)[3], + SafeDiv(Ld, r_u)[0], SafeDiv(Ld, r_u)[1], + SafeDiv(Ld, r_u)[2], SafeDiv(Ld, r_u)[3]); Ray ray = SpawnRayTo(intr.pi, intr.n, time, ls->pLight.pi, ls->pLight.n); if (haveMedia) @@ -198,7 +198,7 @@ void WavefrontPathIntegrator::SampleSubsurface(int wavefrontDepth) { : w.mediumInterface.inside; shadowRayQueue->Push(ShadowRayWorkItem{ray, 1 - ShadowEpsilon, lambda, Ld, - inv_w_u, inv_w_l, w.pixelIndex}); + r_u, r_l, w.pixelIndex}); } }); diff --git a/src/pbrt/wavefront/surfscatter.cpp b/src/pbrt/wavefront/surfscatter.cpp index b0b5d04fa..801d48619 100644 --- a/src/pbrt/wavefront/surfscatter.cpp +++ b/src/pbrt/wavefront/surfscatter.cpp @@ -189,18 +189,18 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue Vector3f wi = bsdfSample->wi; SampledSpectrum beta = w.beta * bsdfSample->f * AbsDot(wi, ns) / bsdfSample->pdf; - SampledSpectrum inv_w_u = w.inv_w_u, inv_w_l; + SampledSpectrum r_u = w.r_u, r_l; PBRT_DBG("%s f*cos[0] %f bsdfSample->pdf %f f*cos/pdf %f\n", ConcreteBxDF::Name(), bsdfSample->f[0] * AbsDot(wi, ns), bsdfSample->pdf, bsdfSample->f[0] * AbsDot(wi, ns) / bsdfSample->pdf); - // Update _inv_w_u_ based on BSDF sample PDF + // Update _r_u_ based on BSDF sample PDF if (bsdfSample->pdfIsProportional) - inv_w_l = inv_w_u / bsdf.PDF(wo, bsdfSample->wi); + r_l = r_u / bsdf.PDF(wo, bsdfSample->wi); else - inv_w_l = inv_w_u / bsdfSample->pdf; + r_l = r_u / bsdfSample->pdf; // Update _etaScale_ accounting for BSDF scattering Float etaScale = w.etaScale; @@ -209,7 +209,7 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue // Apply Russian roulette to indirect ray based on weighted path // throughput - SampledSpectrum rrBeta = beta * etaScale / inv_w_u.Average(); + SampledSpectrum rrBeta = beta * etaScale / r_u.Average(); // Note: depth >= 1 here to match VolPathIntegrator (which increments // depth earlier). if (rrBeta.MaxComponentValue() < 1 && w.depth >= 1) { @@ -225,7 +225,7 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue // Initialize spawned ray and enqueue for next ray depth if (bsdfSample->IsTransmission() && w.material->HasSubsurfaceScattering()) { - bssrdfEvalQueue->Push(w.material, lambda, beta, inv_w_u, + bssrdfEvalQueue->Push(w.material, lambda, beta, r_u, Point3f(w.pi), wo, w.n, ns, dpdus, w.uv, w.depth, w.mediumInterface, etaScale, w.pixelIndex); @@ -241,20 +241,20 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue // NOTE: slightly different than context below. Problem? LightSampleContext ctx(w.pi, w.n, ns); nextRayQueue->PushIndirectRay( - ray, w.depth + 1, ctx, beta, inv_w_u, inv_w_l, lambda, + ray, w.depth + 1, ctx, beta, r_u, r_l, lambda, etaScale, bsdfSample->IsSpecular(), anyNonSpecularBounces, w.pixelIndex); PBRT_DBG( "Spawned indirect ray at depth %d from w.index %d. " - "Specular %d beta %f %f %f %f inv_w_u %f %f %f %f inv_w_l %f " - "%f %f %f beta/inv_w_u %f %f %f %f\n", + "Specular %d beta %f %f %f %f r_u %f %f %f %f r_l %f " + "%f %f %f beta/r_u %f %f %f %f\n", w.depth + 1, w.pixelIndex, int(bsdfSample->IsSpecular()), - beta[0], beta[1], beta[2], beta[3], inv_w_u[0], inv_w_u[1], - inv_w_u[2], inv_w_u[3], inv_w_l[0], inv_w_l[1], inv_w_l[2], - inv_w_l[3], SafeDiv(beta, inv_w_u)[0], - SafeDiv(beta, inv_w_u)[1], SafeDiv(beta, inv_w_u)[2], - SafeDiv(beta, inv_w_u)[3]); + beta[0], beta[1], beta[2], beta[3], r_u[0], r_u[1], + r_u[2], r_u[3], r_l[0], r_l[1], r_l[2], + r_l[3], SafeDiv(beta, r_u)[0], + SafeDiv(beta, r_u)[1], SafeDiv(beta, r_u)[2], + SafeDiv(beta, r_u)[3]); } } } @@ -297,12 +297,12 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue f[2], f[3], ls->L[0], ls->L[1], ls->L[2], ls->L[3], ls->pdf); Float lightPDF = ls->pdf * sampledLight->p; - // This causes inv_w_u to be zero for the shadow ray, so that + // This causes r_u to be zero for the shadow ray, so that // part of MIS just becomes a no-op. Float bsdfPDF = IsDeltaLight(light.Type()) ? 0.f : bsdf.PDF(wo, wi); - SampledSpectrum inv_w_u = w.inv_w_u * bsdfPDF; - SampledSpectrum inv_w_l = w.inv_w_u * lightPDF; + SampledSpectrum r_u = w.r_u * bsdfPDF; + SampledSpectrum r_l = w.r_u * lightPDF; // Enqueue shadow ray with tentative radiance contribution SampledSpectrum Ld = beta * ls->L; @@ -313,16 +313,16 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue : w.mediumInterface.inside; shadowRayQueue->Push(ShadowRayWorkItem{ray, 1 - ShadowEpsilon, lambda, Ld, - inv_w_u, inv_w_l, w.pixelIndex}); + r_u, r_l, w.pixelIndex}); PBRT_DBG("w.index %d spawned shadow ray depth %d Ld %f %f %f %f " "new beta %f %f %f %f beta/uni %f %f %f %f Ld/uni %f %f %f %f\n", w.pixelIndex, w.depth, Ld[0], Ld[1], Ld[2], Ld[3], beta[0], - beta[1], beta[2], beta[3], SafeDiv(beta, inv_w_u)[0], - SafeDiv(beta, inv_w_u)[1], SafeDiv(beta, inv_w_u)[2], - SafeDiv(beta, inv_w_u)[3], SafeDiv(Ld, inv_w_u)[0], - SafeDiv(Ld, inv_w_u)[1], SafeDiv(Ld, inv_w_u)[2], - SafeDiv(Ld, inv_w_u)[3]); + beta[1], beta[2], beta[3], SafeDiv(beta, r_u)[0], + SafeDiv(beta, r_u)[1], SafeDiv(beta, r_u)[2], + SafeDiv(beta, r_u)[3], SafeDiv(Ld, r_u)[0], + SafeDiv(Ld, r_u)[1], SafeDiv(Ld, r_u)[2], + SafeDiv(Ld, r_u)[3]); } }); } diff --git a/src/pbrt/wavefront/workitems.h b/src/pbrt/wavefront/workitems.h index b568a27fb..a4befe04e 100644 --- a/src/pbrt/wavefront/workitems.h +++ b/src/pbrt/wavefront/workitems.h @@ -122,7 +122,7 @@ struct RayWorkItem { int depth; SampledWavelengths lambda; int pixelIndex; - SampledSpectrum beta, inv_w_u, inv_w_l; + SampledSpectrum beta, r_u, r_l; LightSampleContext prevIntrCtx; Float etaScale; int specularBounce; @@ -139,7 +139,7 @@ struct EscapedRayWorkItem { int pixelIndex; SampledSpectrum beta; int specularBounce; - SampledSpectrum inv_w_u, inv_w_l; + SampledSpectrum r_u, r_l; LightSampleContext prevIntrCtx; }; @@ -153,7 +153,7 @@ struct HitAreaLightWorkItem { Vector3f wo; SampledWavelengths lambda; int depth; - SampledSpectrum beta, inv_w_u, inv_w_l; + SampledSpectrum beta, r_u, r_l; LightSampleContext prevIntrCtx; int specularBounce; int pixelIndex; @@ -167,7 +167,7 @@ struct ShadowRayWorkItem { Ray ray; Float tMax; SampledWavelengths lambda; - SampledSpectrum Ld, inv_w_u, inv_w_l; + SampledSpectrum Ld, r_u, r_l; int pixelIndex; }; @@ -187,7 +187,7 @@ struct GetBSSRDFAndProbeRayWorkItem { Material material; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; Point3f p; Vector3f wo; Normal3f n, ns; @@ -206,7 +206,7 @@ struct SubsurfaceScatterWorkItem { Material material; TabulatedBSSRDF bssrdf; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; Float reservoirPDF; Float uLight; SubsurfaceInteraction ssi; @@ -223,8 +223,8 @@ struct MediumSampleWorkItem { Float tMax; SampledWavelengths lambda; SampledSpectrum beta; - SampledSpectrum inv_w_u; - SampledSpectrum inv_w_l; + SampledSpectrum r_u; + SampledSpectrum r_l; int pixelIndex; LightSampleContext prevIntrCtx; int specularBounce; @@ -252,7 +252,7 @@ struct MediumScatterWorkItem { Point3f p; int depth; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; const PhaseFunction *phase; Vector3f wo; Float time; @@ -319,7 +319,7 @@ struct MaterialEvalWorkItem { int pixelIndex; int anyNonSpecularBounces; Vector3f wo; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; Float etaScale; MediumInterface mediumInterface; }; @@ -336,8 +336,8 @@ class RayQueue : public WorkQueue { PBRT_CPU_GPU int PushIndirectRay(const Ray &ray, int depth, const LightSampleContext &prevIntrCtx, - const SampledSpectrum &beta, const SampledSpectrum &inv_w_u, - const SampledSpectrum &inv_w_l, const SampledWavelengths &lambda, + const SampledSpectrum &beta, const SampledSpectrum &r_u, + const SampledSpectrum &r_l, const SampledWavelengths &lambda, Float etaScale, bool specularBounce, bool anyNonSpecularBounces, int pixelIndex); }; @@ -354,8 +354,8 @@ inline int RayQueue::PushCameraRay(const Ray &ray, const SampledWavelengths &lam this->beta[index] = SampledSpectrum(1.f); this->etaScale[index] = 1.f; this->anyNonSpecularBounces[index] = false; - this->inv_w_u[index] = SampledSpectrum(1.f); - this->inv_w_l[index] = SampledSpectrum(1.f); + this->r_u[index] = SampledSpectrum(1.f); + this->r_l[index] = SampledSpectrum(1.f); this->specularBounce[index] = false; return index; } @@ -363,8 +363,8 @@ inline int RayQueue::PushCameraRay(const Ray &ray, const SampledWavelengths &lam PBRT_CPU_GPU inline int RayQueue::PushIndirectRay( const Ray &ray, int depth, const LightSampleContext &prevIntrCtx, - const SampledSpectrum &beta, const SampledSpectrum &inv_w_u, - const SampledSpectrum &inv_w_l, const SampledWavelengths &lambda, Float etaScale, + const SampledSpectrum &beta, const SampledSpectrum &r_u, + const SampledSpectrum &r_l, const SampledWavelengths &lambda, Float etaScale, bool specularBounce, bool anyNonSpecularBounces, int pixelIndex) { int index = AllocateEntry(); DCHECK(!ray.HasNaN()); @@ -373,8 +373,8 @@ inline int RayQueue::PushIndirectRay( this->pixelIndex[index] = pixelIndex; this->prevIntrCtx[index] = prevIntrCtx; this->beta[index] = beta; - this->inv_w_u[index] = inv_w_u; - this->inv_w_l[index] = inv_w_l; + this->r_u[index] = r_u; + this->r_l[index] = r_l; this->lambda[index] = lambda; this->anyNonSpecularBounces[index] = anyNonSpecularBounces; this->specularBounce[index] = specularBounce; @@ -399,7 +399,7 @@ class EscapedRayQueue : public WorkQueue { inline int EscapedRayQueue::Push(RayWorkItem r) { return Push(EscapedRayWorkItem{r.ray.o, r.ray.d, r.depth, r.lambda, r.pixelIndex, - r.beta, (int)r.specularBounce, r.inv_w_u, r.inv_w_l, + r.beta, (int)r.specularBounce, r.r_u, r.r_l, r.prevIntrCtx}); } @@ -410,14 +410,14 @@ class GetBSSRDFAndProbeRayQueue : public WorkQueue PBRT_CPU_GPU int Push(Material material, SampledWavelengths lambda, SampledSpectrum beta, - SampledSpectrum inv_w_u, Point3f p, Vector3f wo, Normal3f n, Normal3f ns, + SampledSpectrum r_u, Point3f p, Vector3f wo, Normal3f n, Normal3f ns, Vector3f dpdus, Point2f uv, int depth, MediumInterface mediumInterface, Float etaScale, int pixelIndex) { int index = AllocateEntry(); this->material[index] = material; this->lambda[index] = lambda; this->beta[index] = beta; - this->inv_w_u[index] = inv_w_u; + this->r_u[index] = r_u; this->p[index] = p; this->wo[index] = wo; this->n[index] = n; @@ -439,7 +439,7 @@ class SubsurfaceScatterQueue : public WorkQueue { PBRT_CPU_GPU int Push(Point3f p0, Point3f p1, int depth, Material material, TabulatedBSSRDF bssrdf, - SampledWavelengths lambda, SampledSpectrum beta, SampledSpectrum inv_w_u, + SampledWavelengths lambda, SampledSpectrum beta, SampledSpectrum r_u, MediumInterface mediumInterface, Float etaScale, int pixelIndex) { int index = AllocateEntry(); this->p0[index] = p0; @@ -449,7 +449,7 @@ class SubsurfaceScatterQueue : public WorkQueue { this->bssrdf[index] = bssrdf; this->lambda[index] = lambda; this->beta[index] = beta; - this->inv_w_u[index] = inv_w_u; + this->r_u[index] = r_u; this->mediumInterface[index] = mediumInterface; this->etaScale[index] = etaScale; this->pixelIndex[index] = pixelIndex; @@ -466,7 +466,7 @@ class MediumSampleQueue : public WorkQueue { PBRT_CPU_GPU int Push(Ray ray, Float tMax, SampledWavelengths lambda, SampledSpectrum beta, - SampledSpectrum inv_w_u, SampledSpectrum inv_w_l, int pixelIndex, + SampledSpectrum r_u, SampledSpectrum r_l, int pixelIndex, LightSampleContext prevIntrCtx, int specularBounce, int anyNonSpecularBounces, Float etaScale) { int index = AllocateEntry(); @@ -474,8 +474,8 @@ class MediumSampleQueue : public WorkQueue { this->tMax[index] = tMax; this->lambda[index] = lambda; this->beta[index] = beta; - this->inv_w_u[index] = inv_w_u; - this->inv_w_l[index] = inv_w_l; + this->r_u[index] = r_u; + this->r_l[index] = r_l; this->pixelIndex[index] = pixelIndex; this->prevIntrCtx[index] = prevIntrCtx; this->specularBounce[index] = specularBounce; @@ -486,7 +486,7 @@ class MediumSampleQueue : public WorkQueue { PBRT_CPU_GPU int Push(RayWorkItem r, Float tMax) { - return Push(r.ray, tMax, r.lambda, r.beta, r.inv_w_u, r.inv_w_l, r.pixelIndex, + return Push(r.ray, tMax, r.lambda, r.beta, r.r_u, r.r_l, r.pixelIndex, r.prevIntrCtx, r.specularBounce, r.anyNonSpecularBounces, r.etaScale); } }; diff --git a/src/pbrt/wavefront/workitems.soa b/src/pbrt/wavefront/workitems.soa index fd1f0e849..d4be1a4ac 100644 --- a/src/pbrt/wavefront/workitems.soa +++ b/src/pbrt/wavefront/workitems.soa @@ -42,7 +42,7 @@ soa RayWorkItem { int depth; int pixelIndex; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u, inv_w_l; + SampledSpectrum beta, r_u, r_l; LightSampleContext prevIntrCtx; Float etaScale; int specularBounce; @@ -53,7 +53,7 @@ soa EscapedRayWorkItem { Point3f rayo; Vector3f rayd; int depth; - SampledSpectrum beta, inv_w_u, inv_w_l; + SampledSpectrum beta, r_u, r_l; SampledWavelengths lambda; LightSampleContext prevIntrCtx; int specularBounce; @@ -63,7 +63,7 @@ soa EscapedRayWorkItem { soa HitAreaLightWorkItem { Light areaLight; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u, inv_w_l; + SampledSpectrum beta, r_u, r_l; Point3f p; Normal3f n; Point2f uv; @@ -78,14 +78,14 @@ soa ShadowRayWorkItem { Ray ray; Float tMax; SampledWavelengths lambda; - SampledSpectrum Ld, inv_w_u, inv_w_l; + SampledSpectrum Ld, r_u, r_l; int pixelIndex; }; soa GetBSSRDFAndProbeRayWorkItem { Material material; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; Point3f p; Vector3f wo; Normal3f n, ns; @@ -104,7 +104,7 @@ soa SubsurfaceScatterWorkItem { Material material; TabulatedBSSRDF bssrdf; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; MediumInterface mediumInterface; Float etaScale; int pixelIndex; @@ -120,7 +120,7 @@ soa MediumSampleWorkItem { int depth; Float tMax; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u, inv_w_l; + SampledSpectrum beta, r_u, r_l; int pixelIndex; Light areaLight; Point3fi pi; @@ -144,7 +144,7 @@ soa MediumScatterWorkItem { Point3f p; int depth; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; const ConcretePhaseFunction *phase; Vector3f wo; Float time; @@ -156,7 +156,7 @@ soa MediumScatterWorkItem { soa MaterialEvalWorkItem { const ConcreteMaterial *material; SampledWavelengths lambda; - SampledSpectrum beta, inv_w_u; + SampledSpectrum beta, r_u; Point3fi pi; Normal3f n, ns; Vector3f dpdu, dpdv; From b251ba1b31da79c25d7f369788a7d818b6b816aa Mon Sep 17 00:00:00 2001 From: AwesomeKuma Date: Fri, 30 Dec 2022 22:09:59 +0800 Subject: [PATCH 094/149] Add a simple VisualStudio debugger visualizer(.natvis) for TaggedPointer --- CMakeLists.txt | 4 ++++ src/pbrt/visualstudio.natvis | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/pbrt/visualstudio.natvis diff --git a/CMakeLists.txt b/CMakeLists.txt index 68396cdcf..b717d8b9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -531,6 +531,10 @@ set (PBRT_SOURCE src/pbrt/cmd/pspec_gpu.cpp ) + +if (MSVC) + set (PBRT_SOURCE ${PBRT_SOURCE} src/pbrt/visualstudio.natvis) +endif () set (PBRT_SOURCE_HEADERS src/pbrt/bsdf.h diff --git a/src/pbrt/visualstudio.natvis b/src/pbrt/visualstudio.natvis new file mode 100644 index 000000000..5ffafb329 --- /dev/null +++ b/src/pbrt/visualstudio.natvis @@ -0,0 +1,40 @@ + + + + nullptr + {($T1*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T2*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T3*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T4*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T5*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T6*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T7*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T8*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T9*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T10*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T11*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T12*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T13*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T14*)(bits & 0x1FFFFFFFFFFFFFF)} + {($T15*)(bits & 0x1FFFFFFFFFFFFFF)} + unknown + + ((bits & 0xFE00000000000000) >> 57) + ($T1*)(bits & 0x1FFFFFFFFFFFFFF) + ($T2*)(bits & 0x1FFFFFFFFFFFFFF) + ($T3*)(bits & 0x1FFFFFFFFFFFFFF) + ($T4*)(bits & 0x1FFFFFFFFFFFFFF) + ($T5*)(bits & 0x1FFFFFFFFFFFFFF) + ($T6*)(bits & 0x1FFFFFFFFFFFFFF) + ($T7*)(bits & 0x1FFFFFFFFFFFFFF) + ($T8*)(bits & 0x1FFFFFFFFFFFFFF) + ($T9*)(bits & 0x1FFFFFFFFFFFFFF) + ($T10*)(bits & 0x1FFFFFFFFFFFFFF) + ($T11*)(bits & 0x1FFFFFFFFFFFFFF) + ($T12*)(bits & 0x1FFFFFFFFFFFFFF) + ($T13*)(bits & 0x1FFFFFFFFFFFFFF) + ($T14*)(bits & 0x1FFFFFFFFFFFFFF) + ($T15*)(bits & 0x1FFFFFFFFFFFFFF) + + + \ No newline at end of file From 6becd80d96c0056d9aca3416a70305e1bcd5683a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 3 Jan 2023 08:26:44 -0800 Subject: [PATCH 095/149] Update visualstudio.natvis --- src/pbrt/visualstudio.natvis | 164 ++++++++++++++++++++++++++++------- 1 file changed, 132 insertions(+), 32 deletions(-) diff --git a/src/pbrt/visualstudio.natvis b/src/pbrt/visualstudio.natvis index 5ffafb329..dd76f448a 100644 --- a/src/pbrt/visualstudio.natvis +++ b/src/pbrt/visualstudio.natvis @@ -1,40 +1,140 @@ - nullptr - {($T1*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T2*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T3*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T4*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T5*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T6*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T7*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T8*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T9*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T10*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T11*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T12*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T13*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T14*)(bits & 0x1FFFFFFFFFFFFFF)} - {($T15*)(bits & 0x1FFFFFFFFFFFFFF)} + + + nullptr + {($T1*)_ptr()} + {($T2*)_ptr()} + {($T3*)_ptr()} + {($T4*)_ptr()} + {($T5*)_ptr()} + {($T6*)_ptr()} + {($T7*)_ptr()} + {($T8*)_ptr()} + {($T9*)_ptr()} + {($T10*)_ptr()} + {($T11*)_ptr()} + {($T12*)_ptr()} + {($T13*)_ptr()} + {($T14*)_ptr()} + {($T15*)_ptr()} unknown ((bits & 0xFE00000000000000) >> 57) - ($T1*)(bits & 0x1FFFFFFFFFFFFFF) - ($T2*)(bits & 0x1FFFFFFFFFFFFFF) - ($T3*)(bits & 0x1FFFFFFFFFFFFFF) - ($T4*)(bits & 0x1FFFFFFFFFFFFFF) - ($T5*)(bits & 0x1FFFFFFFFFFFFFF) - ($T6*)(bits & 0x1FFFFFFFFFFFFFF) - ($T7*)(bits & 0x1FFFFFFFFFFFFFF) - ($T8*)(bits & 0x1FFFFFFFFFFFFFF) - ($T9*)(bits & 0x1FFFFFFFFFFFFFF) - ($T10*)(bits & 0x1FFFFFFFFFFFFFF) - ($T11*)(bits & 0x1FFFFFFFFFFFFFF) - ($T12*)(bits & 0x1FFFFFFFFFFFFFF) - ($T13*)(bits & 0x1FFFFFFFFFFFFFF) - ($T14*)(bits & 0x1FFFFFFFFFFFFFF) - ($T15*)(bits & 0x1FFFFFFFFFFFFFF) + ($T1*)_ptr() + ($T2*)_ptr() + ($T3*)_ptr() + ($T4*)_ptr() + ($T5*)_ptr() + ($T6*)_ptr() + ($T7*)_ptr() + ($T8*)_ptr() + ($T9*)_ptr() + ($T10*)_ptr() + ($T11*)_ptr() + ($T12*)_ptr() + ($T13*)_ptr() + ($T14*)_ptr() + ($T15*)_ptr() - \ No newline at end of file + + + {{ size={$T2} }} + + + $T2 + values + + + + + + null + {reinterpret_cast<$T1*>(&optionalValue)} + + reinterpret_cast<$T1*>(&optionalValue) + + + + + {{ size={n} }} + + + n + ptr + + + + + + {{ size={nStored} }} + + nAlloc + alloc + + nStored + ptr + + + + + + + + + + + + ({*this,view(noparens)}) + + + + + + {value}, {*((Base *) this),view(noparens)} + + {value} + ({*this,view(noparens)}) + + value + ((Base *) this)->value + ((Base::Base *) this)->value + ((Base::Base::Base *) this)->value + ((Base::Base::Base::Base *) this)->value + + Next five elements: + + *((Base::Base::Base::Base::Base *) this) + + + + + + {value}, {*((Base *) this),view(noparensasptr)} + + {&value} + ({*this,view(noparensasptr)}) + + &value + &((Base *) this)->value + &((Base::Base *) this)->value + &((Base::Base::Base *) this)->value + &((Base::Base::Base::Base *) this)->value + + Next five elements: + + *((Base::Base::Base::Base::Base *) this),view(asptr) + + + + From 20673d2d8ac6b90830c6a53d2ad694e73907233e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 3 Jan 2023 11:27:01 -0800 Subject: [PATCH 096/149] Update from 1st printing final book source No functional changes; just some variable renamings and changes in comments that correspond to fragment names that were edited. --- src/pbrt/bxdfs.cpp | 25 ++++++----- src/pbrt/bxdfs.h | 6 +-- src/pbrt/cameras.h | 1 + src/pbrt/cpu/aggregates.cpp | 4 +- src/pbrt/cpu/integrators.cpp | 80 +++++++++++++++++----------------- src/pbrt/cpu/integrators.h | 2 +- src/pbrt/lights.cpp | 8 ++-- src/pbrt/lightsamplers.h | 40 ++++++++--------- src/pbrt/samplers.h | 14 +++--- src/pbrt/shapes.cpp | 9 ++-- src/pbrt/shapes.h | 11 ++--- src/pbrt/textures.h | 2 +- src/pbrt/util/buffercache.h | 2 +- src/pbrt/util/lowdiscrepancy.h | 4 +- src/pbrt/util/math.cpp | 2 +- src/pbrt/util/math.h | 2 +- src/pbrt/util/sampling.cpp | 6 +-- src/pbrt/util/transform.h | 2 +- 18 files changed, 112 insertions(+), 108 deletions(-) diff --git a/src/pbrt/bxdfs.cpp b/src/pbrt/bxdfs.cpp index a8ff0b8fa..5f4dd46f5 100644 --- a/src/pbrt/bxdfs.cpp +++ b/src/pbrt/bxdfs.cpp @@ -312,7 +312,7 @@ SampledSpectrum HairBxDF::f(Vector3f wo, Vector3f wi, TransportMode mode) const Float cosTheta_i = SafeSqrt(1 - Sqr(sinTheta_i)); Float phi_i = std::atan2(wi.z, wi.y); - // Compute $\cos \thetat$ for refracted ray + // Compute $\cos\,\thetat$ for refracted ray Float sinTheta_t = sinTheta_o / eta; Float cosTheta_t = SafeSqrt(1 - Sqr(sinTheta_t)); @@ -329,8 +329,9 @@ SampledSpectrum HairBxDF::f(Vector3f wo, Vector3f wi, TransportMode mode) const Float phi = phi_i - phi_o; pstd::array ap = Ap(cosTheta_o, eta, h, T); SampledSpectrum fsum(0.); + for (int p = 0; p < pMax; ++p) { - // Compute $\sin \thetao$ and $\cos \thetao$ terms accounting for scales + // Compute $\sin\,\thetao$ and $\cos\,\thetao$ terms accounting for scales Float sinThetap_o, cosThetap_o; if (p == 0) { sinThetap_o = sinTheta_o * cos2kAlpha[1] - cosTheta_o * sin2kAlpha[1]; @@ -348,7 +349,7 @@ SampledSpectrum HairBxDF::f(Vector3f wo, Vector3f wi, TransportMode mode) const cosThetap_o = cosTheta_o; } - // Handle out-of-range $\cos \thetao$ from scale adjustment + // Handle out-of-range $\cos\,\thetao$ from scale adjustment cosThetap_o = std::abs(cosThetap_o); fsum += Mp(cosTheta_i, cosThetap_o, sinTheta_i, sinThetap_o, v[p]) * ap[p] * @@ -367,7 +368,7 @@ SampledSpectrum HairBxDF::f(Vector3f wo, Vector3f wi, TransportMode mode) const pstd::array HairBxDF::ApPDF(Float cosTheta_o) const { // Initialize array of $A_p$ values for _cosTheta_o_ Float sinTheta_o = SafeSqrt(1 - Sqr(cosTheta_o)); - // Compute $\cos \thetat$ for refracted ray + // Compute $\cos\,\thetat$ for refracted ray Float sinTheta_t = sinTheta_o / eta; Float cosTheta_t = SafeSqrt(1 - Sqr(sinTheta_t)); @@ -406,7 +407,7 @@ pstd::optional HairBxDF::Sample_f(Vector3f wo, Float uc, Point2f u, pstd::array apPDF = ApPDF(cosTheta_o); int p = SampleDiscrete(apPDF, uc, nullptr, &uc); - // Compute $\sin \thetao$ and $\cos \thetao$ terms accounting for scales + // Compute $\sin\,\thetao$ and $\cos\,\thetao$ terms accounting for scales Float sinThetap_o, cosThetap_o; if (p == 0) { sinThetap_o = sinTheta_o * cos2kAlpha[1] - cosTheta_o * sin2kAlpha[1]; @@ -424,7 +425,7 @@ pstd::optional HairBxDF::Sample_f(Vector3f wo, Float uc, Point2f u, cosThetap_o = cosTheta_o; } - // Handle out-of-range $\cos \thetao$ from scale adjustment + // Handle out-of-range $\cos\,\thetao$ from scale adjustment cosThetap_o = std::abs(cosThetap_o); // Sample $M_p$ to compute $\thetai$ @@ -455,7 +456,7 @@ pstd::optional HairBxDF::Sample_f(Vector3f wo, Float uc, Point2f u, // Compute PDF for sampled hair scattering direction _wi_ Float pdf = 0; for (int p = 0; p < pMax; ++p) { - // Compute $\sin \thetao$ and $\cos \thetao$ terms accounting for scales + // Compute $\sin\,\thetao$ and $\cos\,\thetao$ terms accounting for scales Float sinThetap_o, cosThetap_o; if (p == 0) { sinThetap_o = sinTheta_o * cos2kAlpha[1] - cosTheta_o * sin2kAlpha[1]; @@ -473,10 +474,10 @@ pstd::optional HairBxDF::Sample_f(Vector3f wo, Float uc, Point2f u, cosThetap_o = cosTheta_o; } - // Handle out-of-range $\cos \thetao$ from scale adjustment + // Handle out-of-range $\cos\,\thetao$ from scale adjustment cosThetap_o = std::abs(cosThetap_o); - // Handle out-of-range $\cos \thetao$ from scale adjustment + // Handle out-of-range $\cos\,\thetao$ from scale adjustment cosThetap_o = std::abs(cosThetap_o); pdf += Mp(cosTheta_i, cosThetap_o, sinTheta_i, sinThetap_o, v[p]) * apPDF[p] * @@ -515,7 +516,7 @@ Float HairBxDF::PDF(Vector3f wo, Vector3f wi, TransportMode mode, Float phi = phi_i - phi_o; Float pdf = 0; for (int p = 0; p < pMax; ++p) { - // Compute $\sin \thetao$ and $\cos \thetao$ terms accounting for scales + // Compute $\sin\,\thetao$ and $\cos\,\thetao$ terms accounting for scales Float sinThetap_o, cosThetap_o; if (p == 0) { sinThetap_o = sinTheta_o * cos2kAlpha[1] - cosTheta_o * sin2kAlpha[1]; @@ -533,7 +534,7 @@ Float HairBxDF::PDF(Vector3f wo, Vector3f wi, TransportMode mode, cosThetap_o = cosTheta_o; } - // Handle out-of-range $\cos \thetao$ from scale adjustment + // Handle out-of-range $\cos\,\thetao$ from scale adjustment cosThetap_o = std::abs(cosThetap_o); pdf += Mp(cosTheta_i, cosThetap_o, sinTheta_i, sinThetap_o, v[p]) * apPDF[p] * @@ -1010,7 +1011,7 @@ SampledSpectrum MeasuredBxDF::f(Vector3f wo, Vector3f wi, TransportMode mode) co return SampledSpectrum(0); wm = Normalize(wm); - // Map $\wo$ and $\wm$ to the unit square $[0, 1]^2$ + // Map $\wo$ and $\wm$ to the unit square $[0,\,1]^2$ Float theta_o = SphericalTheta(wo), phi_o = std::atan2(wo.y, wo.x); Float theta_m = SphericalTheta(wm), phi_m = std::atan2(wm.y, wm.x); Point2f u_wo(theta2u(theta_o), phi2u(phi_o)); diff --git a/src/pbrt/bxdfs.h b/src/pbrt/bxdfs.h index 33254357e..0c72c9ddc 100644 --- a/src/pbrt/bxdfs.h +++ b/src/pbrt/bxdfs.h @@ -477,7 +477,7 @@ class LayeredBxDF { SampledSpectrum f(Vector3f wo, Vector3f wi, TransportMode mode) const { SampledSpectrum f(0.); // Estimate _LayeredBxDF_ value _f_ using random sampling - // Set _wi_ and _wi_ for layered BSDF evaluation + // Set _wo_ and _wi_ for layered BSDF evaluation if (twoSided && wo.z < 0) { wo = -wo; wi = -wi; @@ -539,7 +539,7 @@ class LayeredBxDF { PBRT_DBG("beta: %f %f %f %f, w: %f %f %f, f: %f %f %f %f\n", beta[0], beta[1], beta[2], beta[3], w.x, w.y, w.z, f[0], f[1], f[2], f[3]); - // Possibly terminate layered BSDF random walk with Russian Roulette + // Possibly terminate layered BSDF random walk with Russian roulette if (depth > 3 && beta.MaxComponentValue() < 0.25f) { Float q = std::max(0, 1 - beta.MaxComponentValue()); if (r() < q) @@ -778,7 +778,7 @@ class LayeredBxDF { Float PDF(Vector3f wo, Vector3f wi, TransportMode mode, BxDFReflTransFlags sampleFlags = BxDFReflTransFlags::All) const { CHECK(sampleFlags == BxDFReflTransFlags::All); // for now - // Set _wi_ and _wi_ for layered BSDF evaluation + // Set _wo_ and _wi_ for layered BSDF evaluation if (twoSided && wo.z < 0) { wo = -wo; wi = -wi; diff --git a/src/pbrt/cameras.h b/src/pbrt/cameras.h index 4ea993284..73ffd67a5 100644 --- a/src/pbrt/cameras.h +++ b/src/pbrt/cameras.h @@ -272,6 +272,7 @@ class ProjectiveCamera : public CameraBase { cameraFromRaster = Inverse(screenFromCamera) * screenFromRaster; } + protected: // ProjectiveCamera Protected Members Transform screenFromCamera, cameraFromRaster; Transform rasterFromScreen, screenFromRaster; diff --git a/src/pbrt/cpu/aggregates.cpp b/src/pbrt/cpu/aggregates.cpp index a1d0621d2..53eb8c42b 100644 --- a/src/pbrt/cpu/aggregates.cpp +++ b/src/pbrt/cpu/aggregates.cpp @@ -290,7 +290,7 @@ BVHBuildNode *BVHAggregate::buildRecursive(ThreadLocal &threadAllocat // Compute costs for splitting after each bucket constexpr int nSplits = nBuckets - 1; - float costs[nSplits] = {}; + Float costs[nSplits] = {}; // Partially initialize _costs_ using a forward scan over splits int countBelow = 0; Bounds3f boundBelow; @@ -300,7 +300,7 @@ BVHBuildNode *BVHAggregate::buildRecursive(ThreadLocal &threadAllocat costs[i] += countBelow * boundBelow.SurfaceArea(); } - // Finish initializing _costs_ using a backwards scan over splits + // Finish initializing _costs_ using a backward scan over splits int countAbove = 0; Bounds3f boundAbove; for (int i = nSplits; i >= 1; --i) { diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index e2bdb3056..96575b829 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -146,7 +146,7 @@ void ImageTileIntegrator::Render() { Film film = camera.GetFilm(); DisplayDynamic(film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, - [&](Bounds2i b, pstd::span> displayValue) { + [&](Bounds2i b, pstd::span> displayValue) { int index = 0; for (Point2i p : b) { RGB rgb = film.GetPixelRGB(pixelBounds.pMin + p, @@ -521,7 +521,7 @@ void LightPathIntegrator::EvaluatePixelSample(Point2i pPixel, int sampleIndex, if (!sampledLight) return; Light light = sampledLight->light; - Float lightPDF = sampledLight->p; + Float p_l = sampledLight->p; // Sample point on light source for light path Float time = camera.SampleTime(sampler.Get1D()); @@ -544,7 +544,7 @@ void LightPathIntegrator::EvaluatePixelSample(Point2i pPixel, int sampleIndex, // Compute visible light's path contribution and add to film SampledSpectrum L = Le * DistanceSquared(cs->pRef.p(), cs->pLens.p()) * - cs->Wi / (lightPDF * pdf * cs->pdf); + cs->Wi / (p_l * pdf * cs->pdf); camera.GetFilm().AddSplat(cs->pRaster, L, lambda); } } @@ -556,7 +556,7 @@ void LightPathIntegrator::EvaluatePixelSample(Point2i pPixel, int sampleIndex, // Initialize light path ray and weighted path throughput _beta_ RayDifferential ray(les->ray); SampledSpectrum beta = - les->L * les->AbsCosTheta(ray.d) / (lightPDF * les->pdfPos * les->pdfDir); + les->L * les->AbsCosTheta(ray.d) / (p_l * les->pdfPos * les->pdfDir); while (true) { // Intersect light path ray with scene @@ -634,7 +634,7 @@ SampledSpectrum PathIntegrator::Li(RayDifferential ray, SampledWavelengths &lamb SampledSpectrum L(0.f), beta(1.f); int depth = 0; - Float bsdfPDF, etaScale = 1; + Float p_b, etaScale = 1; bool specularBounce = false, anyNonSpecularBounces = false; LightSampleContext prevIntrCtx; @@ -651,9 +651,9 @@ SampledSpectrum PathIntegrator::Li(RayDifferential ray, SampledWavelengths &lamb L += beta * Le; else { // Compute MIS weight for infinite light - Float lightPDF = lightSampler.PMF(prevIntrCtx, light) * - light.PDF_Li(prevIntrCtx, ray.d, true); - Float w_b = PowerHeuristic(1, bsdfPDF, 1, lightPDF); + Float p_l = lightSampler.PMF(prevIntrCtx, light) * + light.PDF_Li(prevIntrCtx, ray.d, true); + Float w_b = PowerHeuristic(1, p_b, 1, p_l); L += beta * w_b * Le; } @@ -669,9 +669,9 @@ SampledSpectrum PathIntegrator::Li(RayDifferential ray, SampledWavelengths &lamb else { // Compute MIS weight for area light Light areaLight(si->intr.areaLight); - Float lightPDF = lightSampler.PMF(prevIntrCtx, areaLight) * - areaLight.PDF_Li(prevIntrCtx, ray.d, true); - Float w_l = PowerHeuristic(1, bsdfPDF, 1, lightPDF); + Float p_l = lightSampler.PMF(prevIntrCtx, areaLight) * + areaLight.PDF_Li(prevIntrCtx, ray.d, true); + Float w_l = PowerHeuristic(1, p_b, 1, p_l); L += beta * w_l * Le; } @@ -739,7 +739,7 @@ SampledSpectrum PathIntegrator::Li(RayDifferential ray, SampledWavelengths &lamb break; // Update path state variables after surface scattering beta *= bs->f * AbsDot(bs->wi, isect.shading.n) / bs->pdf; - bsdfPDF = bs->pdfIsProportional ? bsdf.PDF(wo, bs->wi) : bs->pdf; + p_b = bs->pdfIsProportional ? bsdf.PDF(wo, bs->wi) : bs->pdf; DCHECK(!IsInf(beta.y(lambda))); specularBounce = bs->IsSpecular(); anyNonSpecularBounces |= !bs->IsSpecular(); @@ -899,7 +899,7 @@ SampledSpectrum SimpleVolPathIntegrator::Li(RayDifferential ray, return false; } else { - // Handle null scattering event for medium sample + // Handle null-scattering event for medium sample uMode = rng.Uniform(); return true; } @@ -1024,18 +1024,18 @@ SampledSpectrum VolPathIntegrator::Li(RayDifferential ray, SampledWavelengths &l return false; } - // Update _beta_ and _r_u_ for real scattering event + // Update _beta_ and _r_u_ for real-scattering event Float pdf = T_maj[0] * mp.sigma_s[0]; beta *= T_maj * mp.sigma_s / pdf; r_u *= T_maj * mp.sigma_s / pdf; if (beta && r_u) { - // Sample direct lighting at volume scattering event + // Sample direct lighting at volume-scattering event MediumInteraction intr(p, -ray.d, ray.time, ray.medium, mp.phase); L += SampleLd(intr, nullptr, lambda, sampler, beta, r_u); - // Sample new direction at real scattering event + // Sample new direction at real-scattering event Point2f u = sampler.Get2D(); pstd::optional ps = intr.phase.Sample_p(-ray.d, u); @@ -1088,9 +1088,9 @@ SampledSpectrum VolPathIntegrator::Li(RayDifferential ray, SampledWavelengths &l L += beta * Le / r_u.Average(); else { // Add infinite light contribution using both PDFs with MIS - Float lightPDF = lightSampler.PMF(prevIntrContext, light) * - light.PDF_Li(prevIntrContext, ray.d, true); - r_l *= lightPDF; + Float p_l = lightSampler.PMF(prevIntrContext, light) * + light.PDF_Li(prevIntrContext, ray.d, true); + r_l *= p_l; L += beta * Le / (r_u + r_l).Average(); } } @@ -1106,9 +1106,9 @@ SampledSpectrum VolPathIntegrator::Li(RayDifferential ray, SampledWavelengths &l else { // Add surface light contribution using both PDFs with MIS Light areaLight(isect.areaLight); - Float lightPDF = lightSampler.PMF(prevIntrContext, areaLight) * - areaLight.PDF_Li(prevIntrContext, ray.d, true); - r_l *= lightPDF; + Float p_l = lightSampler.PMF(prevIntrContext, areaLight) * + areaLight.PDF_Li(prevIntrContext, ray.d, true); + r_l *= p_l; L += beta * Le / (r_u + r_l).Average(); } } @@ -1304,7 +1304,7 @@ SampledSpectrum VolPathIntegrator::SampleLd(const Interaction &intr, const BSDF pstd::optional ls = light.SampleLi(ctx, uLight, lambda, true); if (!ls || !ls->L || ls->pdf == 0) return SampledSpectrum(0.f); - Float lightPDF = sampledLight->p * ls->pdf; + Float p_l = sampledLight->p * ls->pdf; // Evaluate BSDF or phase function for light sample direction Float scatterPDF; @@ -1383,7 +1383,7 @@ SampledSpectrum VolPathIntegrator::SampleLd(const Interaction &intr, const BSDF lightRay = si->intr.SpawnRayTo(ls->pLight); } // Return path contribution function estimate for direct lighting - r_l *= r_p * lightPDF; + r_l *= r_p * p_l; r_u *= r_p * scatterPDF; if (IsDeltaLight(light.Type())) return beta * f_hat * T_ray * ls->L / r_l.Average(); @@ -1934,12 +1934,12 @@ int GenerateLightSubpath(const Integrator &integrator, SampledWavelengths &lambd RayDifferential ray(les->ray); // Generate first vertex of light subpath - Float lightPDF = lightSamplePDF * les->pdfPos; - path[0] = les->intr ? Vertex::CreateLight(light, *les->intr, les->L, lightPDF) - : Vertex::CreateLight(light, ray, les->L, lightPDF); + Float p_l = lightSamplePDF * les->pdfPos; + path[0] = les->intr ? Vertex::CreateLight(light, *les->intr, les->L, p_l) + : Vertex::CreateLight(light, ray, les->L, p_l); // Follow light subpath random walk - SampledSpectrum beta = les->L * les->AbsCosTheta(ray.d) / (lightPDF * les->pdfDir); + SampledSpectrum beta = les->L * les->AbsCosTheta(ray.d) / (p_l * les->pdfDir); PBRT_DBG("%s\n", StringPrintf( "Starting light subpath. Ray: %s, Le %s, beta %s, pdfPos %f, pdfDir %f", @@ -2363,7 +2363,7 @@ SampledSpectrum ConnectBDPT(const Integrator &integrator, SampledWavelengths &la if (sampledLight) { Light light = sampledLight->light; - Float lightPDF = sampledLight->p; + Float p_l = sampledLight->p; LightSampleContext ctx; if (pt.IsOnSurface()) { @@ -2383,7 +2383,7 @@ SampledSpectrum ConnectBDPT(const Integrator &integrator, SampledWavelengths &la if (lightWeight && lightWeight->L && lightWeight->pdf > 0) { EndpointInteraction ei(light, lightWeight->pLight); sampled = Vertex::CreateLight( - ei, lightWeight->L / (lightWeight->pdf * lightPDF), 0); + ei, lightWeight->L / (lightWeight->pdf * p_l), 0); sampled.pdfFwd = sampled.PDFLightOrigin(integrator.infiniteLights, pt, lightSampler); L = pt.beta * pt.f(sampled, TransportMode::Radiance) * sampled.beta; @@ -2877,7 +2877,7 @@ void SPPMIntegrator::Render() { // Follow camera ray path until a visible point is created SPPMPixel &pixel = pixels[pPixel]; - Float etaScale = 1, bsdfPDF; + Float etaScale = 1, p_b; bool specularBounce = true, haveSetVisiblePoint = false; LightSampleContext prevIntrCtx; int depth = 0; @@ -2894,9 +2894,9 @@ void SPPMIntegrator::Render() { L += beta * Le; else { // Compute MIS weight for infinite light - Float lightPDF = lightSampler.PMF(prevIntrCtx, light) * - light.PDF_Li(prevIntrCtx, ray.d, true); - Float w_b = PowerHeuristic(1, bsdfPDF, 1, lightPDF); + Float p_l = lightSampler.PMF(prevIntrCtx, light) * + light.PDF_Li(prevIntrCtx, ray.d, true); + Float w_b = PowerHeuristic(1, p_b, 1, p_l); L += beta * w_b * Le; } @@ -2928,9 +2928,9 @@ void SPPMIntegrator::Render() { else { // Compute MIS weight for area light Light areaLight(si->intr.areaLight); - Float lightPDF = lightSampler.PMF(prevIntrCtx, areaLight) * - areaLight.PDF_Li(prevIntrCtx, ray.d, true); - Float w_l = PowerHeuristic(1, bsdfPDF, 1, lightPDF); + Float p_l = lightSampler.PMF(prevIntrCtx, areaLight) * + areaLight.PDF_Li(prevIntrCtx, ray.d, true); + Float w_l = PowerHeuristic(1, p_b, 1, p_l); L += beta * w_l * Le; } @@ -2966,7 +2966,7 @@ void SPPMIntegrator::Render() { etaScale *= Sqr(bs->eta); beta *= bs->f * AbsDot(bs->wi, isect.shading.n) / bs->pdf; - bsdfPDF = bs->pdfIsProportional ? bsdf.PDF(wo, bs->wi) : bs->pdf; + p_b = bs->pdfIsProportional ? bsdf.PDF(wo, bs->wi) : bs->pdf; SampledSpectrum rrBeta = beta * etaScale; if (rrBeta.MaxComponentValue() < 1) { @@ -3079,7 +3079,7 @@ void SPPMIntegrator::Render() { if (!sampledLight) continue; Light light = sampledLight->light; - Float lightPDF = sampledLight->p; + Float p_l = sampledLight->p; // Compute sample values for photon ray leaving light source Point2f uLight0 = Sample2D(); @@ -3094,7 +3094,7 @@ void SPPMIntegrator::Render() { continue; RayDifferential photonRay = RayDifferential(les->ray); SampledSpectrum beta = (les->AbsCosTheta(photonRay.d) * les->L) / - (lightPDF * les->pdfPos * les->pdfDir); + (p_l * les->pdfPos * les->pdfDir); if (!beta) continue; diff --git a/src/pbrt/cpu/integrators.h b/src/pbrt/cpu/integrators.h index 275a84fa6..eb38543bd 100644 --- a/src/pbrt/cpu/integrators.h +++ b/src/pbrt/cpu/integrators.h @@ -62,7 +62,7 @@ class Integrator { std::vector infiniteLights; protected: - // Integrator Private Methods + // Integrator Protected Methods Integrator(Primitive aggregate, std::vector lights) : aggregate(aggregate), lights(lights) { // Integrator constructor implementation diff --git a/src/pbrt/lights.cpp b/src/pbrt/lights.cpp index af1f66748..b66128f99 100644 --- a/src/pbrt/lights.cpp +++ b/src/pbrt/lights.cpp @@ -133,11 +133,11 @@ Float LightBounds::Importance(Point3f p, Normal3f n) const { cosTheta_w = std::abs(cosTheta_w); Float sinTheta_w = SafeSqrt(1 - Sqr(cosTheta_w)); - // Compute $\cos \theta_\roman{b}$ for reference point + // Compute $\cos\,\theta_\roman{\+b}$ for reference point Float cosTheta_b = BoundSubtendedDirections(bounds, p).cosTheta; Float sinTheta_b = SafeSqrt(1 - Sqr(cosTheta_b)); - // Compute $\cos \theta'$ and test against $\cos \theta_\roman{e}$ + // Compute $\cos\,\theta'$ and test against $\cos\,\theta_\roman{e}$ Float sinTheta_o = SafeSqrt(1 - Sqr(cosTheta_o)); Float cosTheta_x = cosSubClamped(sinTheta_w, cosTheta_w, sinTheta_o, cosTheta_o); Float sinTheta_x = sinSubClamped(sinTheta_w, cosTheta_w, sinTheta_o, cosTheta_o); @@ -148,7 +148,7 @@ Float LightBounds::Importance(Point3f p, Normal3f n) const { // Return final importance at reference point Float importance = phi * cosThetap / d2; DCHECK_GE(importance, -1e-3); - // Account for $\cos \theta_\roman{i}$ in importance at surfaces + // Account for $\cos\theta_\roman{i}$ in importance at surfaces if (n != Normal3f(0, 0, 0)) { Float cosTheta_i = AbsDot(wi, n); Float sinTheta_i = SafeSqrt(1 - Sqr(cosTheta_i)); @@ -1260,7 +1260,7 @@ Float PortalImageInfiniteLight::PDF_Li(LightSampleContext ctx, Vector3f w, // Return PDF for sampling $(u,v)$ from reference point pstd::optional b = ImageBounds(ctx.p()); if (!b) - return {}; + return 0; Float pdf = distribution.PDF(*uv, *b); return pdf / duv_dw; } diff --git a/src/pbrt/lightsamplers.h b/src/pbrt/lightsamplers.h index 997397fda..e98e4bdca 100644 --- a/src/pbrt/lightsamplers.h +++ b/src/pbrt/lightsamplers.h @@ -69,9 +69,9 @@ class PowerLightSampler { pstd::optional Sample(Float u) const { if (!aliasTable.size()) return {}; - Float pdf; - int lightIndex = aliasTable.Sample(u, &pdf); - return SampledLight{lights[lightIndex], pdf}; + Float pmf; + int lightIndex = aliasTable.Sample(u, &pmf); + return SampledLight{lights[lightIndex], pmf}; } PBRT_CPU_GPU @@ -172,11 +172,11 @@ class CompactLightBounds { cosTheta_w = std::abs(cosTheta_w); Float sinTheta_w = SafeSqrt(1 - Sqr(cosTheta_w)); - // Compute $\cos \theta_\roman{b}$ for reference point + // Compute $\cos\,\theta_\roman{\+b}$ for reference point Float cosTheta_b = BoundSubtendedDirections(bounds, p).cosTheta; Float sinTheta_b = SafeSqrt(1 - Sqr(cosTheta_b)); - // Compute $\cos \theta'$ and test against $\cos \theta_\roman{e}$ + // Compute $\cos\,\theta'$ and test against $\cos\,\theta_\roman{e}$ Float sinTheta_o = SafeSqrt(1 - Sqr(cosTheta_o)); Float cosTheta_x = cosSubClamped(sinTheta_w, cosTheta_w, sinTheta_o, cosTheta_o); Float sinTheta_x = sinSubClamped(sinTheta_w, cosTheta_w, sinTheta_o, cosTheta_o); @@ -187,7 +187,7 @@ class CompactLightBounds { // Return final importance at reference point Float importance = phi * cosThetap / d2; DCHECK_GE(importance, -1e-3); - // Account for $\cos \theta_\roman{i}$ in importance at surfaces + // Account for $\cos\theta_\roman{i}$ in importance at surfaces if (n != Normal3f(0, 0, 0)) { Float cosTheta_i = AbsDot(wi, n); Float sinTheta_i = SafeSqrt(1 - Sqr(cosTheta_i)); @@ -273,8 +273,8 @@ class BVHLightSampler { u /= pInfinite; int index = std::min(u * infiniteLights.size(), infiniteLights.size() - 1); - Float pdf = pInfinite / infiniteLights.size(); - return SampledLight{infiniteLights[index], pdf}; + Float pmf = pInfinite / infiniteLights.size(); + return SampledLight{infiniteLights[index], pmf}; } else { // Traverse light BVH to sample light @@ -285,7 +285,7 @@ class BVHLightSampler { Normal3f n = ctx.ns; u = std::min((u - pInfinite) / (1 - pInfinite), OneMinusEpsilon); int nodeIndex = 0; - Float pdf = 1 - pInfinite; + Float pmf = 1 - pInfinite; while (true) { // Process light BVH node for light sampling @@ -301,9 +301,9 @@ class BVHLightSampler { return {}; // Randomly sample light BVH child node - Float nodePDF; - int child = SampleDiscrete(ci, u, &nodePDF, &u); - pdf *= nodePDF; + Float nodePMF; + int child = SampleDiscrete(ci, u, &nodePMF, &u); + pmf *= nodePMF; nodeIndex = (child == 0) ? (nodeIndex + 1) : node.childOrLightIndex; } else { @@ -312,7 +312,7 @@ class BVHLightSampler { DCHECK_GT(node.lightBounds.Importance(p, n, allLightBounds), 0); if (nodeIndex > 0 || node.lightBounds.Importance(p, n, allLightBounds) > 0) - return SampledLight{lights[node.childOrLightIndex], pdf}; + return SampledLight{lights[node.childOrLightIndex], pmf}; return {}; } } @@ -321,11 +321,11 @@ class BVHLightSampler { PBRT_CPU_GPU Float PMF(const LightSampleContext &ctx, Light light) const { - // Handle infinite _light_ PDF computation + // Handle infinite _light_ PMF computation if (!lightToBitTrail.HasKey(light)) return 1.f / (infiniteLights.size() + (nodes.empty() ? 0 : 1)); - // Initialize local variables for BVH traversal for PDF computation + // Initialize local variables for BVH traversal for PMF computation uint32_t bitTrail = lightToBitTrail[light]; Point3f p = ctx.p(); Normal3f n = ctx.ns; @@ -333,23 +333,23 @@ class BVHLightSampler { Float pInfinite = Float(infiniteLights.size()) / Float(infiniteLights.size() + (nodes.empty() ? 0 : 1)); - Float pdf = 1 - pInfinite; + Float pmf = 1 - pInfinite; int nodeIndex = 0; - // Compute light's PDF by walking down tree nodes to the light + // Compute light's PMF by walking down tree nodes to the light while (true) { const LightBVHNode *node = &nodes[nodeIndex]; if (node->isLeaf) { DCHECK_EQ(light, lights[node->childOrLightIndex]); - return pdf; + return pmf; } - // Compute child importances and update PDF for current node + // Compute child importances and update PMF for current node const LightBVHNode *child0 = &nodes[nodeIndex + 1]; const LightBVHNode *child1 = &nodes[node->childOrLightIndex]; Float ci[2] = {child0->lightBounds.Importance(p, n, allLightBounds), child1->lightBounds.Importance(p, n, allLightBounds)}; DCHECK_GT(ci[bitTrail & 1], 0); - pdf *= ci[bitTrail & 1] / (ci[0] + ci[1]); + pmf *= ci[bitTrail & 1] / (ci[0] + ci[1]); // Use _bitTrail_ to find next node index and update its value nodeIndex = (bitTrail & 1) ? node->childOrLightIndex : (nodeIndex + 1); diff --git a/src/pbrt/samplers.h b/src/pbrt/samplers.h index 62cfe4cd4..2d13f94f7 100644 --- a/src/pbrt/samplers.h +++ b/src/pbrt/samplers.h @@ -186,7 +186,7 @@ class PaddedSobolSampler { int dim = dimension; dimension += 2; - // Return randomized 2D Sobol' sample + // Return randomized 2D Sobol\+$'$ sample return Point2f(SampleDimension(0, index, uint32_t(hash)), SampleDimension(1, index, hash >> 32)); } @@ -258,7 +258,7 @@ class ZSobolSampler { Float Get1D() { uint64_t sampleIndex = GetSampleIndex(); ++dimension; - // Generate 1D Sobol$'$ sample at _sampleIndex_ + // Generate 1D Sobol\+$'$ sample at _sampleIndex_ uint32_t sampleHash = Hash(dimension, seed); if (randomize == RandomizeStrategy::None) return SobolSample(sampleIndex, 0, NoRandomizer()); @@ -274,7 +274,7 @@ class ZSobolSampler { Point2f Get2D() { uint64_t sampleIndex = GetSampleIndex(); dimension += 2; - // Generate 2D Sobol sample at _sampleIndex_ + // Generate 2D Sobol\+$'$ sample at _sampleIndex_ uint64_t bits = Hash(dimension, seed); uint32_t sampleHash[2] = {uint32_t(bits), uint32_t(bits >> 32)}; if (randomize == RandomizeStrategy::None) @@ -334,7 +334,7 @@ class ZSobolSampler { bool pow2Samples = log2SamplesPerPixel & 1; int lastDigit = pow2Samples ? 1 : 0; for (int i = nBase4Digits - 1; i >= lastDigit; --i) { - // Randomly permute $i$th base 4 digit in _mortonIndex_ + // Randomly permute $i$th base-4 digit in _mortonIndex_ int digitShift = 2 * i - (pow2Samples ? 1 : 0); int digit = (mortonIndex >> digitShift) & 3; // Choose permutation _p_ to use for _digit_ @@ -525,7 +525,7 @@ class SobolSampler { Point2f GetPixel2D() { Point2f u(SobolSample(sobolIndex, 0, NoRandomizer()), SobolSample(sobolIndex, 1, NoRandomizer())); - // Remap Sobol$'$ dimensions used for pixel samples + // Remap Sobol\+$'$ dimensions used for pixel samples for (int dim = 0; dim < 2; ++dim) { DCHECK_RARE(1e-7, u[dim] * scale - pixel[dim] < 0); DCHECK_RARE(1e-7, u[dim] * scale - pixel[dim] > 1); @@ -542,11 +542,11 @@ class SobolSampler { // SobolSampler Private Methods PBRT_CPU_GPU Float SampleDimension(int dimension) const { - // Return un-randomized Sobol$'$ sample if appropriate + // Return un-randomized Sobol\+$'$ sample if appropriate if (randomize == RandomizeStrategy::None) return SobolSample(sobolIndex, dimension, NoRandomizer()); - // Return randomized Sobol$'$ sample using _randomize_ + // Return randomized Sobol\+$'$ sample using _randomize_ uint32_t hash = Hash(dimension, seed); if (randomize == RandomizeStrategy::PermuteDigits) return SobolSample(sobolIndex, dimension, BinaryPermuteScrambler(hash)); diff --git a/src/pbrt/shapes.cpp b/src/pbrt/shapes.cpp index 2b81df572..f765baef9 100644 --- a/src/pbrt/shapes.cpp +++ b/src/pbrt/shapes.cpp @@ -211,7 +211,7 @@ pstd::optional IntersectTriangle(const Ray &ray, Float tMa Float e1 = DifferenceOfProducts(p2t.x, p0t.y, p2t.y, p0t.x); Float e2 = DifferenceOfProducts(p0t.x, p1t.y, p0t.y, p1t.x); - // Fall back to double precision test at triangle edges + // Fall back to double-precision test at triangle edges if (sizeof(Float) == sizeof(float) && (e0 == 0.0f || e1 == 0.0f || e2 == 0.0f)) { double p2txp1ty = (double)p2t.x * (double)p1t.y; double p2typ1tx = (double)p2t.y * (double)p1t.x; @@ -677,6 +677,7 @@ bool Curve::RecursiveIntersect(const Ray &ray, Float tMax, pstd::span(cp), Clamp(w, 0, 1), &dpcdw); Float ptCurveDist2 = Sqr(pc.x) + Sqr(pc.y); + if (ptCurveDist2 > Sqr(hitWidth) * 0.25f) return false; if (pc.z < 0 || pc.z > rayLength * tMax) @@ -1284,9 +1285,9 @@ pstd::optional BilinearPatch::Sample(const ShapeSampleContext &ctx, } // Sample direction to rectangular bilinear patch Float pdf = 1; - // Warp uniform sample _u_ to account for incident $\cos \theta$ factor + // Warp uniform sample _u_ to account for incident $\cos\theta$ factor if (ctx.ns != Normal3f(0, 0, 0)) { - // Compute $\cos \theta$ weights for rectangle seen from reference point + // Compute $\cos\theta$ weights for rectangle seen from reference point pstd::array w = pstd::array{std::max(0.01, AbsDot(v00, ctx.ns)), std::max(0.01, AbsDot(v10, ctx.ns)), @@ -1355,7 +1356,7 @@ Float BilinearPatch::PDF(const ShapeSampleContext &ctx, Vector3f wi) const { // Return PDF for sample in spherical rectangle Float pdf = 1 / SphericalQuadArea(v00, v10, v11, v01); if (ctx.ns != Normal3f(0, 0, 0)) { - // Compute $\cos \theta$ weights for rectangle seen from reference point + // Compute $\cos\theta$ weights for rectangle seen from reference point pstd::array w = pstd::array{std::max(0.01, AbsDot(v00, ctx.ns)), std::max(0.01, AbsDot(v10, ctx.ns)), diff --git a/src/pbrt/shapes.h b/src/pbrt/shapes.h index 4629781ea..fc984b9d8 100644 --- a/src/pbrt/shapes.h +++ b/src/pbrt/shapes.h @@ -313,7 +313,7 @@ class Sphere { } // Sample sphere uniformly inside subtended cone - // Compute quantities related the $\theta_\roman{max}$ for cone + // Compute quantities related to the $\theta_\roman{max}$ for cone Float sinThetaMax = radius / Distance(ctx.p(), pCenter); Float sin2ThetaMax = Sqr(sinThetaMax); Float cosThetaMax = SafeSqrt(1 - sin2ThetaMax); @@ -511,6 +511,7 @@ class Disk { Point3f pObj(pd.x * radius, pd.y * radius, height); Point3fi pi = (*renderFromObject)(Point3fi(pObj)); Normal3f n = Normalize((*renderFromObject)(Normal3f(0, 0, 1))); + if (reverseOrientation) n *= -1; // Compute $(u,v)$ for sampled point on disk @@ -1079,7 +1080,7 @@ class Triangle { // Apply warp product sampling for cosine factor at reference point Float pdf = 1; if (ctx.ns != Normal3f(0, 0, 0)) { - // Compute $\cos \theta$-based weights _w_ at sample domain corners + // Compute $\cos\theta$-based weights _w_ at sample domain corners Point3f rp = ctx.p(); Vector3f wi[3] = {Normalize(p0 - rp), Normalize(p1 - rp), Normalize(p2 - rp)}; pstd::array w = @@ -1104,7 +1105,7 @@ class Triangle { Point3f pAbsSum = Abs(b[0] * p0) + Abs(b[1] * p1) + Abs((1 - b[0] - b[1]) * p2); Vector3f pError = Vector3f(gamma(6) * pAbsSum); - // Return _ShapeSample_ for uniform solid angle sampled point on triangle + // Return _ShapeSample_ for solid angle sampled point on triangle Point3f p = b[0] * p0 + b[1] * p1 + b[2] * p2; // Compute surface normal for sampled point on triangle Normal3f n = Normalize(Normal3f(Cross(p1 - p0, p2 - p0))); @@ -1149,7 +1150,7 @@ class Triangle { } Float pdf = 1 / solidAngle; - // Adjust PDF for warp product sampling of triangle $\cos \theta$ factor + // Adjust PDF for warp product sampling of triangle $\cos\theta$ factor if (ctx.ns != Normal3f(0, 0, 0)) { // Get triangle vertices in _p0_, _p1_, and _p2_ const TriangleMesh *mesh = GetMesh(); @@ -1157,7 +1158,7 @@ class Triangle { Point3f p0 = mesh->p[v[0]], p1 = mesh->p[v[1]], p2 = mesh->p[v[2]]; Point2f u = InvertSphericalTriangleSample({p0, p1, p2}, ctx.p(), wi); - // Compute $\cos \theta$-based weights _w_ at sample domain corners + // Compute $\cos\theta$-based weights _w_ at sample domain corners Point3f rp = ctx.p(); Vector3f wi[3] = {Normalize(p0 - rp), Normalize(p1 - rp), Normalize(p2 - rp)}; pstd::array w = diff --git a/src/pbrt/textures.h b/src/pbrt/textures.h index a33b49a20..4a074e967 100644 --- a/src/pbrt/textures.h +++ b/src/pbrt/textures.h @@ -117,7 +117,7 @@ class SphericalMapping { PBRT_CPU_GPU TexCoord2D Map(TextureEvalContext ctx) const { Point3f pt = textureFromRender(ctx.p); - // Compute $\partial s/\partial \pt{}$ and $\partial t/\partial \pt{}$ for + // Compute $\partial\,s/\partial\,\pt{}$ and $\partial\,t/\partial\,\pt{}$ for // spherical mapping Float x2y2 = Sqr(pt.x) + Sqr(pt.y); Float sqrtx2y2 = std::sqrt(x2y2); diff --git a/src/pbrt/util/buffercache.h b/src/pbrt/util/buffercache.h index 36f10abe4..92baad934 100644 --- a/src/pbrt/util/buffercache.h +++ b/src/pbrt/util/buffercache.h @@ -32,7 +32,7 @@ class BufferCache { // BufferCache Public Methods const T *LookupOrAdd(pstd::span buf, Allocator alloc) { ++nBufferCacheLookups; - // Return pointer to data if _buf_ contents is already in the cache + // Return pointer to data if _buf_ contents are already in the cache Buffer lookupBuffer(buf.data(), buf.size()); int shardIndex = uint32_t(lookupBuffer.hash) >> (32 - logShards); DCHECK(shardIndex >= 0 && shardIndex < nShards); diff --git a/src/pbrt/util/lowdiscrepancy.h b/src/pbrt/util/lowdiscrepancy.h index 9ce4abab1..dfa923197 100644 --- a/src/pbrt/util/lowdiscrepancy.h +++ b/src/pbrt/util/lowdiscrepancy.h @@ -168,13 +168,13 @@ template PBRT_CPU_GPU inline Float SobolSample(int64_t a, int dimension, R randomizer) { DCHECK_LT(dimension, NSobolDimensions); DCHECK(a >= 0 && a < (1ull << SobolMatrixSize)); - // Compute initial Sobol sample _v_ using generator matrices + // Compute initial Sobol\+$'$ sample _v_ using generator matrices uint32_t v = 0; for (int i = dimension * SobolMatrixSize; a != 0; a >>= 1, i++) if (a & 1) v ^= SobolMatrices32[i]; - // Randomize Sobol sample and return floating-point value + // Randomize Sobol\+$'$ sample and return floating-point value v = randomizer(v); return std::min(v * 0x1p-32f, FloatOneMinusEpsilon); } diff --git a/src/pbrt/util/math.cpp b/src/pbrt/util/math.cpp index f54fcbc9f..d65a555bb 100644 --- a/src/pbrt/util/math.cpp +++ b/src/pbrt/util/math.cpp @@ -306,7 +306,7 @@ Vector3f EqualAreaSquareToSphere(Point2f p) { // Find $z$ coordinate for spherical direction Float z = pstd::copysign(1 - Sqr(r), signedDistance); - // Compute $\cos \phi$ and $\sin \phi$ for original quadrant and return vector + // Compute $\cos\phi$ and $\sin\phi$ for original quadrant and return vector Float cosPhi = pstd::copysign(std::cos(phi), u); Float sinPhi = pstd::copysign(std::sin(phi), v); return Vector3f(cosPhi * r * SafeSqrt(2 - Sqr(r)), sinPhi * r * SafeSqrt(2 - Sqr(r)), diff --git a/src/pbrt/util/math.h b/src/pbrt/util/math.h index bec2b9acc..d54620d14 100644 --- a/src/pbrt/util/math.h +++ b/src/pbrt/util/math.h @@ -338,7 +338,7 @@ PBRT_CPU_GPU inline constexpr Float EvaluatePolynomial(Float t, C c, Args... cRe // http://www.plunk.org/~hatch/rightway.html PBRT_CPU_GPU inline Float SinXOverX(Float x) { - if (1 + x * x == 1) + if (1 - x * x == 1) return 1; return std::sin(x) / x; } diff --git a/src/pbrt/util/sampling.cpp b/src/pbrt/util/sampling.cpp index 42fc1a44c..6dfacd65d 100644 --- a/src/pbrt/util/sampling.cpp +++ b/src/pbrt/util/sampling.cpp @@ -59,7 +59,7 @@ pstd::array SampleSphericalTriangle(const pstd::array &v, *pdf = (A <= 0) ? 0 : 1 / A; } - // Find $\cos \beta'$ for point along _b_ for sampled area + // Find $\cos\beta'$ for point along _b_ for sampled area Float cosAlpha = std::cos(alpha), sinAlpha = std::sin(alpha); Float sinPhi = std::sin(Ap_pi) * cosAlpha - std::cos(Ap_pi) * sinAlpha; Float cosPhi = std::cos(Ap_pi) * cosAlpha + std::sin(Ap_pi) * sinAlpha; @@ -345,7 +345,7 @@ Point2f InvertSphericalRectangleSample(Point3f pRef, Point3f s, Vector3f ex, Vec } Vector3f SampleHenyeyGreenstein(Vector3f wo, Float g, Point2f u, Float *pdf) { - // Compute $\cos \theta$ for Henyey--Greenstein sample + // Compute $\cos\theta$ for Henyey--Greenstein sample Float cosTheta; if (std::abs(g) < 1e-3f) cosTheta = 1 - 2 * u[0]; @@ -576,7 +576,7 @@ AliasTable::AliasTable(pstd::span weights, Allocator alloc) // Process under and over work item together while (!under.empty() && !over.empty()) { - // Remove an item from each alias table work list + // Remove items _un_ and _ov_ from the alias table work lists Outcome un = under.back(), ov = over.back(); under.pop_back(); over.pop_back(); diff --git a/src/pbrt/util/transform.h b/src/pbrt/util/transform.h index a1a8a5497..8e5b17d42 100644 --- a/src/pbrt/util/transform.h +++ b/src/pbrt/util/transform.h @@ -132,7 +132,7 @@ class Transform { PBRT_CPU_GPU Point3fi operator()(const Point3fi &p) const { Float x = Float(p.x), y = Float(p.y), z = Float(p.z); - // Compute transformed coordinates from point _x_, _y_, and _z_ + // Compute transformed coordinates from point _(x, y, z)_ Float xp = (m[0][0] * x + m[0][1] * y) + (m[0][2] * z + m[0][3]); Float yp = (m[1][0] * x + m[1][1] * y) + (m[1][2] * z + m[1][3]); Float zp = (m[2][0] * x + m[2][1] * y) + (m[2][2] * z + m[2][3]); From db03ad9b70c0f1ebc88d3fb199c9f7331b8bd1d1 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 3 Jan 2023 13:41:08 -0800 Subject: [PATCH 097/149] Fix bug in PBRT_FLOAT_AS_DOUBLE build introduced in 20673d2d8ac6b9 --- src/pbrt/cpu/integrators.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index 96575b829..bbc0608c1 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -146,7 +146,7 @@ void ImageTileIntegrator::Render() { Film film = camera.GetFilm(); DisplayDynamic(film.GetFilename(), Point2i(pixelBounds.Diagonal()), {"R", "G", "B"}, - [&](Bounds2i b, pstd::span> displayValue) { + [&](Bounds2i b, pstd::span> displayValue) { int index = 0; for (Point2i p : b) { RGB rgb = film.GetPixelRGB(pixelBounds.pMin + p, From 302b5d508124ec856501e933ee399bfa326b7cff Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 3 Jan 2023 13:31:41 -0800 Subject: [PATCH 098/149] Upgrade to actions/checkout@v3 --- .github/workflows/ci-cpu-linux.yml | 4 ++-- .github/workflows/ci-cpu-macos.yml | 4 ++-- .github/workflows/ci-cpu-windows.yml | 4 ++-- .github/workflows/ci-gpu.yml | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-cpu-linux.yml b/.github/workflows/ci-cpu-linux.yml index feafca28a..4622a4b26 100644 --- a/.github/workflows/ci-cpu-linux.yml +++ b/.github/workflows/ci-cpu-linux.yml @@ -45,12 +45,12 @@ jobs: steps: - name: Checkout pbrt - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true - name: Checkout rgb2spectrum tables - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: mmp/rgb2spectrum path: build diff --git a/.github/workflows/ci-cpu-macos.yml b/.github/workflows/ci-cpu-macos.yml index 93faa79b4..10959b25e 100644 --- a/.github/workflows/ci-cpu-macos.yml +++ b/.github/workflows/ci-cpu-macos.yml @@ -23,12 +23,12 @@ jobs: steps: - name: Checkout pbrt - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true - name: Checkout rgb2spectrum tables - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: mmp/rgb2spectrum path: build diff --git a/.github/workflows/ci-cpu-windows.yml b/.github/workflows/ci-cpu-windows.yml index d75e49e32..6455c5e4a 100644 --- a/.github/workflows/ci-cpu-windows.yml +++ b/.github/workflows/ci-cpu-windows.yml @@ -23,12 +23,12 @@ jobs: steps: - name: Checkout pbrt - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true - name: Checkout rgb2spectrum tables - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: mmp/rgb2spectrum path: build diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index 66f850a16..df270825b 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -35,12 +35,12 @@ jobs: run: nvcc -V - name: Checkout pbrt - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true - name: Checkout rgb2spectrum tables - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: mmp/rgb2spectrum path: build @@ -52,7 +52,7 @@ jobs: key: optix-7.12345 - name: Checkout OptiX headers - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ssh-key: ${{ secrets.CHECKOUT_KEY }} repository: mmp/optix-headers From 83d428279567081ad0ce1471c090e73f158aab20 Mon Sep 17 00:00:00 2001 From: jim price Date: Wed, 4 Jan 2023 01:11:34 -0800 Subject: [PATCH 099/149] Avoid NaNs when the BSDFSample's pdf is 0. Addresses #313 --- src/pbrt/bxdfs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/bxdfs.cpp b/src/pbrt/bxdfs.cpp index 5f4dd46f5..0763bb4fd 100644 --- a/src/pbrt/bxdfs.cpp +++ b/src/pbrt/bxdfs.cpp @@ -1136,7 +1136,7 @@ SampledSpectrum BxDF::rho(Vector3f wo, pstd::span uc, for (size_t i = 0; i < uc.size(); ++i) { // Compute estimate of $\rho_\roman{hd}$ pstd::optional bs = Sample_f(wo, uc[i], u2[i]); - if (bs) + if (bs && bs->pdf > 0) r += bs->f * AbsCosTheta(bs->wi) / bs->pdf; } return r / uc.size(); @@ -1154,7 +1154,7 @@ SampledSpectrum BxDF::rho(pstd::span u1, pstd::span continue; Float pdfo = UniformHemispherePDF(); pstd::optional bs = Sample_f(wo, uc[i], u2[i]); - if (bs) + if (bs && bs->pdf > 0) r += bs->f * AbsCosTheta(bs->wi) * AbsCosTheta(wo) / (pdfo * bs->pdf); } return r / (Pi * uc.size()); From 0786e4e0a09ac4899c2593acefb7256d0b00a8cf Mon Sep 17 00:00:00 2001 From: NePPoi <2251277087@qq.com> Date: Tue, 10 Jan 2023 13:42:51 +0800 Subject: [PATCH 100/149] Fix bug in polymorphic_allocator::deallocate --- src/pbrt/util/pstd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/util/pstd.h b/src/pbrt/util/pstd.h index 7a568eb3f..2d6065fef 100644 --- a/src/pbrt/util/pstd.h +++ b/src/pbrt/util/pstd.h @@ -636,7 +636,7 @@ class polymorphic_allocator { [[nodiscard]] Tp *allocate(size_t n) { return static_cast(resource()->allocate(n * sizeof(Tp), alignof(Tp))); } - void deallocate(Tp *p, size_t n) { resource()->deallocate(p, n); } + void deallocate(Tp *p, size_t n) { resource()->deallocate(p, n * sizeof(Tp)); } void *allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t)) { return resource()->allocate(nbytes, alignment); From 6da64631f9dec6a0a656268475ef5310b849a850 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 28 Jan 2023 06:59:14 -0800 Subject: [PATCH 101/149] Increase sampling rate for tests when NSpectrumSamples < 4. Fixes #321. --- src/pbrt/bsdfs_test.cpp | 2 ++ src/pbrt/cpu/integrators_test.cpp | 33 ++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/pbrt/bsdfs_test.cpp b/src/pbrt/bsdfs_test.cpp index aa025eb76..15f9443d9 100644 --- a/src/pbrt/bsdfs_test.cpp +++ b/src/pbrt/bsdfs_test.cpp @@ -681,6 +681,8 @@ TEST(Hair, WhiteFurnace) { // More samples for the smooth case, since we're sampling blindly. int count = (beta_m < .5 || beta_n < .5) ? 100000 : 20000; + if (NSpectrumSamples < 4) count *= 4; + for (int i = 0; i < count; ++i) { SampledWavelengths lambda = SampledWavelengths::SampleVisible(RadicalInverse(0, i)); diff --git a/src/pbrt/cpu/integrators_test.cpp b/src/pbrt/cpu/integrators_test.cpp index dfcc7b6f1..15fc5c2f6 100644 --- a/src/pbrt/cpu/integrators_test.cpp +++ b/src/pbrt/cpu/integrators_test.cpp @@ -241,26 +241,31 @@ std::vector> GetSamplers(const Point2i &resoluti if (!samplers.empty()) return samplers; - samplers.push_back(std::make_pair(new HaltonSampler(256, resolution), "Halton 256")); + int sqrtSpp = 16; + if (NSpectrumSamples < 4) + sqrtSpp *= 2; + int spp = sqrtSpp * sqrtSpp; + + samplers.push_back(std::make_pair(new HaltonSampler(spp, resolution), "Halton")); samplers.push_back( - std::make_pair(new PaddedSobolSampler(256, RandomizeStrategy::PermuteDigits), - "Padded Sobol 256")); + std::make_pair(new PaddedSobolSampler(spp, RandomizeStrategy::PermuteDigits), + "Padded Sobolspp")); samplers.push_back(std::make_pair( - new ZSobolSampler(256, Point2i(16, 16), RandomizeStrategy::PermuteDigits), - "Z Sobol 256")); + new ZSobolSampler(spp, Point2i(16, 16), RandomizeStrategy::PermuteDigits), + "Z Sobol")); samplers.push_back( - std::make_pair(new SobolSampler(256, resolution, RandomizeStrategy::None), - "Sobol 256 Not Randomized")); + std::make_pair(new SobolSampler(spp, resolution, RandomizeStrategy::None), + "Sobol Not Randomized")); samplers.push_back(std::make_pair( - new SobolSampler(256, resolution, RandomizeStrategy::PermuteDigits), - "Sobol 256 XOR Scramble")); + new SobolSampler(spp, resolution, RandomizeStrategy::PermuteDigits), + "Sobol XOR Scramble")); samplers.push_back( - std::make_pair(new SobolSampler(256, resolution, RandomizeStrategy::Owen), - "Sobol 256 Owen Scramble")); - samplers.push_back(std::make_pair(new IndependentSampler(256), "Independent 256")); + std::make_pair(new SobolSampler(spp, resolution, RandomizeStrategy::Owen), + "Sobol Owen Scramble")); + samplers.push_back(std::make_pair(new IndependentSampler(spp), "Independent")); samplers.push_back( - std::make_pair(new StratifiedSampler(16, 16, true), "Stratified 16x16")); - samplers.push_back(std::make_pair(new PMJ02BNSampler(256), "PMJ02bn 256")); + std::make_pair(new StratifiedSampler(sqrtSpp,sqrtSpp, true), "Stratified")); + samplers.push_back(std::make_pair(new PMJ02BNSampler(spp), "PMJ02bn")); return samplers; } From 967aa48d113abc6e774d09fb2f52b28db2fe6a75 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 28 Jan 2023 07:01:57 -0800 Subject: [PATCH 102/149] Add --fp16 option to imgtool convert --- src/pbrt/cmd/imgtool.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 8f7656b6a..5e91fe267 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -108,6 +108,7 @@ static std::map commandUsage = { replace the pixel with the median of the 3x3 neighboring pixels. Default: infinity (i.e., disabled). --flipy Flip the image along the y axis + --fp16 Convert image to fp16 pixel format. --gamma Apply a gamma curve with exponent v. (Default: 1 (none)). --maxluminance Luminance value mapped to white by tonemapping. Default: 1 @@ -1646,6 +1647,7 @@ int convert(std::vector args) { Float despikeLimit = Infinity; bool preserveColors = false; bool bw = false; + bool fp16 = false; std::string inFile, outFile; std::string colorspace; std::string channelNames; @@ -1665,6 +1667,7 @@ int convert(std::vector args) { ParseArg(&iter, args.end(), "colorspace", &colorspace, onError) || ParseArg(&iter, args.end(), "crop", pstd::MakeSpan(cropWindow), onError) || ParseArg(&iter, args.end(), "despike", &despikeLimit, onError) || + ParseArg(&iter, args.end(), "fp16", &fp16, onError) || ParseArg(&iter, args.end(), "flipy", &flipy, onError) || ParseArg(&iter, args.end(), "gamma", &gamma, onError) || ParseArg(&iter, args.end(), "maxluminance", &maxY, onError) || @@ -1972,6 +1975,9 @@ int convert(std::vector args) { } } + if (fp16) + image = image.ConvertToFormat(PixelFormat::Half); + if (!image.Write(outFile, outMetadata)) return 1; From 9939f8672a7964e6c0a32043d21d0baa30a7b792 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 28 Jan 2023 07:13:28 -0800 Subject: [PATCH 103/149] Add user's guide and file format links to README.md (Issue #320) --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 54320e063..0454dda15 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,12 @@ system will be useful to some people in its current form and that any bugs in the current implementation might be found now, allowing us to correct them before the book is final. -A number of scenes for pbrt-v4 are [available in a git -repository](https://github.com/mmp/pbrt-v4-scenes). +Resources +--------- + +* A number of scenes for pbrt-v4 are [available in a git repository](https://github.com/mmp/pbrt-v4-scenes). +* The [pbrt-v4 User's Guide](https://pbrt.org/users-guide-v4.html). +* Documentation on the [pbrt-v4 Scene Description Format](https://pbrt.org/fileformat-v4.html). Features -------- From b1603296ce47e0c7e688674ea895e4e640cf3502 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 28 Jan 2023 07:30:08 -0800 Subject: [PATCH 104/149] Remove imgtool denoise It's not a very good denoiser and in any case is not described in the book. --- src/pbrt/cmd/imgtool.cpp | 249 --------------------------------------- 1 file changed, 249 deletions(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 5e91fe267..0d3aeff40 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -138,14 +138,6 @@ static std::map commandUsage = { --outfile Filename to use for saving an image that encodes the absolute value of per-pixel differences. --reference Filename for reference image -)")}}, - {"denoise", - {"denoise [options] ", - "Applies a simple denoising algorithm to the provided image.\n" - " The image should be a multi-channel EXR as generated by pbrt's\n" - " \"gbuffer\" film.", - std::string(R"( options: - --outfile Filename to use for the denoised image. )")}}, #ifdef PBRT_BUILD_GPU_RENDERER {"denoise-optix", @@ -2226,245 +2218,6 @@ int makeequiarea(std::vector args) { return 0; } -Image denoiseImage(const Image &in, const ImageChannelDesc &Ldesc, - const Image &varianceImage, const ImageChannelDesc &albedoDesc, - const ImageChannelDesc &zDesc, const ImageChannelDesc &deltaZDesc, - const ImageChannelDesc &nDesc, int halfWidth, int nLevels) { - Image illum(PixelFormat::Float, in.Resolution(), {"R", "G", "B"}); - for (int y = 0; y < in.Resolution().y; ++y) - for (int x = 0; x < in.Resolution().x; ++x) { - ImageChannelValues albedo = in.GetChannels({x, y}, albedoDesc); - ImageChannelValues L = in.GetChannels({x, y}, Ldesc); - for (int c = 0; c < 3; ++c) - if (albedo[c] > 0) - illum.SetChannel({x, y}, c, L[c] / albedo[c]); - else - illum.SetChannel({x, y}, c, L[c]); - } - - std::vector f(halfWidth + 1, 0.); - for (int i = 0; i <= halfWidth; ++i) - f[i] = FastExp(-Float(i) / halfWidth * 3.f); - - static int call = -1; - ++call; - - Image currentImage = std::move(illum); - for (int i = 0; i < nLevels; ++i) { - int delta = 1 << i; // A-Trous step between samples. - - Image filtered(PixelFormat::Float, in.Resolution(), {"R", "G", "B"}); - // Image wImage(PixelFormat::Float, in.Resolution(), 3, "Wp,Wn,Wc"); - // Image dzImage(PixelFormat::Float, in.Resolution(), 1, "Y"); - - ParallelFor(0, currentImage.Resolution().y, [&](int64_t start, int64_t end) { - for (int y = start; y < end; ++y) { - for (int x = 0; x < currentImage.Resolution().x; ++x) { - float wsum = 0; - ImageChannelValues c = currentImage.GetChannels({x, y}); - - Float z = in.GetChannels({x, y}, zDesc); - // FIXME: hack multiply to cancel out scaled ray - // differentials... - Float dzdx = 8 * in.GetChannels({x, y}, deltaZDesc)[0]; - Float dzdy = 8 * in.GetChannels({x, y}, deltaZDesc)[1]; - - ImageChannelValues nChan = in.GetChannels({x, y}, nDesc); - Normal3f n = Normal3f(nChan[0], nChan[1], nChan[2]); - if (n == Normal3f(0, 0, 0)) - // background pixel - continue; - - Float pixelVariance = varianceImage.GetChannel({x, y}, 0); - float result[3] = {0.f}; - float wpSum = 0, wnSum = 0, wcSum = 0; - // if (pixelVariance > .001) { - // pixelVariance = std::max(pixelVariance, - // .000001); { - { - // Higher sigma -> more blur - // Float sigma_y = .05; - Float sigma_z = .005; - - // sigma_y = pixelVariance * 50; - // sigma_y = std::sqrt(std::sqrt(pixelVariance)) * - // 10 * sigmaYScale; - - for (int dy = -halfWidth * delta; dy <= halfWidth * delta; - dy += delta) { - if (y + dy < 0 || y + dy >= currentImage.Resolution().y) - continue; - for (int dx = -halfWidth * delta; dx <= halfWidth * delta; - dx += delta) { - if (x + dx < 0 || x + dx >= currentImage.Resolution().x) - continue; - ImageChannelValues co = - currentImage.GetChannels({x + dx, y + dy}); - Float dc2 = (Sqr(c[0] - co[0]) + Sqr(c[1] - co[1]) + - Sqr(c[2] - co[2])); // squared color - // difference - Float otherVariance = - varianceImage.GetChannel({x + dx, y + dy}, 0); - Float d2 = - std::max(0, dc2 - (pixelVariance + - std::min(pixelVariance, - otherVariance))) / - (1e-4 + 0.36f * (pixelVariance + otherVariance)); - - Float zo = in.GetChannels({x + dx, y + dy}, zDesc); - ImageChannelValues noChan = - in.GetChannels({x + dx, y + dy}, nDesc); - Normal3f no = Normal3f(noChan[0], noChan[1], noChan[2]); - if (no == Normal3f(0, 0, 0)) - // background pixel; - continue; - - Float zp = z + dx * dzdx + dy * dzdy; - Float dz = (zo - zp) / ((zo + zp) * 0.5f); - - // Assume camera space position... - Float wp = Gaussian(dz, 0, sigma_z) * - f[std::abs(dy / delta)] * - f[std::abs(dx / delta)]; - Float wn = Pow<32>(std::max(0, Dot(n, no))); - Float wc = - FastExp(-d2 / 90); // Gaussian(dc, 0, sigma_y); - CHECK(!std::isnan(wc)); - wpSum += wp; - wnSum += wn; - wcSum += wc; - Float w = wp * wn * wc; - - // CO fprintf(stderr, "(%d, %d) dc2 %f var - // %f other var %f -> d2 %f\n", CO x, y, - // dc2, pixelVariance, otherVariance, d2); - - CHECK(!std::isnan(w)); - if (w == 0) - continue; - - for (int c = 0; c < 3; ++c) { - result[c] += - w * currentImage.GetChannel({x + dx, y + dy}, c); - CHECK(!std::isnan(result[c])); - } - wsum += w; - } - } - } - for (int c = 0; c < 3; ++c) - if (wsum > 0) { - filtered.SetChannel({x, y}, c, result[c] / wsum); - // wImage.SetChannels({x, y}, {wpSum, wnSum, - // wcSum}); - } else - filtered.SetChannel({x, y}, c, - currentImage.GetChannel({x, y}, c)); - } - } - }); - - // filtered.Write(StringPrintf("filtered-%d-%d.exr", call, i)); - // wImage.Write(StringPrintf("weights%d.exr", i)); - // if (i == 0) - // dzImage.Write("dz.exr"); - - pstd::swap(filtered, currentImage); - } - - // static int i = 0; - // currentImage.Write(StringPrintf("filteredillum-%d.exr", i++)); - - // reincorporate albedo - for (int y = 0; y < currentImage.Resolution().y; ++y) - for (int x = 0; x < currentImage.Resolution().x; ++x) { - ImageChannelValues albedo = in.GetChannels({x, y}, albedoDesc); - for (int c = 0; c < 3; ++c) - currentImage.SetChannel({x, y}, c, - currentImage.GetChannel({x, y}, c) * albedo[c]); - } - - return currentImage; -} - -int denoise(std::vector args) { - std::string inFilename, outFilename; - - auto onError = [](const std::string &err) { - usage("denoise", "%s", err.c_str()); - exit(1); - }; - for (auto iter = args.begin(); iter != args.end(); ++iter) { - if (ParseArg(&iter, args.end(), "outfile", &outFilename, onError)) { - // success - } else if ((*iter)[0] == '-') - usage("denoise", "%s: unknown command flag", iter->c_str()); - else if (inFilename.empty()) { - inFilename = *iter; - } else - usage("denoise", "multiple input filenames provided."); - } - if (inFilename.empty()) - usage("denoise", "input image filename must be provided."); - if (outFilename.empty()) - usage("denoise", "output image filename must be provided."); - - ImageAndMetadata im = Image::Read(inFilename); - Image &in = im.image; - - auto checkForChannels = [&inFilename](ImageChannelDesc &desc, const char *names) { - if (!desc) { - Error("%s: didn't find \"%s\" channels.", inFilename, names); - exit(1); - } - }; - ImageChannelDesc rgbDesc = in.GetChannelDesc({"R", "G", "B"}); - checkForChannels(rgbDesc, "R,G,B"); - ImageChannelDesc zDesc = in.GetChannelDesc({"Pz"}); - checkForChannels(zDesc, "Pz"); - ImageChannelDesc deltaZDesc = in.GetChannelDesc({"dzdx", "dzdy"}); - checkForChannels(deltaZDesc, "dzdx,dzdy"); - ImageChannelDesc nDesc = in.GetChannelDesc({"Nx", "Ny", "Nz"}); - checkForChannels(nDesc, "Nx,Ny,Nz"); - ImageChannelDesc nsDesc = in.GetChannelDesc({"Nsx", "Nsy", "Nsz"}); - checkForChannels(nsDesc, "Nsx,Nsy,Nsz"); - ImageChannelDesc albedoDesc = in.GetChannelDesc({"Albedo.R", "Albedo.G", "Albedo.B"}); - checkForChannels(albedoDesc, "Albedo.R,Albedo.G,Albedo.B"); - ImageChannelDesc varianceDesc = in.GetChannelDesc({"Variance.R", "Variance.G", "Variance.B"}); - checkForChannels(varianceDesc, "Variance.R,Variance.G,Variance.B"); - - ImageChannelDesc jointDesc = in.GetChannelDesc({"Pz", "Nx", "Ny", "Nz"}); - ImageChannelValues jointSigmaIndir(4, 1); - Float xySigmaIndir[2] = {2.f, 2.f}; - Image filteredVariance = in.JointBilateralFilter(varianceDesc, 7, xySigmaIndir, - jointDesc, jointSigmaIndir); - - int halfWidth = 3; - int nLevels = 3; - Image denoisedImage = denoiseImage(in, rgbDesc, filteredVariance, albedoDesc, zDesc, - deltaZDesc, nsDesc, halfWidth, nLevels); - - Image result(PixelFormat::Float, in.Resolution(), {"R", "G", "B"}); - for (int y = 0; y < in.Resolution().y; ++y) - for (int x = 0; x < in.Resolution().x; ++x) { - ImageChannelValues Ldenoised = denoisedImage.GetChannels({x, y}); - for (int c = 0; c < 3; ++c) - result.SetChannel({x, y}, c, Ldenoised[c]); - } - - ImageMetadata outMetadata; - outMetadata.cameraFromWorld = im.metadata.cameraFromWorld; - outMetadata.NDCFromWorld = im.metadata.NDCFromWorld; - outMetadata.pixelBounds = im.metadata.pixelBounds; - outMetadata.fullResolution = im.metadata.fullResolution; - outMetadata.colorSpace = im.metadata.colorSpace; - - if (!result.Write(outFilename, outMetadata)) - return 1; - - return 0; -} - #ifdef PBRT_BUILD_GPU_RENDERER int denoise_optix(std::vector args) { std::string inFilename, outFilename; @@ -2597,8 +2350,6 @@ int main(int argc, char *argv[]) { return convert(args); else if (cmd == "diff") return diff(args); - else if (cmd == "denoise") - return denoise(args); #ifdef PBRT_BUILD_GPU_RENDERER else if (cmd == "denoise-optix") return denoise_optix(args); From 297ea2e9f3d5322059be2567803d7bbccde98834 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 28 Jan 2023 07:47:56 -0800 Subject: [PATCH 105/149] Warn if a spectrum is specified that is non-zero at a single wavelength. Issue #308. --- src/pbrt/paramdict.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pbrt/paramdict.cpp b/src/pbrt/paramdict.cpp index 4024fb1fc..61e9939d9 100644 --- a/src/pbrt/paramdict.cpp +++ b/src/pbrt/paramdict.cpp @@ -417,6 +417,10 @@ std::vector ParameterDictionary::extractSpectrumArray( ErrorExit(¶m.loc, "Found odd number of values for \"%s\"", param.name); int nSamples = param.floats.size() / 2; + if (nSamples == 1) { + Warning(¶m.loc, "Specified spectrum is only non-zero at a single wavelength. " + "This is probably unintended."); + } return returnArray( param.floats, param, param.floats.size(), [this, nSamples, &alloc, param](const Float *v, From 5e69feb538568363309c8e6b19ff67dd650e3c9a Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Mon, 20 Mar 2023 13:11:00 +0100 Subject: [PATCH 106/149] Silent build warnings about deprecated 'snprintf' This directive silences many annoying and perhaps unused warning messages under MacOS arm64 about that a few of printf's are now deprecated --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b717d8b9d..949bd0c22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,9 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL Linux) else () message (SEND_ERROR "Unknown system name: " + CMAKE_SYSTEM_NAME) endif() - +if (CMAKE_SYSTEM_NAME STREQUAL Darwin) + add_definitions(-Wno-deprecated-declarations) # silent deprecated 'snprintf' message under MacOS arm64 +endif() # libgoogle-perftools-dev find_library (PROFILE_LIB profiler) if (NOT PROFILE_LIB) From 5d559de47d703978fad2a1d99dc36c2df8e5af90 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 2 Apr 2023 06:29:27 -0700 Subject: [PATCH 107/149] Fix #if 0'd code for single grid-wide majorants --- src/pbrt/media.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/media.cpp b/src/pbrt/media.cpp index 5f88a9928..0b170414e 100644 --- a/src/pbrt/media.cpp +++ b/src/pbrt/media.cpp @@ -545,7 +545,7 @@ NanoVDBMedium::NanoVDBMedium(const Transform &renderFromMedium, Spectrum sigma_a majorantGridRes = Point3i(1, 1, 1); Float minDensity, maxDensity; densityFloatGrid->tree().extrema(minDensity, maxDensity); - majorantGrid.push_back(maxDensity); + majorantGrid.Set(0, 0, 0, maxDensity); #else LOG_VERBOSE("Starting nanovdb grid GetMaxDensityGrid()"); From b939189eff2998925151b96d59742ff37f751928 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 2 Apr 2023 06:29:42 -0700 Subject: [PATCH 108/149] Update github actions GPU builds Use the latest CUDA and OptiX releases, prune some old ones. The OptiX 7.7 build should fail, per bug #731... --- .github/workflows/ci-gpu.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index df270825b..18e66b7b5 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -15,8 +15,8 @@ jobs: strategy: fail-fast: false matrix: - optix: [ optix-7.1.0, optix-7.2.0, optix-7.3.0, optix-7.4.0 optix-7.5.0 ] - cuda: [ '11.2.2', '11.4.3', '11.5.2', '11.6.1', '11.7.0' ] # 11.3.0 fails for unclear reasons + optix: [ optix-7.3.0, optix-7.4.0 optix-7.5.0, optix-7.7.0 ] + cuda: [ '11.5.2', '11.6.1', '11.7.0', '12.1.0' ] # 11.3.0 fails for unclear reasons os: [ ubuntu-20.04, windows-latest ] name: GPU Build Only (${{ matrix.os }}, CUDA ${{ matrix.cuda }}, ${{ matrix.optix }}) @@ -24,7 +24,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: jimver/cuda-toolkit@v0.2.6 + - uses: jimver/cuda-toolkit@v0.2.10 id: cuda-toolkit with: cuda: ${{ matrix.cuda }} @@ -77,3 +77,12 @@ jobs: - name: Build # We need to limit the number of jobs so that it doesn't OOM run: cmake --build build --parallel 3 --config Release + + - name: Save Windows executable + if: ${{ matrix.os == 'windows-latest' }} + uses: actions/upload-artifact@v3 + with: + name: pbrt.exe + path: pbrt.exe + + From 1b3521b4dd0c63a3d183222e86e25ae17b110ec2 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 2 Apr 2023 06:45:00 -0700 Subject: [PATCH 109/149] Fix Optix 7.7 build Fixes issue #331. --- src/pbrt/gpu/aggregate.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index fd5785007..5428a5f90 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -1061,7 +1061,11 @@ OptixModule OptiXAggregate::createOptiXModule(OptixDeviceContext optixContext, char log[4096]; size_t logSize = sizeof(log); OptixModule optixModule; +#if (OPTIX_VERSION >= 70700) + OPTIX_CHECK_WITH_LOG(optixModuleCreate( +#else OPTIX_CHECK_WITH_LOG(optixModuleCreateFromPTX( +#endif optixContext, &moduleCompileOptions, &pipelineCompileOptions, ptx, strlen(ptx), log, &logSize, &optixModule), log); @@ -1253,11 +1257,13 @@ OptiXAggregate::OptiXAggregate( OptixPipelineLinkOptions pipelineLinkOptions = {}; pipelineLinkOptions.maxTraceDepth = 2; +#if (OPTIX_VERSION < 70700) #ifndef NDEBUG pipelineLinkOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL; #else pipelineLinkOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE; #endif +#endif // OPTIX_VERSION OPTIX_CHECK_WITH_LOG( optixPipelineCreate(optixContext, &pipelineCompileOptions, &pipelineLinkOptions, From a2bd4c8850d06e4e5a5440677b90fc304a292e5d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 3 Apr 2023 11:53:41 -0700 Subject: [PATCH 110/149] Stop using unified memory for vertices/indices passed into the Optix BVH builder. Will hopefully fix issue #329. --- src/pbrt/gpu/aggregate.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index 5428a5f90..c60f2ea93 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -453,13 +453,21 @@ OptiXAggregate::BVH OptiXAggregate::buildBVHForTriangles( input.triangleArray.vertexFormat = OPTIX_VERTEX_FORMAT_FLOAT3; input.triangleArray.vertexStrideInBytes = sizeof(Point3f); input.triangleArray.numVertices = mesh->nVertices; - pDeviceDevicePtrs[meshIndex] = CUdeviceptr(mesh->p); + Point3f *pGPU; + CUDA_CHECK(cudaMalloc(&pGPU, mesh->nVertices * sizeof(Point3f))); + CUDA_CHECK(cudaMemcpy(pGPU, mesh->p, mesh->nVertices * sizeof(Point3f), + cudaMemcpyHostToDevice)); + pDeviceDevicePtrs[meshIndex] = CUdeviceptr(pGPU); input.triangleArray.vertexBuffers = &pDeviceDevicePtrs[meshIndex]; input.triangleArray.indexFormat = OPTIX_INDICES_FORMAT_UNSIGNED_INT3; input.triangleArray.indexStrideInBytes = 3 * sizeof(int); input.triangleArray.numIndexTriplets = mesh->nTriangles; - input.triangleArray.indexBuffer = CUdeviceptr(mesh->vertexIndices); + int *indicesGPU; + CUDA_CHECK(cudaMalloc(&indicesGPU, mesh->nTriangles * 3 * sizeof(int))); + CUDA_CHECK(cudaMemcpy(indicesGPU, mesh->vertexIndices, mesh->nTriangles * 3 * sizeof(int), + cudaMemcpyHostToDevice)); + input.triangleArray.indexBuffer = CUdeviceptr(indicesGPU); FloatTexture alphaTexture = getAlphaTexture(shape, floatTextures, alloc); Material material = getMaterial(shape, namedMaterials, materials); From dfaaa6f3c1106d84bf64b18b722228261b0c7321 Mon Sep 17 00:00:00 2001 From: Philip Degarmo Date: Mon, 3 Apr 2023 13:29:02 -0700 Subject: [PATCH 111/149] Address compile issue with macro expansion for using optixModuleCreate or optixModuleCreateFromPTX --- src/pbrt/gpu/aggregate.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index c60f2ea93..8f067422b 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -1069,14 +1069,21 @@ OptixModule OptiXAggregate::createOptiXModule(OptixDeviceContext optixContext, char log[4096]; size_t logSize = sizeof(log); OptixModule optixModule; + #if (OPTIX_VERSION >= 70700) - OPTIX_CHECK_WITH_LOG(optixModuleCreate( +#define OPTIX_MODULE_CREATE_FN optixModuleCreate #else - OPTIX_CHECK_WITH_LOG(optixModuleCreateFromPTX( +#define OPTIX_MODULE_CREATE_FN optixModuleCreateFromPTX #endif - optixContext, &moduleCompileOptions, &pipelineCompileOptions, - ptx, strlen(ptx), log, &logSize, &optixModule), - log); + + OPTIX_CHECK_WITH_LOG( + OPTIX_MODULE_CREATE_FN( + optixContext, &moduleCompileOptions, &pipelineCompileOptions, + ptx, strlen(ptx), log, &logSize, &optixModule + ), + log + ); + LOG_VERBOSE("%s", log); return optixModule; From 4a668cc1378abbe0ebefd09a1d22b1ce354d88a1 Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Sat, 15 Apr 2023 20:03:54 +0200 Subject: [PATCH 112/149] Silent warning in VDB dependecies Silence a MSVC warning 4146 caused by NanoVDB code when a unary minus operator is applied to an unsigned type. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 949bd0c22..a3cd9e467 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,7 @@ target_compile_options ( "$<$:$<$:SHELL:-Xcompiler >/wd26451>" # arithmetic on 4-byte value, then cast to 8-byte "$<$:$<$:SHELL:-Xcompiler >/wd26495>" # uninitialized member variable "$<$:$<$:SHELL:-Xcompiler >/wd4334>" # 32 to 64 bit displacement + "$<$:$<$:SHELL:-Xcompiler >/wd4146>" # NanoVDB: unary minus operator applied to unsigned type, result still unsigned ) add_library (pbrt_opt INTERFACE) From 8a51bc04fe0eda5a899313aea62128ce7000c96a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 21 Apr 2023 04:59:59 -0700 Subject: [PATCH 113/149] Fix SampleHenyeyGreenstein to not generate NaNs with |g| \approx 1. Issue #333. --- src/pbrt/util/sampling.cpp | 8 ++++++++ src/pbrt/util/sampling_test.cpp | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/pbrt/util/sampling.cpp b/src/pbrt/util/sampling.cpp index 6dfacd65d..4b8683697 100644 --- a/src/pbrt/util/sampling.cpp +++ b/src/pbrt/util/sampling.cpp @@ -345,6 +345,14 @@ Point2f InvertSphericalRectangleSample(Point3f pRef, Point3f s, Vector3f ex, Vec } Vector3f SampleHenyeyGreenstein(Vector3f wo, Float g, Point2f u, Float *pdf) { + // When g \approx -1 and u[0] \approx 0 or with g \approx 1 and u[0] + // \approx 1, the computation of cosTheta below is unstable and can + // give, leading to NaNs. For now we limit g to the range where it is + // still ok; it would be nice to come up with a numerically robust + // rewrite of the computation instead, but with |g| \approx 1, the + // sampling distribution has a very sharp turn to deal with. + g = Clamp(g, -.99, .99); + // Compute $\cos\theta$ for Henyey--Greenstein sample Float cosTheta; if (std::abs(g) < 1e-3f) diff --git a/src/pbrt/util/sampling_test.cpp b/src/pbrt/util/sampling_test.cpp index 92c9dd596..4cdfa798a 100644 --- a/src/pbrt/util/sampling_test.cpp +++ b/src/pbrt/util/sampling_test.cpp @@ -1315,3 +1315,15 @@ TEST(SummedArea, NonCellAligned) { } } } + +TEST(Sampling, HGExtremes) { + Float cosTheta; + + for (Float g : { -.999f, .999f, -1.f, 1.f }) { + for (Float u : { 0.f, OneMinusEpsilon }) { + Float pdf; + Vector3f w = SampleHenyeyGreenstein(Vector3f(0,0,-1), g, Point2f(u, 0.5), &pdf); + EXPECT_FALSE(w.HasNaN()); + } + } +} From 2f83c6a6c1dd2591ddc64010a62843e17eb1021d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 21 Apr 2023 05:11:06 -0700 Subject: [PATCH 114/149] Clamp g range in HenyeyGreenstein. Issue #333. --- src/pbrt/util/scattering.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pbrt/util/scattering.h b/src/pbrt/util/scattering.h index 8dc0239e1..ac8cf9b7e 100644 --- a/src/pbrt/util/scattering.h +++ b/src/pbrt/util/scattering.h @@ -47,6 +47,12 @@ PBRT_CPU_GPU inline bool Refract(Vector3f wi, Normal3f n, Float eta, Float *etap } PBRT_CPU_GPU inline Float HenyeyGreenstein(Float cosTheta, Float g) { + // The Henyey-Greenstein phase function isn't suitable for |g| \approx + // 1 so we clamp it before it becomes numerically instable. (It's an + // analogous situation to BSDFs: if the BSDF is perfectly specular, one + // should use one based on a Dirac delta distribution rather than a + // very smooth microfacet distribution...) + g = Clamp(g, -.99, .99); Float denom = 1 + Sqr(g) + 2 * g * cosTheta; return Inv4Pi * (1 - Sqr(g)) / (denom * SafeSqrt(denom)); } From 11be252af077e85d7f083e1a3255288a92d69d1a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 21 Apr 2023 05:29:15 -0700 Subject: [PATCH 115/149] Fix PBRT_FLOAT_AS_DOUBLE build break --- src/pbrt/util/sampling_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/util/sampling_test.cpp b/src/pbrt/util/sampling_test.cpp index 4cdfa798a..ce8217640 100644 --- a/src/pbrt/util/sampling_test.cpp +++ b/src/pbrt/util/sampling_test.cpp @@ -1320,7 +1320,7 @@ TEST(Sampling, HGExtremes) { Float cosTheta; for (Float g : { -.999f, .999f, -1.f, 1.f }) { - for (Float u : { 0.f, OneMinusEpsilon }) { + for (Float u : { Float(0), OneMinusEpsilon }) { Float pdf; Vector3f w = SampleHenyeyGreenstein(Vector3f(0,0,-1), g, Point2f(u, 0.5), &pdf); EXPECT_FALSE(w.HasNaN()); From d25f567176586d61ddb5154d179b1fa5546eacaa Mon Sep 17 00:00:00 2001 From: wuyakuma Date: Thu, 27 Apr 2023 16:26:08 +0800 Subject: [PATCH 116/149] LLDB DataFormatters for pbrt-v4 --- src/pbrt/pbrt_lldbdataformatters.py | 268 ++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 src/pbrt/pbrt_lldbdataformatters.py diff --git a/src/pbrt/pbrt_lldbdataformatters.py b/src/pbrt/pbrt_lldbdataformatters.py new file mode 100644 index 000000000..e5892244d --- /dev/null +++ b/src/pbrt/pbrt_lldbdataformatters.py @@ -0,0 +1,268 @@ +""" +LLDB Formatters + +1. Load Manually (everytime) + use lldb command 'command script import [PATH]/pbrt_lldbdataformatters.py' (without the quotes) + +2. Load Automatically (add to ~/.lldbinit) + 1) create ~/.lldbinit file if there isn't + 2) open ~/.lldbinit + 3) add 'command script import [PATH]/pbrt_lldbdataformatters.py' to the file (without the quotes) + 4) restart xcode +""" + +import lldb; +import lldb.formatters.Logger; + +# Uncomment this to debug +# lldb.formatters.Logger._lldb_formatters_debug_level=1 + +# TaggedPointer +# seems GetTemplateArgumentType() does work with Variadic Templates, have to parse them into list +class TaggedPointerSynthProvider: + def __init__(self, valobj, dirt): + logger = lldb.formatters.Logger.Logger() + self.valobj = valobj + typeName=self.valobj.GetTypeName() + leftBracket = typeName.find('<') + rightBracket = typeName.find('>') + packedTypes = typeName[leftBracket+1:rightBracket] + logger >> "PackedType: " + str(packedTypes) + self.type_strings = packedTypes.split(',') + logger >> "PackedTypeList: " + str(self.type_strings) + self.update() + + def has_children(self): + return True + + def num_children(self): + return 2 + + def get_child_index(self, name): + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 + + def get_child_at_index(self, index): + logger = lldb.formatters.Logger.Logger() + if index == 0: + return self.valobj.CreateValueFromExpression('tag', str(self.tag)) + if index == 1: + if self.tag > 0: + expr = '(' + self.type + '*)' + str(self.ptr) + logger >> 'expr ' + expr + return self.valobj.CreateValueFromExpression('ptr', expr) + else: + return self.valobj.CreateValueFromExpression('ptr', 'null') + return None + + def update(self): + bits = self.valobj.GetChildMemberWithName('bits').GetValueAsUnsigned() + self.tag = (bits & 0xFE00000000000000) >> 57 + if self.tag > 0 and self.tag <= len(self.type_strings): + self.type = self.type_strings[self.tag-1] + else: + self.type = 'void' + self.ptr = (bits& 0x01FFFFFFFFFFFFFF) + +# Optional +class OptionalSynthProvider: + def __init__(self, valobj, dirt): + self.valobj = valobj + self.update() + + def has_children(self): + return self.set.GetValueAsUnsigned() != 0 + + def num_children(self): + if self.set.GetValueAsUnsigned() == 0: + return 0 + else: + return 1 + + def get_child_index(self, name): + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 + + def get_child_at_index(self, index): + if index == 0: + expr = '*(' + self.type.GetName() + '*)' + str(self.ptr.GetValueAsUnsigned()) + return self.valobj.CreateValueFromExpression('ptr', str(expr)) + return None + + def update(self): + try: + self.set = self.valobj.GetChildMemberWithName('set') + self.type = self.extract_type() + self.ptr = self.valobj.GetChildMemberWithName('optionalValue').AddressOf() + except: + pass + + def extract_type(self): + arrayType = self.valobj.GetType().GetUnqualifiedType() + if arrayType.IsReferenceType(): + arrayType = arrayType.GetDereferencedType() + elif arrayType.IsPointerType(): + arrayType = arrayType.GetPointeeType() + if arrayType.GetNumberOfTemplateArguments() > 0: + elementType = arrayType.GetTemplateArgumentType(0) + else: + elementType = None + return elementType + +def OptionalSummaryProvider(valobj, internal_dict): + set = valobj.GetNumChildren() + if set: + return 'set' + return 'null' + + +# Span +class SpanSynthProvider: + def __init__(self, valobj, dirt): + self.valobj = valobj + self.update() + + def has_children(self): + return True + + def num_children(self): + return self.size + + def get_child_index(self, name): + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 + + def get_child_at_index(self, index): + if index < 0: + return None + if index >= self.num_children(): + return None + offset = index * self.type_size + return self.ptr.CreateChildAtOffset('['+str(index)+']', offset, self.date_type) + + def update(self): + self.size = self.valobj.GetChildMemberWithName('n').GetValueAsUnsigned() + self.ptr = self.valobj.GetChildMemberWithName('ptr') + valType = self.valobj.GetType() + if valType.IsReferenceType(): + valType = valType.GetDereferencedType() + self.date_type = valType.GetTemplateArgumentType(0) + self.type_size = self.date_type.GetByteSize() + +def SpanSummaryProvider(valobj, internal_dict): + length = valobj.GetNumChildren() + return 'size = %d' % length + + +# Array +class ArraySynthProvider: + def __init__(self, valobj, dirt): + self.valobj = valobj + self.update() + + def has_children(self): + return True + + def num_children(self): + return self.size + + def get_child_index(self, name): + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 + + def get_child_at_index(self, index): + if index < 0: + return None + if index >= self.num_children(): + return None + if self.data_type == None: + return None + offset = index * self.type_size + return self.values.CreateChildAtOffset('['+str(index)+']', offset, self.data_type) + + def update(self): + try: + self.values = self.valobj.GetChildMemberWithName('values') + valType = self.values.GetType() + if valType.IsReferenceType(): + valType = valType.GetDereferencedType() + if valType.IsArrayType(): + arraySize = valType.GetByteSize() + self.data_type = valType.GetArrayElementType() + self.type_size = self.data_type.GetByteSize() + self.size = arraySize/self.type_size + else: + self.data_type = None + self.type_size = 0 + self.size = 0 + except: + pass + +def ArraySummaryProvider(valobj, internal_dict): + length = valobj.GetNumChildren() + return 'size = %d' % length + +# Vector +class VectorSynthProvider: + def __init__(self, valobj, dirt): + self.valobj = valobj + self.update() + + def has_children(self): + return True + + def num_children(self): + return self.size.GetValueAsUnsigned() + + def get_child_index(self, name): + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 + + def get_child_at_index(self, index): + if index < 0: + return None + if index >= self.num_children(): + return None + if self.data_type == None: + return None + offset = index * self.type_size + return self.ptr.CreateChildAtOffset('['+str(index)+']', offset, self.data_type) + + def update(self): + try: + self.size = self.valobj.GetChildMemberWithName('nStored') + self.capacity = self.valobj.GetChildMemberWithName('nAlloc') + self.ptr = self.valobj.GetChildMemberWithName('ptr') + self.data_type = self.ptr.GetType() + if self.data_type.IsPointerType(): + self.data_type = self.data_type.GetPointeeType() + self.type_size = self.data_type.GetByteSize() + except: + pass + +def VectorSummaryProvider(valobj, internal_dict): + length = valobj.GetNumChildren() + return 'size = %d' % length + + +def __lldb_init_module(debugger, internal_dict): + debugger.HandleCommand('type synthetic add -l pbrt_lldbdataformatters.TaggedPointerSynthProvider -x "^pbrt::TaggedPointer<.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type synthetic add -l pbrt_lldbdataformatters.OptionalSynthProvider -x "^pstd::optional<.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type summary add -F pbrt_lldbdataformatters.OptionalSummaryProvider -e -x "^pstd::optional<.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type synthetic add -l pbrt_lldbdataformatters.SpanSynthProvider -x "^pstd::span<.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type summary add -F pbrt_lldbdataformatters.SpanSummaryProvider -e -x "^pstd::span<.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type synthetic add -l pbrt_lldbdataformatters.ArraySynthProvider -x "^pstd::array<.+,.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type summary add -F pbrt_lldbdataformatters.ArraySummaryProvider -e -x "^pstd::array<.+,.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type synthetic add -l pbrt_lldbdataformatters.VectorSynthProvider -x "^pstd::vector<.+,.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand('type summary add -F pbrt_lldbdataformatters.VectorSummaryProvider -e -x "^pstd::vector<.+,.+>$" -w pbrt_lldbdataformatters') + debugger.HandleCommand("type category enable pbrt_lldbdataformatters") From e86038eb00fec40301c4a3ca5cab0062eea1e05b Mon Sep 17 00:00:00 2001 From: Hannes Vernooij Date: Tue, 2 May 2023 17:06:05 +0200 Subject: [PATCH 117/149] Take incident IOR into account for the CoatedConductorMaterial This takes the incident index of refraction into account when setting the relative index of refraction for coated conductors. --- src/pbrt/materials.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index 82f1cf1f8..14b05e11a 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -364,8 +364,8 @@ CoatedConductorBxDF CoatedConductorMaterial::GetBxDF(TextureEvaluator texEval, SampledSpectrum ce, ck; if (conductorEta) { - ce = texEval(conductorEta, ctx, lambda); - ck = texEval(k, ctx, lambda); + ce = texEval(conductorEta, ctx, lambda) / ieta; + ck = texEval(k, ctx, lambda) / ieta; } else { // Avoid r==0 NaN case... SampledSpectrum r = Clamp(texEval(reflectance, ctx, lambda), 0, .9999); From 638c2be0f818b7e929dac9aacbd054779d1fcd31 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 3 May 2023 10:01:16 -0700 Subject: [PATCH 118/149] Fix host/device function call warning --- src/pbrt/materials.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/materials.h b/src/pbrt/materials.h index 4651e60f1..7e65707da 100644 --- a/src/pbrt/materials.h +++ b/src/pbrt/materials.h @@ -910,7 +910,7 @@ inline BSDF Material::GetBSDF(TextureEvaluator texEval, MaterialEvalContext ctx, } }; - return Dispatch(getBSDF); + return DispatchCPU(getBSDF); } template @@ -934,7 +934,7 @@ inline BSSRDF Material::GetBSSRDF(TextureEvaluator texEval, MaterialEvalContext return BSSRDF(bssrdf); } }; - return Dispatch(get); + return DispatchCPU(get); } inline bool Material::HasSubsurfaceScattering() const { From 94cd09cbf04db63a13ae55b5a9ae9c690bac3cf0 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 5 May 2023 10:38:53 -0700 Subject: [PATCH 119/149] Update materials.cpp Moved the divides to also cover the case where it works backward to compute eta/k based on a user-specified reflectance. --- src/pbrt/materials.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index 14b05e11a..acd68982b 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -364,14 +364,16 @@ CoatedConductorBxDF CoatedConductorMaterial::GetBxDF(TextureEvaluator texEval, SampledSpectrum ce, ck; if (conductorEta) { - ce = texEval(conductorEta, ctx, lambda) / ieta; - ck = texEval(k, ctx, lambda) / ieta; + ce = texEval(conductorEta, ctx, lambda); + ck = texEval(k, ctx, lambda); } else { // Avoid r==0 NaN case... SampledSpectrum r = Clamp(texEval(reflectance, ctx, lambda), 0, .9999); ce = SampledSpectrum(1.f); ck = 2 * Sqrt(r) / Sqrt(ClampZero(SampledSpectrum(1) - r)); } + ce /= ieta; + ck /= ieta; Float curough = texEval(conductorURoughness, ctx); Float cvrough = texEval(conductorVRoughness, ctx); From 02f607852d623f1213c973d80c98a9a4132cc842 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 10 May 2023 10:26:42 -0700 Subject: [PATCH 120/149] Fix comment --- src/pbrt/materials.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index acd68982b..1d1e6f060 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -367,7 +367,7 @@ CoatedConductorBxDF CoatedConductorMaterial::GetBxDF(TextureEvaluator texEval, ce = texEval(conductorEta, ctx, lambda); ck = texEval(k, ctx, lambda); } else { - // Avoid r==0 NaN case... + // Avoid r==1 NaN case... SampledSpectrum r = Clamp(texEval(reflectance, ctx, lambda), 0, .9999); ce = SampledSpectrum(1.f); ck = 2 * Sqrt(r) / Sqrt(ClampZero(SampledSpectrum(1) - r)); From b8a7238e24bcdde8105cbf6a48e40bf72d9e1c8f Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 10 May 2023 10:29:31 -0700 Subject: [PATCH 121/149] Polish up SampledGrid interface Make capitalization consistent for the [XYZ]Size() methods. Add PBRT_CPU_GPU to those as well as to BytesAllocated(). --- src/pbrt/util/containers.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pbrt/util/containers.h b/src/pbrt/util/containers.h index a6d573499..bd8fe2aef 100644 --- a/src/pbrt/util/containers.h +++ b/src/pbrt/util/containers.h @@ -773,10 +773,10 @@ class SampledGrid { CHECK_EQ(nx * ny * nz, values.size()); } - size_t BytesAllocated() const { return values.size() * sizeof(T); } - int XSize() const { return nx; } - int YSize() const { return ny; } - int zSize() const { return nz; } + PBRT_CPU_GPU size_t BytesAllocated() const { return values.size() * sizeof(T); } + PBRT_CPU_GPU int XSize() const { return nx; } + PBRT_CPU_GPU int YSize() const { return ny; } + PBRT_CPU_GPU int ZSize() const { return nz; } const_iterator begin() const { return values.begin(); } const_iterator end() const { return values.end(); } From d4dc2008bf244105f6ec9104e467b2ee897933d5 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 10 May 2023 10:36:07 -0700 Subject: [PATCH 122/149] Add temperature scale and offset controls to GridMedium --- src/pbrt/media.cpp | 14 +++++++++++--- src/pbrt/media.h | 9 ++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/pbrt/media.cpp b/src/pbrt/media.cpp index 0b170414e..990f57e54 100644 --- a/src/pbrt/media.cpp +++ b/src/pbrt/media.cpp @@ -212,8 +212,9 @@ STAT_MEMORY_COUNTER("Memory/Volume grids", volumeGridBytes); GridMedium::GridMedium(const Bounds3f &bounds, const Transform &renderFromMedium, Spectrum sigma_a, Spectrum sigma_s, Float sigmaScale, Float g, SampledGrid d, - pstd::optional> temperature, Spectrum Le, - SampledGrid LeGrid, Allocator alloc) + pstd::optional> temperature, + Float temperatureScale, Float temperatureOffset, + Spectrum Le, SampledGrid LeGrid, Allocator alloc) : bounds(bounds), renderFromMedium(renderFromMedium), sigma_a_spec(sigma_a, alloc), @@ -221,6 +222,8 @@ GridMedium::GridMedium(const Bounds3f &bounds, const Transform &renderFromMedium densityGrid(std::move(d)), phase(g), temperatureGrid(std::move(temperature)), + temperatureScale(temperatureScale), + temperatureOffset(temperatureOffset), Le_spec(Le, alloc), LeScale(std::move(LeGrid)), majorantGrid(bounds, {16, 16, 16}, alloc) { @@ -316,9 +319,14 @@ GridMedium *GridMedium::Create(const ParameterDictionary ¶meters, sigma_s = alloc.new_object(1.f); Float sigmaScale = parameters.GetOneFloat("scale", 1.f); + Float temperatureOffset = parameters.GetOneFloat("temperatureoffset", + parameters.GetOneFloat("temperaturecutoff", 0.f)); + Float temperatureScale = parameters.GetOneFloat("temperaturescale", 1.f); + return alloc.new_object( Bounds3f(p0, p1), renderFromMedium, sigma_a, sigma_s, sigmaScale, g, - std::move(densityGrid), std::move(temperatureGrid), Le, std::move(LeGrid), alloc); + std::move(densityGrid), std::move(temperatureGrid), temperatureScale, + temperatureOffset, Le, std::move(LeGrid), alloc); } std::string GridMedium::ToString() const { diff --git a/src/pbrt/media.h b/src/pbrt/media.h index fdf88418e..19abb9873 100644 --- a/src/pbrt/media.h +++ b/src/pbrt/media.h @@ -271,6 +271,7 @@ class GridMedium { GridMedium(const Bounds3f &bounds, const Transform &renderFromMedium, Spectrum sigma_a, Spectrum sigma_s, Float sigmaScale, Float g, SampledGrid density, pstd::optional> temperature, + Float temperatureScale, Float temperatureOffset, Spectrum Le, SampledGrid LeScale, Allocator alloc); static GridMedium *Create(const ParameterDictionary ¶meters, @@ -303,7 +304,12 @@ class GridMedium { // Compute emitted radiance using _temperatureGrid_ or _Le_spec_ if (temperatureGrid) { Float temp = temperatureGrid->Lookup(p); - Le = scale * BlackbodySpectrum(temp).Sample(lambda); + // Added after book publication: optionally offset and scale + // temperature based on user-supplied parameters. (Match + // NanoVDBMedium functionality.) + temp = (temp - temperatureOffset) * temperatureScale; + if (temp > 100.f) + Le = scale * BlackbodySpectrum(temp).Sample(lambda); } else Le = scale * Le_spec.Sample(lambda); } @@ -341,6 +347,7 @@ class GridMedium { DenselySampledSpectrum Le_spec; SampledGrid LeScale; bool isEmissive; + Float temperatureScale, temperatureOffset; MajorantGrid majorantGrid; }; From d250ece5d530df30de9777e651201117650cb07d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 12 May 2023 05:30:54 -0700 Subject: [PATCH 123/149] Add nanovdb2pbrt utility. Basic converter from nanovdb to pbrt's text format for volumes, including support for downsampling. --- CMakeLists.txt | 17 ++++ src/pbrt/cmd/nanovdb2pbrt.cpp | 173 ++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 src/pbrt/cmd/nanovdb2pbrt.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a3cd9e467..a8d8d0326 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1004,6 +1004,23 @@ add_sanitizers (plytool) set_property (TARGET plytool PROPERTY FOLDER "cmd") +###################### +# nanovdb2pbrt + +add_executable (nanovdb2pbrt src/pbrt/cmd/nanovdb2pbrt.cpp) +add_executable (pbrt::nanovdb2pbrt ALIAS nanovdb2pbrt) + +target_compile_definitions (nanovdb2pbrt PRIVATE ${PBRT_DEFINITIONS}) +target_compile_options (nanovdb2pbrt PUBLIC ${PBRT_CXX_FLAGS}) +target_include_directories (nanovdb2pbrt PUBLIC src src/ext) +target_link_libraries (nanovdb2pbrt PRIVATE ${ALL_PBRT_LIBS} pbrt_warnings pbrt_opt) + +set_target_properties (nanovdb2pbrt PROPERTIES OUTPUT_NAME nanovdb2pbrt) + +add_sanitizers (nanovdb2pbrt) + +set_property (TARGET nanovdb2pbrt PROPERTY FOLDER "cmd") + ###################### # cyhair2pbrt diff --git a/src/pbrt/cmd/nanovdb2pbrt.cpp b/src/pbrt/cmd/nanovdb2pbrt.cpp new file mode 100644 index 000000000..af970f92c --- /dev/null +++ b/src/pbrt/cmd/nanovdb2pbrt.cpp @@ -0,0 +1,173 @@ +// nanovdb2pbrt.cpp +// pbrt is Copyright(c) 1998-2023 Matt Pharr, Wenzel Jakob, and Greg Humphreys. +// The pbrt source code is licensed under the Apache License, Version 2.0. +// SPDX: Apache-2.0 + +#include + +#include +#include + +#include +#define NANOVDB_USE_ZIP 1 +#include +#include +#include + +#include +#include + +using namespace pbrt; + +template +static nanovdb::GridHandle readGrid(const std::string &filename, + const std::string &gridName, + Allocator alloc) { + NanoVDBBuffer buf(alloc); + nanovdb::GridHandle grid; + try { + grid = + nanovdb::io::readGrid(filename, gridName, 0 /* not verbose */, buf); + } catch (const std::exception &e) { + ErrorExit("nanovdb: %s: %s", filename, e.what()); + } + + if (grid) { + if (!grid.gridMetaData()->isFogVolume() && !grid.gridMetaData()->isUnknown()) + ErrorExit("%s: \"%s\" isn't a FogVolume grid?", filename, gridName); + + LOG_VERBOSE("%s: found %d \"%s\" voxels", filename, + grid.gridMetaData()->activeVoxelCount(), gridName); + } + + return grid; +} + +static void usage(const std::string &msg = {}) { + if (!msg.empty()) + fprintf(stderr, "nanovdb2pbrt: %s\n\n", msg.c_str()); + + fprintf(stderr, + R"(usage: nanovdb2pbrt [] + +Options: + --downsample Number of times to 2x downsample the volume. + Default: 0 + --grid Name of grid to extract. Default: "density" +)"); + exit(msg.empty() ? 0 : 1); +} + +int main(int argc, char *argv[]) { + std::vector args = GetCommandLineArguments(argv); + + auto onError = [](const std::string &err) { + usage(err); + exit(1); + }; + + std::string filename; + std::string grid = "density"; + int downsample = 0; + for (auto iter = args.begin(); iter != args.end(); ++iter) { + if ((*iter)[0] != '-') { + if (filename.empty()) + filename = *iter; + else { + usage(); + exit(1); + } + } else if (ParseArg(&iter, args.end(), "downsample", &downsample, onError) || + ParseArg(&iter, args.end(), "grid", &grid, onError)) { + // success + } else { + usage(); + exit(1); + } + } + + if (filename.empty()) + usage("must specify a nanovdb filename"); + + Allocator alloc; + nanovdb::GridHandle nanoGrid = + readGrid(filename, grid, alloc); + if (!nanoGrid) + ErrorExit("%s: didn't find \"%s\" grid.", filename, grid); + const nanovdb::FloatGrid *floatGrid = nanoGrid.grid(); + + nanovdb::BBox bbox = floatGrid->worldBBox(); + Bounds3f bounds(Point3f(bbox.min()[0], bbox.min()[1], bbox.min()[2]), + Point3f(bbox.max()[0], bbox.max()[1], bbox.max()[2])); + + int nx = floatGrid->indexBBox().dim()[0]; + int ny = floatGrid->indexBBox().dim()[1]; + int nz = floatGrid->indexBBox().dim()[2]; + + std::vector values; + + int z0 = 0, z1 = nz; + int y0 = 0, y1 = ny; + int x0 = 0, x1 = nx; + + // Fix the resolution to be a multiple of 2^downsample just to make + // downsampling easy. Chop off one at a time from the bottom and top + // of the range until we get there; the bounding box is updated as + // well so that the remaining volume doesn't shift spatially. + auto round = [=](int &low, int &high, Float &c0, Float &c1) { + Float delta = (c1-c0) / (high-low); + int mult = 1 << downsample; // want a multiple of this in resolution + while ((high - low) % mult) { + ++low; + c0 += delta; + if ((high - low) % mult) { + --high; + c1 -= delta; + } + } + return high - low; + }; + nz = round(z0, z1, bounds.pMin.z, bounds.pMax.z); + ny = round(y0, y1, bounds.pMin.y, bounds.pMax.y); + nx = round(x0, x1, bounds.pMin.x, bounds.pMax.x); + + for (int z = z0; z < z1; ++z) + for (int y = y0; y < y1; ++y) + for (int x = x0; x < x1; ++x) { + values.push_back(floatGrid->tree().getValue({x, y, z})); + } + + while (downsample > 0) { + std::vector v2; + for (int z = 0; z < nz/2; ++z) + for (int y = 0; y < ny/2; ++y) + for (int x = 0; x < nx/2; ++x) { + auto v = [&](int dx, int dy, int dz) -> Float{ + return values[(2*x+dx) + nx * ((2*y+dy) + ny * (2*z+dz))]; + }; + v2.push_back((v(0,0,0) + v(1,0,0) + v(0,1,0) + v(1,1,0) + + v(0,0,1) + v(1,0,1) + v(0,1,1) + v(1,1,1))/8); + } + + values = std::move(v2); + nx /= 2; + ny /= 2; + nz /= 2; + --downsample; + } + + printf("\"integer nx\" %d \"integer ny\" %d \"integer nz\" %d\n", nx, ny, nz); + printf("\t\"point3 p0\" [ %f %f %f ] \"point3 p1\" [ %f %f %f ]\n", + bounds.pMin.x, bounds.pMin.y, bounds.pMin.z, + bounds.pMax.x, bounds.pMax.y, bounds.pMax.z); + printf("\t\"float %s\" [\n", grid.c_str()); + for (int i = 0; i < values.size(); ++i) { + Float d = values[i]; + if (d == 0) printf("0 "); + else printf("%f ", d); + if ((i % 20) == 19) printf("\n"); + } + printf("]\n"); +} + + From c4baa534042e2ec4eb245924efbcef477e096389 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 12 May 2023 05:31:38 -0700 Subject: [PATCH 124/149] Fix CHECK in imgtool --- src/pbrt/cmd/imgtool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 0d3aeff40..1ddd5f857 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -646,7 +646,7 @@ int splitn(std::vector args) { result.SetChannels({x, y}, desc, {rgb.r, rgb.g, rgb.b}); }; - CHECK_LT(crops.size(), sizeof(edges) / sizeof(edges[0])); + CHECK_LE(crops.size(), sizeof(edges) / sizeof(edges[0])); ImageChannelDesc cropDesc = cropsImage.GetChannelDesc({"R", "G", "B"}); CHECK(bool(cropDesc)); From 73ad6bc42044531780e02298ba4cfe8303b0dc15 Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Mon, 5 Jun 2023 00:27:14 +0200 Subject: [PATCH 125/149] Fix fatal error on Hair material This change fix a error on Hair material when the upper value for 'beta_m' or 'beta_n' is greatest than 1.0 --- src/pbrt/materials.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pbrt/materials.h b/src/pbrt/materials.h index 7e65707da..2665c4a46 100644 --- a/src/pbrt/materials.h +++ b/src/pbrt/materials.h @@ -379,8 +379,8 @@ class HairMaterial { template PBRT_CPU_GPU HairBxDF GetBxDF(TextureEvaluator texEval, MaterialEvalContext ctx, SampledWavelengths &lambda) const { - Float bm = std::max(1e-2, texEval(beta_m, ctx)); - Float bn = std::max(1e-2, texEval(beta_n, ctx)); + Float bm = std::max(1e-2, std::min(1.0, texEval(beta_m, ctx))); + Float bn = std::max(1e-2, std::min(1.0, texEval(beta_n, ctx))); Float a = texEval(alpha, ctx); Float e = texEval(eta, ctx); From 869c5e059e45433906e7b2b786ce760aea5a5a4c Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Tue, 6 Jun 2023 07:33:06 +0800 Subject: [PATCH 126/149] fix broken url --- src/pbrt/util/math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/util/math.h b/src/pbrt/util/math.h index d54620d14..3574318a1 100644 --- a/src/pbrt/util/math.h +++ b/src/pbrt/util/math.h @@ -590,7 +590,7 @@ PBRT_CPU_GPU inline CompensatedFloat InnerProduct(Float a, Float b) { } // Accurate dot products with FMA: Graillat et al., -// http://rnc7.loria.fr/louvet_poster.pdf +// https://www-pequan.lip6.fr/~graillat/papers/posterRNC7.pdf // // Accurate summation, dot product and polynomial evaluation in complex // floating point arithmetic, Graillat and Menissier-Morain. From a8c78a266d0aaa2cd22b11d864683a7fcc9b29b7 Mon Sep 17 00:00:00 2001 From: pbrt4bounty <73945652+pbrt4bounty@users.noreply.github.com> Date: Thu, 15 Jun 2023 20:54:07 +0200 Subject: [PATCH 127/149] Update a few channels names for G-Buffer Updated some channel names in G-Buffer following the naming policy for EXR multilayer. --- src/pbrt/film.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pbrt/film.cpp b/src/pbrt/film.cpp index f1d21d187..df9c9dcba 100644 --- a/src/pbrt/film.cpp +++ b/src/pbrt/film.cpp @@ -696,17 +696,17 @@ Image GBufferFilm::GetImage(ImageMetadata *metadata, Float splatScale) { "Albedo.R", "Albedo.G", "Albedo.B", - "Px", - "Py", - "Pz", + "P.X", + "P.Y", + "P.Z", "dzdx", "dzdy", - "Nx", - "Ny", - "Nz", - "Nsx", - "Nsy", - "Nsz", + "N.X", + "N.Y", + "N.Z", + "Ns.X", + "Ns.Y", + "Ns.Z", "u", "v", "Variance.R", @@ -717,10 +717,10 @@ Image GBufferFilm::GetImage(ImageMetadata *metadata, Float splatScale) { "RelativeVariance.B"}); ImageChannelDesc rgbDesc = image.GetChannelDesc({"R", "G", "B"}); - ImageChannelDesc pDesc = image.GetChannelDesc({"Px", "Py", "Pz"}); + ImageChannelDesc pDesc = image.GetChannelDesc({"P.X", "P.Y", "P.Z"}); ImageChannelDesc dzDesc = image.GetChannelDesc({"dzdx", "dzdy"}); - ImageChannelDesc nDesc = image.GetChannelDesc({"Nx", "Ny", "Nz"}); - ImageChannelDesc nsDesc = image.GetChannelDesc({"Nsx", "Nsy", "Nsz"}); + ImageChannelDesc nDesc = image.GetChannelDesc({"N.X", "N.Y", "N.Z"}); + ImageChannelDesc nsDesc = image.GetChannelDesc({"Ns.X", "Ns.Y", "Ns.Z"}); ImageChannelDesc uvDesc = image.GetChannelDesc({"u", "v"}); ImageChannelDesc albedoRgbDesc = image.GetChannelDesc({"Albedo.R", "Albedo.G", "Albedo.B"}); From 7e97c2019804feded17a543aa4a12c5876ddef97 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 24 Jun 2023 14:23:04 -0700 Subject: [PATCH 128/149] Add missing parameter to StringPrintf in SubsurfaceMaterial::ToString() Fixes #358. --- src/pbrt/materials.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/materials.cpp b/src/pbrt/materials.cpp index 1d1e6f060..20c87b618 100644 --- a/src/pbrt/materials.cpp +++ b/src/pbrt/materials.cpp @@ -491,7 +491,7 @@ std::string SubsurfaceMaterial::ToString() const { return StringPrintf("[ SubsurfaceMaterial displacement: %s normalMap: %s scale: %f " "sigma_a: %s sigma_s: %s reflectance: %s mfp: %s uRoughness: %s " "vRoughness: %s scale: %f eta: %f remapRoughness: %s ]", - displacement, scale, sigma_a, sigma_s, reflectance, mfp, + displacement, normalMap, scale, sigma_a, sigma_s, reflectance, mfp, uRoughness, vRoughness, scale, eta, remapRoughness); } From a1418056390af0397c03f5954e4d5c07479b42b5 Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Mon, 3 Jul 2023 20:46:10 +0800 Subject: [PATCH 129/149] fix to print out debug information when cameraRay not generated --- src/pbrt/cpu/integrators.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index bbc0608c1..7aa146369 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -272,19 +272,17 @@ void RayIntegrator::EvaluatePixelSample(Point2i pPixel, int sampleIndex, Sampler L = SampledSpectrum(0.f); } - if (cameraRay) - PBRT_DBG( - "%s\n", - StringPrintf("Camera sample: %s -> ray %s -> L = %s, visibleSurface %s", - cameraSample, cameraRay->ray, L, - (visibleSurface ? visibleSurface.ToString() : "(none)")) - .c_str()); - else - PBRT_DBG("%s\n", - StringPrintf("Camera sample: %s -> no ray generated", cameraSample) - .c_str()); + PBRT_DBG( + "%s\n", + StringPrintf("Camera sample: %s -> ray %s -> L = %s, visibleSurface %s", + cameraSample, cameraRay->ray, L, + (visibleSurface ? visibleSurface.ToString() : "(none)")) + .c_str()); + } else { + PBRT_DBG("%s\n", + StringPrintf("Camera sample: %s -> no ray generated", cameraSample) + .c_str()); } - // Add camera ray's contribution to image camera.GetFilm().AddSample(pPixel, L, lambda, &visibleSurface, cameraSample.filterWeight); From f94d39f8d908752513104d815e66188f5585f446 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 5 Jul 2023 11:24:47 +0200 Subject: [PATCH 130/149] Update denoise_optix for changes to g-buffer channel naming (pr #356) --- src/pbrt/cmd/imgtool.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 1ddd5f857..6a57fdd44 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -2250,7 +2250,7 @@ int denoise_optix(std::vector args) { ImageChannelDesc desc[3] = { image.GetChannelDesc({"R", "G", "B"}), image.GetChannelDesc({"Albedo.R", "Albedo.G", "Albedo.B"}), - image.GetChannelDesc({"Nsx", "Nsy", "Nsz"})}; + image.GetChannelDesc({"Ns.X", "Ns.Y", "Ns.Z"})}; if (!desc[0]) { Error("%s: image doesn't have R, G, B channels.", inFilename); return 1; @@ -2262,10 +2262,14 @@ int denoise_optix(std::vector args) { nLayers = 1; } if (!desc[2]) { - Warning("%s: image doesn't have Nsx, Nsy, Nsz channels. " - "Denoising quality may suffer.", - inFilename); - nLayers = 1; + // Try the old naming scheme + desc[2] = image.GetChannelDesc({"Nsx", "Nsy", "Nsz"}); + if (!desc[2]) { + Warning("%s: image doesn't have Ns.X, Ns.Y, Ns.Z channels. " + "Denoising quality may suffer.", + inFilename); + nLayers = 1; + } } Denoiser denoiser((Vector2i)image.Resolution(), nLayers == 3); From 6150152c72f79ea9a8bcf03c5763785dccd84622 Mon Sep 17 00:00:00 2001 From: "Ka Wing, Li" <68145845+kingiler@users.noreply.github.com> Date: Wed, 5 Jul 2023 17:32:20 +0000 Subject: [PATCH 131/149] Fix displacement --- src/pbrt/util/mesh.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pbrt/util/mesh.h b/src/pbrt/util/mesh.h index db72e8f3f..95d3080fd 100644 --- a/src/pbrt/util/mesh.h +++ b/src/pbrt/util/mesh.h @@ -99,13 +99,15 @@ struct TriQuadMesh { outputMesh.ConvertToOnlyTriangles(); if (outputMesh.n.empty()) outputMesh.ComputeNormals(); + std::vector oldTriIndices(outputMesh.triIndices); outputMesh.triIndices.clear(); // Refine HashMap, int, HashIntPair> edgeSplit({}); - for (int i = 0; i < triIndices.size() / 3; ++i) - outputMesh.Refine(dist, maxDist, triIndices[3 * i], triIndices[3 * i + 1], - triIndices[3 * i + 2], edgeSplit); + for (int i = 0; i < oldTriIndices.size() / 3; ++i) + outputMesh.Refine(dist, maxDist, oldTriIndices[3 * i], + oldTriIndices[3 * i + 1], oldTriIndices[3 * i + 2], + edgeSplit); // Displace displace(outputMesh.p.data(), outputMesh.n.data(), outputMesh.uv.data(), From 8c7bf37b6c4d423abd24a8587455d035b17f0f2b Mon Sep 17 00:00:00 2001 From: Julian Amann Date: Wed, 5 Jul 2023 22:31:07 +0200 Subject: [PATCH 132/149] Fix spelling --- src/pbrt/util/noise.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/util/noise.cpp b/src/pbrt/util/noise.cpp index 5e66cb976..77373bea3 100644 --- a/src/pbrt/util/noise.cpp +++ b/src/pbrt/util/noise.cpp @@ -55,7 +55,7 @@ static PBRT_CONST int NoisePerm[2 * NoisePermSize] = { // Noise Function Definitions Float Noise(Float x, Float y, Float z) { // Compute noise cell coordinates and offsets - // Avoid overflow when computing deltas if the coordiantes are too large to store in + // Avoid overflow when computing deltas if the coordinates are too large to store in // int32s. x = pstd::fmod(x, Float(1 << 30)); y = pstd::fmod(y, Float(1 << 30)); From 46b19d5e1a0db0bcc6c9b651b55262ac2ad45fcf Mon Sep 17 00:00:00 2001 From: Julian Amann Date: Wed, 5 Jul 2023 22:33:34 +0200 Subject: [PATCH 133/149] Fix dupe word typo --- src/pbrt/cmd/imgtool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 6a57fdd44..c575b6b23 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -483,7 +483,7 @@ int assemble(std::vector args) { } if (Union(*metadata.pixelBounds, fullBounds) != fullBounds) { Warning("%s: pixel bounds (%d, %d) - (%d, %d) in EXR file isn't inside " - "the the full image (0, 0) - (%d, %d). " + "the full image (0, 0) - (%d, %d). " "Ignoring this file.", file, metadata.pixelBounds->pMin.x, metadata.pixelBounds->pMin.y, metadata.pixelBounds->pMax.x, metadata.pixelBounds->pMax.y, From 698e20331b8cb1bdb6e7a0e6c1f86375e3f76c69 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 14 Jul 2023 10:26:38 -0700 Subject: [PATCH 134/149] Fix bug in f94d39f8d908752513104d815e66188f5585f446. Fixes #368. --- src/pbrt/cmd/imgtool.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pbrt/cmd/imgtool.cpp b/src/pbrt/cmd/imgtool.cpp index 6a57fdd44..c1053e182 100644 --- a/src/pbrt/cmd/imgtool.cpp +++ b/src/pbrt/cmd/imgtool.cpp @@ -2247,6 +2247,7 @@ int denoise_optix(std::vector args) { CUDA_CHECK(cudaFree(nullptr)); int nLayers = 3; + bool oldNormalNaming = false; ImageChannelDesc desc[3] = { image.GetChannelDesc({"R", "G", "B"}), image.GetChannelDesc({"Albedo.R", "Albedo.G", "Albedo.B"}), @@ -2264,7 +2265,9 @@ int denoise_optix(std::vector args) { if (!desc[2]) { // Try the old naming scheme desc[2] = image.GetChannelDesc({"Nsx", "Nsy", "Nsz"}); - if (!desc[2]) { + if (desc[2]) + oldNormalNaming = true; + else { Warning("%s: image doesn't have Ns.X, Ns.Y, Ns.Z channels. " "Denoising quality may suffer.", inFilename); @@ -2302,7 +2305,10 @@ int denoise_optix(std::vector args) { Normal3f *normalGPU = nullptr; if (nLayers == 3) { albedoGPU = (RGB *)copyChannelsToGPU({"Albedo.R", "Albedo.G", "Albedo.B"}); - normalGPU = (Normal3f *)copyChannelsToGPU({"Nsx", "Nsy", "Nsz"}, true); + if (oldNormalNaming) + normalGPU = (Normal3f *)copyChannelsToGPU({"Nsx", "Nsy", "Nsz"}, true); + else + normalGPU = (Normal3f *)copyChannelsToGPU({"Ns.X", "Ns.Y", "Ns.Z"}, true); } RGB *rgbResultGPU; From ce95acb9b94fdd2f4918bca643310ccfd481b1fa Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 4 Aug 2023 11:57:06 -0700 Subject: [PATCH 135/149] Convert vertex positions to 32-bit for OptiX when using PBRT_FLOAT_AS_DOUBLE. Issue #359. --- src/pbrt/gpu/aggregate.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index 8f067422b..92026d6af 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -451,12 +451,29 @@ OptiXAggregate::BVH OptiXAggregate::buildBVHForTriangles( input.type = OPTIX_BUILD_INPUT_TYPE_TRIANGLES; input.triangleArray.vertexFormat = OPTIX_VERTEX_FORMAT_FLOAT3; - input.triangleArray.vertexStrideInBytes = sizeof(Point3f); input.triangleArray.numVertices = mesh->nVertices; +#ifdef PBRT_FLOAT_AS_DOUBLE + // Convert the vertex positions to 32-bit floats before giving + // them to OptiX, since it doesn't support double-precision + // geometry. + input.triangleArray.vertexStrideInBytes = 3 * sizeof(float); + float *pGPU; + std::vector p32(3 * mesh->nVertices); + for (int i = 0; i < mesh->nVertices; i++) { + p32[3*i] = mesh->p[i].x; + p32[3*i+1] = mesh->p[i].y; + p32[3*i+2] = mesh->p[i].z; + } + CUDA_CHECK(cudaMalloc(&pGPU, mesh->nVertices * 3 * sizeof(float))); + CUDA_CHECK(cudaMemcpy(pGPU, p32.data(), mesh->nVertices * 3 * sizeof(float), + cudaMemcpyHostToDevice)); +#else + input.triangleArray.vertexStrideInBytes = sizeof(Point3f); Point3f *pGPU; CUDA_CHECK(cudaMalloc(&pGPU, mesh->nVertices * sizeof(Point3f))); CUDA_CHECK(cudaMemcpy(pGPU, mesh->p, mesh->nVertices * sizeof(Point3f), cudaMemcpyHostToDevice)); +#endif pDeviceDevicePtrs[meshIndex] = CUdeviceptr(pGPU); input.triangleArray.vertexBuffers = &pDeviceDevicePtrs[meshIndex]; From 2583512f09df8f28b32161be4154169f0f9088d4 Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Tue, 29 Aug 2023 20:30:04 +0800 Subject: [PATCH 136/149] delete unused variable --- src/pbrt/cpu/integrators.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index 7aa146369..a2f15f96b 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -1418,8 +1418,6 @@ AOIntegrator::AOIntegrator(bool cosSample, Float maxDist, Camera camera, Sampler SampledSpectrum AOIntegrator::Li(RayDifferential ray, SampledWavelengths &lambda, Sampler sampler, ScratchBuffer &scratchBuffer, VisibleSurface *visibleSurface) const { - SampledSpectrum L(0.f); - // Intersect _ray_ with scene and store intersection in _isect_ pstd::optional si; retry: From 425faa0843d9f3518a7564b434cb340ad85bda41 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 5 Sep 2023 16:00:21 +0100 Subject: [PATCH 137/149] GPU: fix bug with wo direction with quadric/bilinear instances We need to transform these into instance space before calling InteractionFromIntersection... Fixes issue #372. --- src/pbrt/gpu/optix.cu | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pbrt/gpu/optix.cu b/src/pbrt/gpu/optix.cu index 07f11099c..dd37988f0 100644 --- a/src/pbrt/gpu/optix.cu +++ b/src/pbrt/gpu/optix.cu @@ -306,6 +306,9 @@ static __device__ inline SurfaceInteraction getQuadricIntersection( Vector3f wo = -Vector3f(rd.x, rd.y, rd.z); Float time = optixGetRayTime(); + Transform worldFromInstance = getWorldFromInstance(); + wo = worldFromInstance.ApplyInverse(wo); + SurfaceInteraction intr; if (const Sphere *sphere = rec.shape.CastOrNullptr()) intr = sphere->InteractionFromIntersection(si, wo, time); @@ -396,6 +399,9 @@ getBilinearPatchIntersection(Point2f uv) { float3 rd = optixGetWorldRayDirection(); Vector3f wo = -Vector3f(rd.x, rd.y, rd.z); + Transform worldFromInstance = getWorldFromInstance(); + wo = worldFromInstance.ApplyInverse(wo); + return BilinearPatch::InteractionFromIntersection(rec.mesh, optixGetPrimitiveIndex(), uv, optixGetRayTime(), wo); } From 83e45996f4479fdeedd4ed5c18140f67a2c0e58e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sun, 17 Sep 2023 07:06:27 +0100 Subject: [PATCH 138/149] Fix bug in NormalMap() When computing the local basis, it's important to keep the +x axis consistently oriented with dpdu. Fixes #381. --- src/pbrt/materials.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/materials.h b/src/pbrt/materials.h index 2665c4a46..5cc1df28c 100644 --- a/src/pbrt/materials.h +++ b/src/pbrt/materials.h @@ -95,7 +95,7 @@ inline PBRT_CPU_GPU void NormalMap(const Image &normalMap, ns = Normalize(ns); // Transform tangent-space normal to rendering space - Frame frame = Frame::FromZ(ctx.shading.n); + Frame frame = Frame::FromXZ(Normalize(ctx.shading.dpdu), Vector3f(ctx.shading.n)); ns = frame.FromLocal(ns); // Find $\dpdu$ and $\dpdv$ that give shading normal From 880346c59d868a530b7aba59e35c9d588e450879 Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Sun, 17 Sep 2023 22:41:36 +0800 Subject: [PATCH 139/149] delete unused returned variable from gauss_newton() --- src/pbrt/cmd/rgb2spec_opt.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pbrt/cmd/rgb2spec_opt.cpp b/src/pbrt/cmd/rgb2spec_opt.cpp index 1cff054a3..9d253060f 100644 --- a/src/pbrt/cmd/rgb2spec_opt.cpp +++ b/src/pbrt/cmd/rgb2spec_opt.cpp @@ -530,7 +530,7 @@ void eval_jacobian(const double *coeffs, const double *rgb, double **jac) { } } -double gauss_newton(const double rgb[3], double coeffs[3], int it = 15) { +void gauss_newton(const double rgb[3], double coeffs[3], int it = 15) { double r = 0; for (int i = 0; i < it; ++i) { double J0[3], J1[3], J2[3], *J[3] = {J0, J1, J2}; @@ -567,7 +567,6 @@ double gauss_newton(const double rgb[3], double coeffs[3], int it = 15) { if (r < 1e-6) break; } - return std::sqrt(r); } static Gamut parse_gamut(const char *str) { @@ -841,8 +840,7 @@ int main(int argc, char **argv) { rgb[(l + 1) % 3] = x * b; rgb[(l + 2) % 3] = y * b; - double resid = gauss_newton(rgb, coeffs); - (void)resid; + gauss_newton(rgb, coeffs); double c0 = 360.0, c1 = 1.0 / (830.0 - 360.0); double A = coeffs[0], B = coeffs[1], C = coeffs[2]; @@ -863,8 +861,7 @@ int main(int argc, char **argv) { rgb[(l + 1) % 3] = x * b; rgb[(l + 2) % 3] = y * b; - double resid = gauss_newton(rgb, coeffs); - (void)resid; + gauss_newton(rgb, coeffs); double c0 = 360.0, c1 = 1.0 / (830.0 - 360.0); double A = coeffs[0], B = coeffs[1], C = coeffs[2]; From 323da4d0e9cdb6ea999fdae0b86407374daded1c Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 18 Sep 2023 07:19:48 +0100 Subject: [PATCH 140/149] Disable unwantd FMAs with clang 14 Fixes #375 --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8d8d0326..bd99a65fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,11 @@ else () message (STATUS "Found -lprofiler: ${PROFILE_LIB}") endif () +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14) + message (STATUS "Disabling -ffp-contract (thanks, clang 14!)") + list (APPEND PBRT_CXX_FLAGS "-ffp-contract=off") +endif () + add_library (pbrt_warnings INTERFACE) target_compile_options ( pbrt_warnings From 1f092943cc50269ea6630460bf55b488eacf7f9e Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Tue, 26 Sep 2023 08:05:28 +0800 Subject: [PATCH 141/149] add const qualifier to function arguments in LUPSolve() --- src/pbrt/cmd/rgb2spec_opt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/cmd/rgb2spec_opt.cpp b/src/pbrt/cmd/rgb2spec_opt.cpp index 9d253060f..d54283f40 100644 --- a/src/pbrt/cmd/rgb2spec_opt.cpp +++ b/src/pbrt/cmd/rgb2spec_opt.cpp @@ -316,7 +316,7 @@ int LUPDecompose(double **A, int N, double Tol, int *P) { /* INPUT: A,P filled in LUPDecompose; b - rhs vector; N - dimension * OUTPUT: x - solution vector of A*x=b */ -void LUPSolve(double **A, int *P, double *b, int N, double *x) { +void LUPSolve(double **const A, const int *P, const double *b, int N, double *x) { for (int i = 0; i < N; i++) { x[i] = b[P[i]]; From adb4f88857453fb4c435bbec4ef76f97db3b0baf Mon Sep 17 00:00:00 2001 From: feimos32 <46518784+feimos32@users.noreply.github.com> Date: Sat, 30 Sep 2023 11:20:20 +0800 Subject: [PATCH 142/149] Update wavefront.cpp The redundant line of code has been removed. --- src/pbrt/wavefront/wavefront.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pbrt/wavefront/wavefront.cpp b/src/pbrt/wavefront/wavefront.cpp index 1d53458fd..7482fdb84 100644 --- a/src/pbrt/wavefront/wavefront.cpp +++ b/src/pbrt/wavefront/wavefront.cpp @@ -63,7 +63,6 @@ void RenderWavefront(BasicScene &scene) { #endif // PBRT_BUILD_GPU_RENDERER ImageMetadata metadata; - metadata.samplesPerPixel = integrator->sampler.SamplesPerPixel(); integrator->camera.InitMetadata(&metadata); metadata.renderTimeSeconds = seconds; metadata.samplesPerPixel = integrator->sampler.SamplesPerPixel(); From 3c4932275fdf48ff7960e48b5c78f051d1ab10bd Mon Sep 17 00:00:00 2001 From: John Alberse Date: Sat, 30 Sep 2023 15:38:16 -0500 Subject: [PATCH 143/149] Constrain max value test further for unbounded Removes a 10x multiplier on the maximum value in the MaxValue test for RgbUnboundedSpectrum. The 10x multiplier makes the check unnecesarily lax; the evaluations on the various lambdas below it should pass without the multiplier applied. --- src/pbrt/util/spectrum_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/util/spectrum_test.cpp b/src/pbrt/util/spectrum_test.cpp index cc4129596..ff10dfa89 100644 --- a/src/pbrt/util/spectrum_test.cpp +++ b/src/pbrt/util/spectrum_test.cpp @@ -109,7 +109,7 @@ TEST(Spectrum, MaxValue) { EXPECT_LE(sr(lambda), m); RGBUnboundedSpectrum su(*RGBColorSpace::sRGB, 10 * rgb); - m = su.MaxValue() * 1.00001f * 10.f; + m = su.MaxValue() * 1.00001f; for (Float lambda = 360; lambda < 830; lambda += .92) EXPECT_LE(su(lambda), m); From fe4effc7a68e3fb1d304e1e6b8023d12ee2ed2cb Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Tue, 10 Oct 2023 06:12:31 +0800 Subject: [PATCH 144/149] remove redundant function declaration --- src/pbrt/util/spectrum.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pbrt/util/spectrum.h b/src/pbrt/util/spectrum.h index 8b2ae4810..943a9993c 100644 --- a/src/pbrt/util/spectrum.h +++ b/src/pbrt/util/spectrum.h @@ -85,7 +85,6 @@ DenselySampledSpectrum D(Float T, Allocator alloc); Float SpectrumToPhotometric(Spectrum s); -Float SpectrumToPhotometric(Spectrum s); XYZ SpectrumToXYZ(Spectrum s); // SampledSpectrum Definition From 9d038c5caff7a173b208304d8eebb9ba6e2c0f17 Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Wed, 11 Oct 2023 11:24:16 +0800 Subject: [PATCH 145/149] replace SampledSpectrum(X) with X in AOIntegrator::Li() to simplify computation --- src/pbrt/cpu/integrators.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index a2f15f96b..dd74d06cd 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -1454,7 +1454,7 @@ SampledSpectrum AOIntegrator::Li(RayDifferential ray, SampledWavelengths &lambda Ray r = isect.SpawnRay(wi); if (!IntersectP(r, maxDist)) { return illumScale * illuminant.Sample(lambda) * - SampledSpectrum(Dot(wi, n) / (Pi * pdf)); + Dot(wi, n) / (Pi * pdf); } } return SampledSpectrum(0.); From 44a61fad814de0a95a4d582f0b0db20e89394360 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 17 Oct 2023 13:17:24 +0800 Subject: [PATCH 146/149] compatibility with optix 8 --- src/pbrt/gpu/aggregate.cpp | 7 +++++-- src/pbrt/gpu/denoiser.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index 92026d6af..b86e514ac 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -1053,8 +1053,11 @@ OptixPipelineCompileOptions OptiXAggregate::getPipelineCompileOptions() { pipelineCompileOptions.numAttributeValues = 4; // OPTIX_EXCEPTION_FLAG_NONE; pipelineCompileOptions.exceptionFlags = - (OPTIX_EXCEPTION_FLAG_STACK_OVERFLOW | OPTIX_EXCEPTION_FLAG_TRACE_DEPTH | - OPTIX_EXCEPTION_FLAG_DEBUG); + (OPTIX_EXCEPTION_FLAG_STACK_OVERFLOW | OPTIX_EXCEPTION_FLAG_TRACE_DEPTH); +#if (OPTIX_VERSION < 80000) + // This flag is remove since OptiX 8.0.0 + pipelineCompileOptions.exceptionFlags |= OPTIX_EXCEPTION_FLAG_DEBUG; +#endif pipelineCompileOptions.pipelineLaunchParamsVariableName = "params"; return pipelineCompileOptions; diff --git a/src/pbrt/gpu/denoiser.cpp b/src/pbrt/gpu/denoiser.cpp index c593c207e..021d61d64 100644 --- a/src/pbrt/gpu/denoiser.cpp +++ b/src/pbrt/gpu/denoiser.cpp @@ -40,7 +40,9 @@ Denoiser::Denoiser(Vector2i resolution, bool haveAlbedoAndNormal) OPTIX_CHECK(optixDeviceContextCreate(cudaContext, 0, &optixContext)); OptixDenoiserOptions options = {}; -#if (OPTIX_VERSION >= 70300) +#if (OPTIX_VERSION >= 80000) + options.denoiseAlpha = OPTIX_DENOISER_ALPHA_MODE_COPY; +#elif (OPTIX_VERSION >= 70300) if (haveAlbedoAndNormal) options.guideAlbedo = options.guideNormal = 1; @@ -101,7 +103,9 @@ void Denoiser::Denoise(RGB *rgb, Normal3f *n, RGB *albedo, RGB *result) { CUdeviceptr(scratchBuffer), memorySizes.withoutOverlapScratchSizeInBytes)); OptixDenoiserParams params = {}; -#if (OPTIX_VERSION >= 70500) +#if (OPTIX_VERSION >= 80000) + // denoiseAlpha is moved to OptixDenoiserOptions in OptiX 8.0 +#elif (OPTIX_VERSION >= 70500) params.denoiseAlpha = OPTIX_DENOISER_ALPHA_MODE_COPY; #else params.denoiseAlpha = 0; From 43c8eab8a237f6a10caee50aa7a34d161199c296 Mon Sep 17 00:00:00 2001 From: Zheng Shaokun Date: Tue, 17 Oct 2023 13:25:23 +0800 Subject: [PATCH 147/149] fix typo --- src/pbrt/gpu/aggregate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/gpu/aggregate.cpp b/src/pbrt/gpu/aggregate.cpp index b86e514ac..0c6ee6ce3 100644 --- a/src/pbrt/gpu/aggregate.cpp +++ b/src/pbrt/gpu/aggregate.cpp @@ -1055,7 +1055,7 @@ OptixPipelineCompileOptions OptiXAggregate::getPipelineCompileOptions() { pipelineCompileOptions.exceptionFlags = (OPTIX_EXCEPTION_FLAG_STACK_OVERFLOW | OPTIX_EXCEPTION_FLAG_TRACE_DEPTH); #if (OPTIX_VERSION < 80000) - // This flag is remove since OptiX 8.0.0 + // This flag is removed since OptiX 8.0.0 pipelineCompileOptions.exceptionFlags |= OPTIX_EXCEPTION_FLAG_DEBUG; #endif pipelineCompileOptions.pipelineLaunchParamsVariableName = "params"; From 3adc3f01aa4098afb71a77158b452d770244dda6 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 18 Oct 2023 04:45:53 -0700 Subject: [PATCH 148/149] Add OptiX 8 to github actions build matrix, remove a few old OptiX versions --- .github/workflows/ci-gpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-gpu.yml b/.github/workflows/ci-gpu.yml index 18e66b7b5..0e8a9a56f 100644 --- a/.github/workflows/ci-gpu.yml +++ b/.github/workflows/ci-gpu.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - optix: [ optix-7.3.0, optix-7.4.0 optix-7.5.0, optix-7.7.0 ] + optix: [ optix-7.5.0, optix-7.7.0, optix-8.0.0 ] cuda: [ '11.5.2', '11.6.1', '11.7.0', '12.1.0' ] # 11.3.0 fails for unclear reasons os: [ ubuntu-20.04, windows-latest ] From 2b5837a862d7f79f4c2dd48acb2038e737b019a7 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 18 Oct 2023 16:30:54 -0700 Subject: [PATCH 149/149] Fix BDPTIntegrator to account for crop windows correctly. Fixes issue #347, fix thanks to @rainbow-app. --- src/pbrt/cpu/integrators.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/pbrt/cpu/integrators.cpp b/src/pbrt/cpu/integrators.cpp index dd74d06cd..ff6c74f08 100644 --- a/src/pbrt/cpu/integrators.cpp +++ b/src/pbrt/cpu/integrators.cpp @@ -2126,7 +2126,7 @@ SampledSpectrum G(const Integrator &integrator, Sampler sampler, const Vertex &v return g * integrator.Tr(v0.GetInteraction(), v1.GetInteraction(), lambda); } -Float MISWeight(const Integrator &integrator, Vertex *lightVertices, +Float MISWeight(const Integrator &integrator, Camera camera, Vertex *lightVertices, Vertex *cameraVertices, Vertex &sampled, int s, int t, LightSampler lightSampler) { if (s + t == 2) @@ -2177,10 +2177,16 @@ Float MISWeight(const Integrator &integrator, Vertex *lightVertices, if (qsMinus) a7 = {&qsMinus->pdfRev, qs->PDF(integrator, pt, *qsMinus)}; + Film film = camera.GetFilm(); + Float splatScale = Float(film.FullResolution().x) * Float(film.FullResolution().y) / + Float(film.PixelBounds().Area()); + // Consider hypothetical connection strategies along the camera subpath Float ri = 1; for (int i = t - 1; i > 0; --i) { ri *= remap0(cameraVertices[i].pdfRev) / remap0(cameraVertices[i].pdfFwd); + // See https://github.com/mmp/pbrt-v4/issues/347 + if (i == 1) ri /= splatScale; if (!cameraVertices[i].delta && !cameraVertices[i - 1].delta) sumRi += ri; } @@ -2195,6 +2201,8 @@ Float MISWeight(const Integrator &integrator, Vertex *lightVertices, sumRi += ri; } + // See https://github.com/mmp/pbrt-v4/issues/347 + if (t == 1) sumRi /= splatScale; return 1 / (1 + sumRi); } @@ -2345,8 +2353,14 @@ SampledSpectrum ConnectBDPT(const Integrator &integrator, SampledWavelengths &la if (qs.IsOnSurface()) L *= AbsDot(cs->wi, qs.ns()); DCHECK(!L.HasNaNs()); - if (L) + if (L) { L *= integrator.Tr(cs->pRef, cs->pLens, lambda); + + // See https://github.com/mmp/pbrt-v4/issues/347 + Film film = camera.GetFilm(); + L *= Float(film.FullResolution().x) * Float(film.FullResolution().y) / + Float(film.PixelBounds().Area()); + } } } @@ -2418,7 +2432,7 @@ SampledSpectrum ConnectBDPT(const Integrator &integrator, SampledWavelengths &la ++zeroRadiancePaths; pathLength << s + t - 2; // Compute MIS weight for connection strategy - Float misWeight = L ? MISWeight(integrator, lightVertices, cameraVertices, sampled, s, + Float misWeight = L ? MISWeight(integrator, camera, lightVertices, cameraVertices, sampled, s, t, lightSampler) : 0.f; PBRT_DBG("MIS weight for (s,t) = (%d, %d) connection: %f\n", s, t, misWeight);