├── dist
├── houdini
│ ├── plugInfo.json
│ ├── UsdRenderers.json
│ └── HdGatlingRendererPlugin_Viewport.ds
└── blender
│ ├── __init__.py
│ ├── blender_manifest.toml
│ └── engine.py
├── src
├── hdGatling
│ ├── .gitattributes
│ ├── testenv
│ │ ├── _data
│ │ │ ├── quad.usda
│ │ │ └── usd-wg-assets
│ │ │ │ └── primvar_interpolation
│ │ │ │ ├── LICENSE
│ │ │ │ ├── README.md
│ │ │ │ └── primvar_interpolation.usda
│ │ ├── Render.AOVs
│ │ │ ├── cube.usda
│ │ │ ├── scene.usd
│ │ │ ├── ref_bounces.png
│ │ │ ├── ref_color.png
│ │ │ ├── ref_depth.png
│ │ │ ├── ref_faceId.png
│ │ │ ├── ref_instanceId.png
│ │ │ ├── ref_normal.png
│ │ │ ├── ref_objectId.png
│ │ │ ├── ref_tangents.png
│ │ │ ├── ref_texcoords.png
│ │ │ ├── ref_barycentrics.png
│ │ │ └── ref_bitangents.png
│ │ ├── Render.Empty1x1
│ │ │ ├── ref.png
│ │ │ └── scene.usd
│ │ ├── Materials.MtlxViewDirection
│ │ │ ├── ref.png
│ │ │ ├── scene.mtlx
│ │ │ └── scene.usd
│ │ └── Mesh.PrimvarInterpolation
│ │ │ ├── ref.png
│ │ │ └── scene.usd
│ ├── plugInfo.json.in
│ ├── previewSurfaceNetworkPatcher.h
│ ├── utils.h
│ ├── renderParam.h
│ ├── mdlDiscoveryPlugin.h
│ ├── tokens.cpp
│ ├── renderParam.cpp
│ ├── instancer.h
│ ├── mdlParserPlugin.h
│ ├── material.h
│ ├── rendererPlugin.h
│ ├── materialNetworkCompiler.h
│ ├── renderPass.h
│ ├── renderBuffer.h
│ ├── utils.cpp
│ ├── material.cpp
│ ├── mdlDiscoveryPlugin.cpp
│ ├── mdlParserPlugin.cpp
│ └── mesh.h
├── imgio
│ ├── testenv
│ │ ├── 4c.exr
│ │ ├── 4c.hdr
│ │ ├── 4c.jpg
│ │ ├── 4c.png
│ │ ├── 4c.tga
│ │ └── 4c.tiff
│ ├── gtl
│ │ └── imgio
│ │ │ ├── ErrorCodes.h
│ │ │ ├── Image.h
│ │ │ └── Imgio.h
│ ├── impl
│ │ ├── PngDecoder.h
│ │ ├── JpegDecoder.h
│ │ ├── TgaDecoder.h
│ │ ├── TiffDecoder.h
│ │ ├── ExrDecoder.h
│ │ ├── HdrDecoder.h
│ │ ├── TgaDecoder.cpp
│ │ ├── Imgio.cpp
│ │ ├── JpegDecoder.cpp
│ │ ├── TiffDecoder.cpp
│ │ ├── HdrDecoder.cpp
│ │ ├── PngDecoder.cpp
│ │ └── main.cpp
│ └── CMakeLists.txt
├── CMakeLists.txt
├── gatling
│ ├── CMakeLists.txt
│ ├── Argparse.h
│ ├── SimpleRenderTask.h
│ └── SimpleRenderTask.cpp
├── gi
│ ├── shaders
│ │ ├── mdl_renderer_state.glsl
│ │ ├── rp_main_shadow.miss
│ │ ├── aovs.glsl
│ │ ├── rp_main.ahit
│ │ ├── interface
│ │ │ └── gtl.h
│ │ ├── rp_main.miss
│ │ └── rp_main_payload.glsl
│ ├── impl
│ │ ├── Mmap.h
│ │ ├── GlslShaderCompiler.h
│ │ ├── GlslStitcher.h
│ │ ├── AssetReader.h
│ │ ├── MeshProcessing.h
│ │ ├── TextureManager.h
│ │ ├── GlslStitcher.cpp
│ │ └── AssetReader.cpp
│ └── CMakeLists.txt
├── gt
│ ├── CMakeLists.txt
│ ├── gtl
│ │ └── gt
│ │ │ └── LogFlushListener.h
│ └── impl
│ │ └── LogFlushListener.cpp
├── cgpu
│ ├── CMakeLists.txt
│ └── impl
│ │ └── ShaderReflection.h
├── gb
│ ├── CMakeLists.txt
│ ├── impl
│ │ ├── SmallVector.cpp
│ │ ├── LinearDataStore.cpp
│ │ ├── HandleStore.cpp
│ │ └── Log.cpp
│ └── gtl
│ │ └── gb
│ │ ├── SmallVector.h
│ │ ├── Fmt.h
│ │ ├── ParamTypes.h
│ │ ├── HandleStore.h
│ │ ├── Enum.h
│ │ ├── Log.h
│ │ └── LinearDataStore.h
├── mc
│ ├── impl
│ │ ├── Material.cpp
│ │ ├── MdlMaterial.cpp
│ │ ├── MdlMaterial.h
│ │ ├── MtlxDocumentPatcher.h
│ │ ├── MdlNeurayLoader.h
│ │ ├── Runtime.cpp
│ │ ├── MdlLogger.h
│ │ ├── MtlxMdlCodeGen.h
│ │ ├── MdlRuntime.h
│ │ ├── MdlEntityResolver.h
│ │ └── MdlMaterialCompiler.h
│ ├── gtl
│ │ └── mc
│ │ │ ├── MaterialParameters.h
│ │ │ ├── Runtime.h
│ │ │ ├── Material.h
│ │ │ ├── Frontend.h
│ │ │ └── Backend.h
│ └── CMakeLists.txt
└── ggpu
│ ├── CMakeLists.txt
│ ├── gtl
│ └── ggpu
│ │ ├── ResizableBuffer.h
│ │ ├── DenseDataStore.h
│ │ ├── Stager.h
│ │ ├── DelayedResourceDestroyer.h
│ │ ├── SyncBuffer.h
│ │ └── LinearDataStore.h
│ └── impl
│ ├── DenseDataStore.cpp
│ ├── ResizableBuffer.cpp
│ └── DelayedResourceDestroyer.cpp
├── .github
├── patches
│ └── blender50
│ │ ├── MaterialXConfig.cmake.patch
│ │ ├── pxrConfig.cmake.patch
│ │ └── pxrTargets.cmake.patch
└── workflows
│ ├── deploy-release-weekly.yml
│ ├── deploy-release-manual.yml
│ ├── build-houdini20.yml
│ ├── validation.yml
│ ├── deploy-release.yml
│ ├── build-blender50.yml
│ └── build-usd.yml
├── cmake
├── FindMDL.cmake
└── BuildConfig.cmake
├── CMakeLists.txt
└── .gitmodules
/dist/houdini/plugInfo.json:
--------------------------------------------------------------------------------
1 | {
2 | "Includes": [ "*/resources/" ]
3 | }
4 |
--------------------------------------------------------------------------------
/src/hdGatling/.gitattributes:
--------------------------------------------------------------------------------
1 | testenv/** filter=lfs diff=lfs merge=lfs -text
2 |
--------------------------------------------------------------------------------
/src/imgio/testenv/4c.exr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pablode/gatling/HEAD/src/imgio/testenv/4c.exr
--------------------------------------------------------------------------------
/src/imgio/testenv/4c.hdr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pablode/gatling/HEAD/src/imgio/testenv/4c.hdr
--------------------------------------------------------------------------------
/src/imgio/testenv/4c.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pablode/gatling/HEAD/src/imgio/testenv/4c.jpg
--------------------------------------------------------------------------------
/src/imgio/testenv/4c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pablode/gatling/HEAD/src/imgio/testenv/4c.png
--------------------------------------------------------------------------------
/src/imgio/testenv/4c.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pablode/gatling/HEAD/src/imgio/testenv/4c.tga
--------------------------------------------------------------------------------
/src/imgio/testenv/4c.tiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pablode/gatling/HEAD/src/imgio/testenv/4c.tiff
--------------------------------------------------------------------------------
/.github/patches/blender50/MaterialXConfig.cmake.patch:
--------------------------------------------------------------------------------
1 | 49c49
2 | < if(ON AND ON)
3 | ---
4 | > if(OFF)
5 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/_data/quad.usda:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:73da42fa7ab20de9a111c3220dff831ad6c56f12ab9b9a64c9bf4d496f2113ee
3 | size 886
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/cube.usda:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:cf1aa5f1d55bb317ac8571acaf9e2c46d6c2275e2d8645c5fe42294b8ff791ef
3 | size 10985
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/scene.usd:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:1e3fba18cd35914330615903d290f4f2524aac8e56d2646820d15389b7932268
3 | size 4053
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.Empty1x1/ref.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:0cf8f967872f9f1dbf81940999a735b6c29b7cb9b86ef1cc648c3d050d9e1640
3 | size 70
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.Empty1x1/scene.usd:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:90b86e675f3f5194f43dbe55928706befa7ae64050e16717f784701fd9fe7d63
3 | size 652
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_bounces.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:732035bb2ef15b10d26eec48fff5ed53f1e00fb7b617459fed36ae68a8bc0285
3 | size 200303
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_color.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:7150b26f5489898d9e68efb7ddf19a9c51d43db738c38d66b2f7f4b32b0e6d50
3 | size 202047
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_depth.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:cf25aa02e37faafc2ef2b746248cf54e10cc2275259ceab4ff34fd21fd3e8563
3 | size 41213
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_faceId.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:29c7bdf61dd8f74231e20958f0ddac4590f7fc43e561136ef391ad3a19ba9eca
3 | size 9892
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_instanceId.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:8a051143aa51a8081009a82424da8fcef338efc7dcf116fed3c0aa5ee2da08d8
3 | size 8108
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_normal.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:23b8dc19a65c011f57fa580c6c7937ec9e94fdd01004877acf59e4f5766a9c8d
3 | size 8921
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_objectId.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:7ec016e79b38c4b4a143343c841caa11c87c83bca573da5e684f299bcd4bb5c4
3 | size 10269
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_tangents.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:6469a43e8ba7d52906900a0150cefb321eb4f00dbd17fc6bc667a68aca011ddb
3 | size 9907
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_texcoords.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:6d9f76f403f91a33e769838cf5e510d3ff9c80fa5f212a638583c4567ae3de2a
3 | size 78232
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Materials.MtlxViewDirection/ref.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:f127adf01735411f0f10b18e875da2ea80c4eefa918c20abd67d640c8d9d7e14
3 | size 4808
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Mesh.PrimvarInterpolation/ref.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:2f3d102acf284c692af1d04beab27d06dce9d217b018e84a46ad4f2e69268898
3 | size 223052
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Mesh.PrimvarInterpolation/scene.usd:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:4247856fe1f02bf06cf485a3cab0f1a9eb553547df54099295be3e09ba3c599f
3 | size 993
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_barycentrics.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:9e472e11bc4590384ac9c76536f8a69a053d3f88316daa0f49bdafc435441a3f
3 | size 303217
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Render.AOVs/ref_bitangents.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:64f323e2add58c8a70a6425a355edf507c8ccc1167537c19c9853d932c669fc2
3 | size 10728
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Materials.MtlxViewDirection/scene.mtlx:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:1ad81c39900e15eb087c2665a06e81c5987d4b4548850c9eb7b762adaf9abbe1
3 | size 769
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/Materials.MtlxViewDirection/scene.usd:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:aeb488cca0aa01a46c051f6104b75e9115b4e8197cdd76588943c4e0033d4207
3 | size 1109
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/_data/usd-wg-assets/primvar_interpolation/LICENSE:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4
3 | size 11357
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/_data/usd-wg-assets/primvar_interpolation/README.md:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:a893d1b5e4a7363bae66f92f7c938b4f701579df6fde0f166628235d20fac2c5
3 | size 92
4 |
--------------------------------------------------------------------------------
/src/hdGatling/testenv/_data/usd-wg-assets/primvar_interpolation/primvar_interpolation.usda:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:30912a91e0fbe30c14d15594f0c039bfcb08c7d298dc15446131bdafae463a4b
3 | size 4237
4 |
--------------------------------------------------------------------------------
/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(gb)
2 | add_subdirectory(mc)
3 | add_subdirectory(cgpu)
4 | add_subdirectory(imgio)
5 | add_subdirectory(ggpu)
6 | add_subdirectory(gi)
7 | add_subdirectory(gt)
8 | add_subdirectory(hdGatling)
9 | add_subdirectory(gatling)
10 |
--------------------------------------------------------------------------------
/src/gatling/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(
2 | gatling
3 | main.cpp
4 | Argparse.h
5 | Argparse.cpp
6 | SimpleRenderTask.cpp
7 | SimpleRenderTask.h
8 | )
9 |
10 | target_link_libraries(
11 | gatling
12 | ar cameraUtil hd hf hgi hio usd usdGeom usdImaging
13 | )
14 |
--------------------------------------------------------------------------------
/src/gi/shaders/mdl_renderer_state.glsl:
--------------------------------------------------------------------------------
1 | #ifndef MDL_RENDERER_STATE
2 | #define MDL_RENDERER_STATE
3 |
4 | struct mdl_renderer_state
5 | {
6 | uvec3 hitIndices;
7 | vec2 hitBarycentrics;
8 |
9 | uint64_t sceneDataBufferAddress;
10 | uint sceneDataInfos[SCENE_DATA_COUNT];
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/dist/houdini/UsdRenderers.json:
--------------------------------------------------------------------------------
1 | {
2 | "HdGatlingRendererPlugin": {
3 | "valid": true,
4 | "menulabel": "Gatling",
5 | "menupriority": 100,
6 | "needsselection": true,
7 | "allowbackgroundupdate": false,
8 | "defaultpurposes": ["proxy", "render"],
9 | "aovsupport": false
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/gt/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(
2 | gt STATIC
3 | gtl/gt/LogFlushListener.h
4 | impl/LogFlushListener.cpp
5 | )
6 |
7 | target_include_directories(
8 | gt
9 | PUBLIC
10 | ${CMAKE_CURRENT_SOURCE_DIR}
11 | PRIVATE
12 | gtl/gt
13 | impl
14 | )
15 |
16 | target_link_libraries(
17 | gt
18 | PUBLIC
19 | doctest
20 | PRIVATE
21 | gb
22 | )
23 |
--------------------------------------------------------------------------------
/dist/blender/__init__.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | from . import engine, properties, ui
6 |
7 |
8 | def register():
9 | engine.register()
10 | properties.register()
11 | ui.register()
12 |
13 |
14 | def unregister():
15 | ui.unregister()
16 | properties.unregister()
17 | engine.unregister()
18 |
--------------------------------------------------------------------------------
/dist/blender/blender_manifest.toml:
--------------------------------------------------------------------------------
1 | schema_version = "1.0.0"
2 | blender_version_min = "4.3.0"
3 |
4 | id = "hydra_gatling"
5 | license = [ "SPDX:GPL-3.0-or-later" ]
6 | maintainer = "Pablo Delgado"
7 | name = "Hydra Gatling render engine"
8 | tagline = "A cross-platform GPU path tracer with hardware ray tracing"
9 | version = "0.5.0"
10 | type = "add-on"
11 |
12 | website = "https://github.com/pablode/gatling"
13 | platforms = [ "windows-x64" ]
14 |
--------------------------------------------------------------------------------
/.github/workflows/deploy-release-weekly.yml:
--------------------------------------------------------------------------------
1 | name: Deploy Release (Weekly)
2 |
3 | on:
4 | schedule:
5 | # Run every sunday at 18:00 UTC (8 PM CET)
6 | - cron: '0 18 * * 0'
7 |
8 | jobs:
9 | deploy-release:
10 | name: Deploy release
11 | uses: ./.github/workflows/deploy-release.yml
12 | with:
13 | version-name: Weekly
14 | tag-name: weekly
15 | release-notes: 'Weekly build of the master branch.'
16 | publish-prerelease: true
17 |
--------------------------------------------------------------------------------
/.github/workflows/deploy-release-manual.yml:
--------------------------------------------------------------------------------
1 | name: Deploy Release (Manual)
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | version-name:
7 | required: true
8 | type: string
9 | default: 'Version XXX'
10 | tag-name:
11 | required: true
12 | type: string
13 |
14 | jobs:
15 | deploy-release:
16 | name: Deploy release
17 | uses: ./.github/workflows/deploy-release.yml
18 | with:
19 | version-name: ${{ inputs.version-name }}
20 | tag-name: ${{ inputs.tag-name }}
21 |
--------------------------------------------------------------------------------
/src/cgpu/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(
2 | cgpu STATIC
3 | gtl/cgpu/Cgpu.h
4 | impl/Cgpu.cpp
5 | impl/ShaderReflection.cpp
6 | impl/ShaderReflection.h
7 | )
8 |
9 | target_include_directories(
10 | cgpu
11 | PUBLIC
12 | ${CMAKE_CURRENT_SOURCE_DIR}
13 | PRIVATE
14 | gtl/cgpu
15 | impl
16 | )
17 |
18 | target_link_libraries(
19 | cgpu
20 | PRIVATE
21 | gb
22 | volk
23 | VulkanMemoryAllocator
24 | spirv-reflect-static
25 | )
26 |
27 | set_target_properties(
28 | cgpu
29 | PROPERTIES
30 | # Required since library is linked into hdGatling DSO
31 | POSITION_INDEPENDENT_CODE ON
32 | )
33 |
--------------------------------------------------------------------------------
/src/gi/shaders/rp_main_shadow.miss:
--------------------------------------------------------------------------------
1 | #extension GL_GOOGLE_include_directive: require
2 | #extension GL_EXT_ray_tracing: require
3 | #extension GL_EXT_shader_16bit_storage: require
4 | #extension GL_EXT_shader_explicit_arithmetic_types_float16: require
5 | #extension GL_EXT_shader_explicit_arithmetic_types_int16: require
6 | #extension GL_EXT_shader_explicit_arithmetic_types_int64: require
7 | #extension GL_EXT_buffer_reference: require
8 |
9 | #include "rp_main_payload.glsl"
10 | #include "rp_main_descriptors.glsl"
11 |
12 | layout(location = PAYLOAD_INDEX_SHADOW) rayPayloadInEXT ShadowRayPayload rayPayload;
13 |
14 | void main()
15 | {
16 | rayPayload.shadowed = false;
17 | }
18 |
--------------------------------------------------------------------------------
/src/gb/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(
2 | gb STATIC
3 | gtl/gb/Enum.h
4 | gtl/gb/Fmt.h
5 | gtl/gb/HandleStore.h
6 | gtl/gb/LinearDataStore.h
7 | gtl/gb/Log.h
8 | gtl/gb/ParamTypes.h
9 | gtl/gb/SmallVector.h
10 | impl/HandleStore.cpp
11 | impl/LinearDataStore.cpp
12 | impl/Log.cpp
13 | impl/SmallVector.cpp
14 | )
15 |
16 | target_include_directories(
17 | gb
18 | PUBLIC
19 | ${CMAKE_CURRENT_SOURCE_DIR}
20 | PRIVATE
21 | gtl/gb
22 | impl
23 | )
24 |
25 | target_link_libraries(
26 | gb
27 | PUBLIC
28 | quill
29 | )
30 |
31 | if(GTL_VERBOSE)
32 | target_compile_definitions(gb PUBLIC GTL_VERBOSE=1)
33 | endif()
34 |
35 | # Required since library is linked into hdGatling DSO
36 | set_target_properties(gb PROPERTIES POSITION_INDEPENDENT_CODE ON)
37 |
--------------------------------------------------------------------------------
/src/gb/impl/SmallVector.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "SmallVector.h"
19 |
--------------------------------------------------------------------------------
/src/mc/impl/Material.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "Material.h"
19 |
--------------------------------------------------------------------------------
/src/mc/impl/MdlMaterial.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "MdlMaterial.h"
19 |
--------------------------------------------------------------------------------
/src/gb/impl/LinearDataStore.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "LinearDataStore.h"
19 |
--------------------------------------------------------------------------------
/src/ggpu/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(
2 | ggpu STATIC
3 | gtl/ggpu/DelayedResourceDestroyer.h
4 | gtl/ggpu/DenseDataStore.h
5 | gtl/ggpu/LinearDataStore.h
6 | gtl/ggpu/ResizableBuffer.h
7 | gtl/ggpu/Stager.h
8 | gtl/ggpu/SyncBuffer.h
9 | impl/DelayedResourceDestroyer.cpp
10 | impl/DenseDataStore.cpp
11 | impl/LinearDataStore.cpp
12 | impl/ResizableBuffer.cpp
13 | impl/Stager.cpp
14 | impl/SyncBuffer.cpp
15 | )
16 |
17 | target_include_directories(
18 | ggpu
19 | PUBLIC
20 | ${CMAKE_CURRENT_SOURCE_DIR}
21 | PRIVATE
22 | gtl/ggpu
23 | impl
24 | )
25 |
26 | target_link_libraries(
27 | ggpu
28 | PRIVATE
29 | gb
30 | cgpu
31 | )
32 |
33 | set_target_properties(
34 | ggpu
35 | PROPERTIES
36 | # Required since library is linked into hdGatling DSO
37 | POSITION_INDEPENDENT_CODE ON
38 | )
39 |
--------------------------------------------------------------------------------
/src/gb/gtl/gb/SmallVector.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | namespace gtl
24 | {
25 | template
26 | using GbSmallVector = std::vector;
27 | }
28 |
--------------------------------------------------------------------------------
/src/imgio/gtl/imgio/ErrorCodes.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | namespace gtl
21 | {
22 | enum class ImgioError
23 | {
24 | None,
25 | UnsupportedEncoding,
26 | Decode,
27 | CorruptData,
28 | Unknown
29 | };
30 | }
31 |
--------------------------------------------------------------------------------
/cmake/FindMDL.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Find MDL.
3 | #
4 | # Once done, this will define following vars:
5 | # MDL_FOUND
6 | # MDL_INCLUDE_DIR
7 | # MDL_SHARED_LIB
8 | # MDL_LIB_DIR
9 | #
10 |
11 | find_path(MDL_INCLUDE_DIR
12 | NAMES mi/mdl_sdk.h
13 | PATH_SUFFIXES include
14 | HINTS ${MDL_ROOT}
15 | )
16 |
17 | if(WIN32)
18 | set(MDL_OS_LIB_DIR "nt-x86-64")
19 | set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
20 | elseif(APPLE)
21 | set(MDL_OS_LIB_DIR "macosx-uni")
22 | else()
23 | set(MDL_OS_LIB_DIR "linux-x86-64")
24 | endif()
25 |
26 | find_library(MDL_SHARED_LIB
27 | NAMES mdl_sdk libmdl_sdk
28 | HINTS ${MDL_ROOT}
29 | PATH_SUFFIXES bin lib ${MDL_OS_LIB_DIR}/lib
30 | )
31 |
32 | get_filename_component(MDL_LIB_DIR ${MDL_SHARED_LIB} DIRECTORY)
33 |
34 | include(FindPackageHandleStandardArgs)
35 | find_package_handle_standard_args(MDL
36 | DEFAULT_MSG
37 | MDL_INCLUDE_DIR
38 | MDL_SHARED_LIB
39 | MDL_LIB_DIR
40 | )
41 |
42 | mark_as_advanced(MDL_INCLUDE_DIR MDL_SHARED_LIB MDL_LIB_DIR)
43 |
--------------------------------------------------------------------------------
/src/gb/gtl/gb/Fmt.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #define GB_FMT(fmt, ...) fmtquill::format(fmt, __VA_ARGS__)
24 | #define GB_FMT_SPRINTF(fmt, ...) fmtquill::sprintf(fmt, __VA_ARGS__)
25 |
--------------------------------------------------------------------------------
/.github/patches/blender50/pxrConfig.cmake.patch:
--------------------------------------------------------------------------------
1 | 45,49c45
2 | < if (NOT DEFINED Python3_VERSION)
3 | < find_dependency(Python3 "3.11.13" EXACT COMPONENTS Development)
4 | < else()
5 | < find_dependency(Python3 COMPONENTS Development)
6 | < endif()
7 | ---
8 | > find_dependency(Python3 "3.11.9" EXACT COMPONENTS Development)
9 | 135,138c131
10 | < if (NOT DEFINED VulkanMemoryAllocator_DIR AND NOT [[C:/db/build/S/VS1564R/Release/vulkan_memory_allocator/share/cmake/VulkanMemoryAllocator]] STREQUAL "")
11 | < set(VulkanMemoryAllocator_DIR [[C:/db/build/S/VS1564R/Release/vulkan_memory_allocator/share/cmake/VulkanMemoryAllocator]])
12 | < endif()
13 | < find_dependency(VulkanHeaders)
14 | ---
15 | > #find_dependency(VulkanHeaders)
16 | 140d132
17 | < find_dependency(VulkanMemoryAllocator)
18 | 143a136,138
19 | > find_package(TBB REQUIRED)
20 | > find_package(OpenSubdiv REQUIRED)
21 | >
22 | 164a160,161
23 | >
24 | > include_directories(${PXR_INCLUDE_DIRS})
25 |
--------------------------------------------------------------------------------
/src/mc/impl/MdlMaterial.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace gtl
25 | {
26 | struct McMdlMaterial
27 | {
28 | mi::base::Handle compiledMaterial;
29 | };
30 | }
31 |
--------------------------------------------------------------------------------
/src/hdGatling/plugInfo.json.in:
--------------------------------------------------------------------------------
1 | {
2 | "Plugins": [
3 | {
4 | "Info": {
5 | "Types": {
6 | "HdGatlingRendererPlugin": {
7 | "bases": ["HdRendererPlugin"],
8 | "displayName": "Gatling",
9 | "priority": 99
10 | },
11 | "HdGatlingMdlDiscoveryPlugin": {
12 | "bases": ["@USD_NODE_LIB@DiscoveryPlugin"],
13 | "displayName": "MDL Discovery"
14 | },
15 | "HdGatlingMdlParserPlugin": {
16 | "bases": ["@USD_NODE_LIB@ParserPlugin"],
17 | "displayName": "MDL Node Parser"
18 | }
19 | }
20 | },
21 | "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@",
22 | "Name": "hdGatling",
23 | "ResourcePath": "resources",
24 | "Root": "..",
25 | "Type": "library"
26 | }
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/src/imgio/impl/PngDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include "ErrorCodes.h"
23 |
24 | namespace gtl
25 | {
26 | struct ImgioImage;
27 |
28 | class ImgioPngDecoder
29 | {
30 | public:
31 | static ImgioError decode(size_t size, const void* data, ImgioImage* img);
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/src/hdGatling/previewSurfaceNetworkPatcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | PXR_NAMESPACE_OPEN_SCOPE
23 |
24 | struct HdMaterialNetwork2;
25 |
26 | class PreviewSurfaceNetworkPatcher
27 | {
28 | public:
29 | void Patch(HdMaterialNetwork2& network);
30 | };
31 |
32 | PXR_NAMESPACE_CLOSE_SCOPE
33 |
--------------------------------------------------------------------------------
/src/imgio/impl/JpegDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include "ErrorCodes.h"
23 |
24 | namespace gtl
25 | {
26 | struct ImgioImage;
27 |
28 | class ImgioJpegDecoder
29 | {
30 | public:
31 | static ImgioError decode(size_t size, const void* data, ImgioImage* img);
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/src/imgio/impl/TgaDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2025 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include "ErrorCodes.h"
23 |
24 | namespace gtl
25 | {
26 | struct ImgioImage;
27 |
28 | class ImgioTgaDecoder
29 | {
30 | public:
31 | static ImgioError decode(size_t size, const void* data, ImgioImage* img);
32 | };
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/src/imgio/impl/TiffDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include "ErrorCodes.h"
23 |
24 | namespace gtl
25 | {
26 | struct ImgioImage;
27 |
28 | class ImgioTiffDecoder
29 | {
30 | public:
31 | static ImgioError decode(size_t size, const void* data, ImgioImage* img);
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/src/imgio/impl/ExrDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include "ErrorCodes.h"
23 |
24 | namespace gtl
25 | {
26 | struct ImgioImage;
27 |
28 | class ImgioExrDecoder
29 | {
30 | public:
31 | static ImgioError decode(size_t size, const void* data, ImgioImage* img, bool keepHdr);
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/src/imgio/impl/HdrDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include "ErrorCodes.h"
23 |
24 | namespace gtl
25 | {
26 | struct ImgioImage;
27 |
28 | class ImgioHdrDecoder
29 | {
30 | public:
31 | static ImgioError decode(size_t size, const void* data, ImgioImage* img, bool keepHdr);
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/cmake/BuildConfig.cmake:
--------------------------------------------------------------------------------
1 | # Use RelWithDebInfo as base config
2 | get_directory_property(_vars VARIABLES)
3 | foreach(_var IN LISTS _vars)
4 | if (_var MATCHES "_RELWITHDEBINFO$")
5 | string(REPLACE "_RELWITHDEBINFO" "_DEVELOP" _var_new "${_var}")
6 | set(${_var_new} "${${_var}}")
7 | mark_as_advanced(${_var_new})
8 | endif()
9 | endforeach()
10 |
11 | # But with assertions
12 | if(MSVC)
13 | string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_DEVELOP "${CMAKE_CXX_FLAGS_DEVELOP}")
14 | string(REPLACE "/DNDEBUG" "" CMAKE_C_FLAGS_DEVELOP "${CMAKE_C_FLAGS_DEVELOP}")
15 | else()
16 | string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_DEVELOP "${CMAKE_CXX_FLAGS_DEVELOP}")
17 | string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_DEVELOP "${CMAKE_C_FLAGS_DEVELOP}")
18 | endif()
19 |
20 | # Update the documentation string for GUIs
21 | set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Develop." FORCE)
22 |
23 | # Append list of configs for multi-output generators like VS
24 | list(APPEND CMAKE_CONFIGURATION_TYPES "Develop")
25 |
--------------------------------------------------------------------------------
/src/gb/gtl/gb/ParamTypes.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2025 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | namespace gtl
21 | {
22 | struct GbVec2f { float x; float y; };
23 | struct GbVec3f { float x; float y; float z; };
24 | struct GbVec4f { float x; float y; float z; float w; };
25 |
26 | struct GbColor { float r; float g; float b; };
27 | struct GbTextureAsset { std::string absPath; bool isSrgb; };
28 | }
29 |
--------------------------------------------------------------------------------
/.github/workflows/build-houdini20.yml:
--------------------------------------------------------------------------------
1 | name: Build for Houdini 20
2 |
3 | on:
4 | workflow_call:
5 |
6 | jobs:
7 | build:
8 | name: ${{ matrix.name }}
9 |
10 | strategy:
11 | matrix:
12 | include:
13 | - name: Windows (MSVC)
14 | image: windows-2022
15 | mdl-download-url: "https://github.com/NVIDIA/MDL-SDK/releases/download/2024.1.4/MDL-SDK-2024.1.4-381500.6583-nt-x86-64.zip"
16 | usd-download-url: "https://github.com/pablode/USD/releases/download/houdini20.0-ci-release/USD23.08_Windows_x64.tar.gz"
17 | usd-install-path: "C:/INSTALL"
18 | archive-name: gatling_Houdini20_Windows_x64
19 | cmake-params: -G"Visual Studio 17 2022" -Ax64
20 |
21 | uses: ./.github/workflows/build.yml
22 | with:
23 | image: ${{ matrix.image }}
24 | build-config: Release
25 | usd-download-url: ${{ matrix.usd-download-url }}
26 | usd-install-path: ${{ matrix.usd-install-path }}
27 | upload-install-artifacts: true
28 | archive-name: ${{ matrix.archive-name }}
29 | cmake-params: ${{ matrix.cmake-params }} -DPLUGINFO_LIBPATH_PREFIX=../../usd
30 | houdini-packaging: true
31 |
--------------------------------------------------------------------------------
/src/mc/gtl/mc/MaterialParameters.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2025 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 |
26 | namespace gtl
27 | {
28 | using McMaterialParameterValue = std::variant;
29 |
30 | using McMaterialParameters = std::unordered_map;
31 | }
32 |
--------------------------------------------------------------------------------
/src/hdGatling/utils.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | PXR_NAMESPACE_OPEN_SCOPE
26 |
27 | bool HdGatlingIsPrimvarTypeSupported(const VtValue& value);
28 |
29 | gtl::GiPrimvarType HdGatlingGetGiPrimvarType(HdType type);
30 |
31 | void HdGatlingConvertVtBoolArrayToVtIntArray(VtValue& values);
32 |
33 | PXR_NAMESPACE_CLOSE_SCOPE
34 |
--------------------------------------------------------------------------------
/.github/workflows/validation.yml:
--------------------------------------------------------------------------------
1 | name: Validation Build
2 |
3 | on:
4 | push:
5 | branches:
6 | - 'master'
7 | - 'dev'
8 | paths-ignore:
9 | - '**.md'
10 | pull_request:
11 | paths-ignore:
12 | - '**.md'
13 |
14 | jobs:
15 | build-blender50:
16 | name: Build for Blender 5.0
17 | uses: ./.github/workflows/build-blender50.yml
18 |
19 | build-2508:
20 | name: Build for USD v25.08
21 | uses: ./.github/workflows/build-usd.yml
22 | with:
23 | usd-version: 25.08
24 | run-graphical-tests: true
25 | upload-test-artifacts: true
26 |
27 | build-2505:
28 | name: Build for USD v25.05
29 | uses: ./.github/workflows/build-usd.yml
30 | with:
31 | usd-version: 25.05
32 | run-graphical-tests: true
33 | upload-test-artifacts: true
34 |
35 | build-2502:
36 | name: Build for USD v25.02
37 | uses: ./.github/workflows/build-usd.yml
38 | with:
39 | usd-version: 25.02
40 | upload-test-artifacts: true
41 |
42 | build-2411:
43 | name: Build for USD v24.11
44 | uses: ./.github/workflows/build-usd.yml
45 | with:
46 | usd-version: 24.11
47 | upload-test-artifacts: true
48 |
--------------------------------------------------------------------------------
/src/mc/impl/MtlxDocumentPatcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace gtl
25 | {
26 | class McMtlxDocumentPatcher
27 | {
28 | public:
29 | McMtlxDocumentPatcher(const MaterialX::DocumentPtr mtlxStdLib, const std::string& customNodesPath);
30 |
31 | MaterialX::DocumentPtr patch(const MaterialX::DocumentPtr document);
32 |
33 | private:
34 | MaterialX::DocumentPtr m_customNodesDoc;
35 | };
36 | }
37 |
--------------------------------------------------------------------------------
/src/imgio/gtl/imgio/Image.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | namespace gtl
26 | {
27 | enum class ImgioFormat
28 | {
29 | UNSUPPORTED,
30 | RGBA8_UNORM,
31 | RGB16_FLOAT,
32 | RGBA16_FLOAT,
33 | R32_FLOAT
34 | };
35 |
36 | struct ImgioImage
37 | {
38 | ImgioFormat format = ImgioFormat::RGBA8_UNORM;
39 | uint32_t width;
40 | uint32_t height;
41 | size_t size;
42 | std::vector data;
43 | };
44 | }
45 |
--------------------------------------------------------------------------------
/src/imgio/gtl/imgio/Imgio.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include "Image.h"
21 | #include "ErrorCodes.h"
22 |
23 | #include
24 |
25 | namespace gtl
26 | {
27 | enum class ImgioLoadFlags
28 | {
29 | None = 0,
30 | KeepHdr
31 | };
32 | GB_DECLARE_ENUM_BITOPS(ImgioLoadFlags);
33 |
34 | ImgioError ImgioLoadImage(const void* data,
35 | size_t size,
36 | ImgioImage* img,
37 | ImgioLoadFlags flags = ImgioLoadFlags::None);
38 | }
39 |
--------------------------------------------------------------------------------
/src/gi/shaders/aovs.glsl:
--------------------------------------------------------------------------------
1 | #ifndef AOVS_GLSL
2 | #define AOVS_GLSL
3 |
4 | // These must match the indices in gi.h
5 | #define AOV_ID_COLOR 0
6 | #define AOV_ID_NORMAL 1
7 | #define AOV_ID_DEBUG_NEE 2
8 | #define AOV_ID_DEBUG_BARYCENTRICS 3
9 | #define AOV_ID_DEBUG_TEXCOORDS 4
10 | #define AOV_ID_DEBUG_BOUNCES 5
11 | #define AOV_ID_DEBUG_CLOCK_CYCLES 6
12 | #define AOV_ID_DEBUG_OPACITY 7
13 | #define AOV_ID_DEBUG_TANGENTS 8
14 | #define AOV_ID_DEBUG_BITANGENTS 9
15 | #define AOV_ID_DEBUG_THIN_WALLED 10
16 | #define AOV_ID_OBJECT_ID 11
17 | #define AOV_ID_DEPTH 12
18 | #define AOV_ID_FACE_ID 13
19 | #define AOV_ID_INSTANCE_ID 14
20 | #define AOV_ID_DEBUG_DOUBLE_SIDED 15
21 |
22 | // Mask bits.
23 | #define AOV_BIT_COLOR 1
24 | #define AOV_BIT_NORMAL 2
25 | #define AOV_BIT_DEBUG_NEE 4
26 | #define AOV_BIT_DEBUG_BARYCENTRICS 8
27 | #define AOV_BIT_DEBUG_TEXCOORDS 16
28 | #define AOV_BIT_DEBUG_BOUNCES 32
29 | #define AOV_BIT_DEBUG_CLOCK_CYCLES 64
30 | #define AOV_BIT_DEBUG_OPACITY 128
31 | #define AOV_BIT_DEBUG_TANGENTS 256
32 | #define AOV_BIT_DEBUG_BITANGENTS 512
33 | #define AOV_BIT_DEBUG_THIN_WALLED 1024
34 | #define AOV_BIT_OBJECT_ID 2048
35 | #define AOV_BIT_DEPTH 4096
36 | #define AOV_BIT_FACE_ID 8192
37 | #define AOV_BIT_INSTANCE_ID 16384
38 | #define AOV_BIT_DEBUG_DOUBLE_SIDED 32768
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/src/mc/gtl/mc/Runtime.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace gtl
25 | {
26 | class McMdlRuntime;
27 |
28 | class McRuntime
29 | {
30 | public:
31 | McRuntime(McMdlRuntime* mdlRuntime);
32 |
33 | ~McRuntime();
34 |
35 | McMdlRuntime& getMdlRuntime() const;
36 |
37 | private:
38 | McMdlRuntime* m_mdlRuntime = nullptr;
39 | };
40 |
41 | McRuntime* McLoadRuntime(std::string_view libDir, const std::vector& mdlSearchPaths);
42 | }
43 |
--------------------------------------------------------------------------------
/src/gb/gtl/gb/HandleStore.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace gtl
26 | {
27 | class GbHandleStore
28 | {
29 | public:
30 | GbHandleStore();
31 |
32 | uint64_t allocateHandle();
33 |
34 | bool isHandleValid(uint64_t handle) const;
35 |
36 | void freeHandle(uint64_t handle);
37 |
38 | private:
39 | uint32_t m_maxIndex = 0;
40 | std::vector m_versions;
41 | std::vector m_freeList;
42 | };
43 | }
44 |
--------------------------------------------------------------------------------
/src/gi/impl/Mmap.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | namespace gtl
24 | {
25 | struct GiFile;
26 |
27 | enum class GiFileUsage { Read, Write };
28 |
29 | bool giFileCreate(const char* path, size_t size, GiFile** file);
30 |
31 | bool giFileOpen(const char* path, GiFileUsage usage, GiFile** file);
32 |
33 | size_t giFileSize(GiFile* file);
34 |
35 | bool giFileClose(GiFile* file);
36 |
37 | void* giMmap(GiFile* file, size_t offset, size_t size);
38 |
39 | bool giMunmap(GiFile* file, void* addr);
40 | }
41 |
--------------------------------------------------------------------------------
/.github/patches/blender50/pxrTargets.cmake.patch:
--------------------------------------------------------------------------------
1 | 59,60c59,64
2 | < set_target_properties(usd_ms PROPERTIES
3 | < INTERFACE_LINK_LIBRARIES "Python3::Python;Ws2_32.lib;Dbghelp.lib;Shlwapi.lib;TBB::tbb;Python3::Python;Python3::Python;TBB::tbb;TBB::tbb;TBB::tbb;TBB::tbb;Python3::Python;TBB::tbb;Python3::Python;TBB::tbb;Python3::Python;TBB::tbb;Python3::Python;TBB::tbb;Python3::Python;TBB::tbb;TBB::tbb;TBB::tbb;TBB::tbb;MaterialXCore;MaterialXFormat;OpenGL::GL;C:/db/build/S/VS1564R/Release/opensubdiv/lib/osdCPU.lib;Vulkan::Headers;Vulkan::UtilityHeaders;GPUOpen::VulkanMemoryAllocator;TBB::tbb;TBB::tbb;TBB::tbb;MaterialXCore;MaterialXFormat;Imath::Imath;C:/db/build/S/VS1564R/Release/openvdb/lib/openvdb.lib;TBB::tbb;C:/db/build/S/VS1564R/Release/opensubdiv/lib/osdCPU.lib;C:/db/build/S/VS1564R/Release/opensubdiv/lib/osdGPU.lib;MaterialXGenShader;MaterialXRender;MaterialXCore;MaterialXFormat;MaterialXGenGlsl;MaterialXGenMsl;C:/db/build/S/VS1564R/Release/opensubdiv/lib/osdCPU.lib;C:/db/build/S/VS1564R/Release/opensubdiv/lib/osdGPU.lib;C:/db/build/S/VS1564R/Release/openimageio/lib/OpenImageIO.lib;C:/db/build/S/VS1564R/Release/openimageio/lib/OpenImageIO_Util.lib;Imath::Imath;TBB::tbb"
4 | ---
5 | > target_link_libraries(
6 | > usd_ms
7 | > INTERFACE
8 | > OpenSubdiv::osdGPU_static
9 | > MaterialXCore
10 | > Python3::Python
11 |
--------------------------------------------------------------------------------
/src/mc/impl/MdlNeurayLoader.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | namespace gtl
26 | {
27 | class McMdlNeurayLoader
28 | {
29 | public:
30 | McMdlNeurayLoader();
31 | ~McMdlNeurayLoader();
32 |
33 | public:
34 | bool init(std::string_view resourcePath);
35 |
36 | mi::base::Handle getNeuray() const;
37 |
38 | private:
39 | void* m_dsoHandle;
40 | mi::base::Handle m_neuray;
41 | };
42 | }
43 |
--------------------------------------------------------------------------------
/src/gatling/Argparse.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | PXR_NAMESPACE_OPEN_SCOPE
25 |
26 | class HdRenderDelegate;
27 |
28 | struct AppSettings
29 | {
30 | std::string aov;
31 | std::string sceneFilePath;
32 | std::string outputFilePath;
33 | int imageWidth;
34 | int imageHeight;
35 | std::string cameraPath;
36 | bool gammaCorrection;
37 | bool help;
38 | };
39 |
40 | bool ParseArgs(int argc, const char* argv[], HdRenderDelegate& renderDelegate, AppSettings& settings);
41 |
42 | PXR_NAMESPACE_CLOSE_SCOPE
43 |
--------------------------------------------------------------------------------
/src/hdGatling/renderParam.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | namespace gtl
23 | {
24 | struct GiDomeLight;
25 | }
26 |
27 | using namespace gtl;
28 |
29 | PXR_NAMESPACE_OPEN_SCOPE
30 |
31 | class HdGatlingRenderParam final : public HdRenderParam
32 | {
33 | public:
34 | void AddDomeLight(GiDomeLight* domeLight);
35 |
36 | void SetDomeLightOverride(GiDomeLight* domeLight);
37 |
38 | void RemoveDomeLight(GiDomeLight* domeLight);
39 |
40 | GiDomeLight* ActiveDomeLight() const;
41 |
42 | private:
43 | std::vector _domeLights;
44 | GiDomeLight* _domeLightOverride = nullptr;
45 | };
46 |
47 | PXR_NAMESPACE_CLOSE_SCOPE
48 |
--------------------------------------------------------------------------------
/src/imgio/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(IMGIO_SRCS
2 | gtl/imgio/ErrorCodes.h
3 | gtl/imgio/Image.h
4 | gtl/imgio/Imgio.h
5 | impl/Imgio.cpp
6 | impl/ExrDecoder.h
7 | impl/ExrDecoder.cpp
8 | impl/HdrDecoder.h
9 | impl/HdrDecoder.cpp
10 | impl/JpegDecoder.h
11 | impl/JpegDecoder.cpp
12 | impl/PngDecoder.h
13 | impl/PngDecoder.cpp
14 | impl/TgaDecoder.h
15 | impl/TgaDecoder.cpp
16 | impl/TiffDecoder.h
17 | impl/TiffDecoder.cpp
18 | )
19 |
20 | function(configure_target TARGET)
21 | target_include_directories(
22 | ${TARGET}
23 | PRIVATE
24 | gtl/imgio
25 | impl
26 | )
27 |
28 | target_link_libraries(
29 | ${TARGET}
30 | PRIVATE
31 | gb
32 | spng
33 | turbojpeg-static
34 | OpenEXR::OpenEXR
35 | stb # for HDR
36 | tiff tiffxx
37 | )
38 | endfunction()
39 |
40 | add_library(imgio STATIC ${IMGIO_SRCS})
41 | target_include_directories(
42 | imgio
43 | PUBLIC
44 | ${CMAKE_CURRENT_SOURCE_DIR}
45 | )
46 | set_target_properties(
47 | imgio
48 | PROPERTIES
49 | # Required since library is linked into hdGatling DSO
50 | POSITION_INDEPENDENT_CODE ON
51 | )
52 | configure_target(imgio)
53 |
54 | add_executable(imgio_test ${IMGIO_SRCS} impl/main.cpp)
55 | target_link_libraries(imgio_test PRIVATE gt doctest)
56 | target_compile_definitions(imgio_test
57 | PRIVATE
58 | IMGIO_TESTENV_DIR="${CMAKE_CURRENT_SOURCE_DIR}/testenv"
59 | )
60 | configure_target(imgio_test)
61 |
--------------------------------------------------------------------------------
/src/mc/gtl/mc/Material.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace gtl
25 | {
26 | struct McMdlMaterial;
27 |
28 | struct McMaterial
29 | {
30 | bool hasBackfaceBsdf;
31 | bool hasBackfaceEdf;
32 | bool hasVolumeAbsorptionCoeff;
33 | bool hasVolumeScatteringCoeff;
34 | bool hasCutoutTransparency;
35 | bool isEmissive;
36 | bool isThinWalled;
37 | float directionalBias;
38 | std::string resourcePathPrefix;
39 | std::shared_ptr mdlMaterial;
40 | bool requiresSceneTransforms;
41 | std::vector sceneDataNames;
42 | int cameraPositionSceneDataIndex;
43 | };
44 | }
45 |
--------------------------------------------------------------------------------
/src/mc/impl/Runtime.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "Runtime.h"
19 |
20 | #include "MdlRuntime.h"
21 |
22 | namespace gtl
23 | {
24 | McRuntime::McRuntime(McMdlRuntime* mdlRuntime)
25 | : m_mdlRuntime(mdlRuntime)
26 | {
27 | }
28 |
29 | McRuntime::~McRuntime()
30 | {
31 | delete m_mdlRuntime;
32 | }
33 |
34 | McMdlRuntime& McRuntime::getMdlRuntime() const
35 | {
36 | return *m_mdlRuntime;
37 | }
38 |
39 | McRuntime* McLoadRuntime(std::string_view libDir, const std::vector& mdlSearchPaths)
40 | {
41 | McMdlRuntime* r = new McMdlRuntime();
42 | if (!r->init(libDir, mdlSearchPaths))
43 | {
44 | delete r;
45 | return nullptr;
46 | }
47 | return new McRuntime(r);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/cgpu/impl/ShaderReflection.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | namespace gtl
24 | {
25 | struct CgpuShaderReflectionBinding
26 | {
27 | uint32_t binding;
28 | uint32_t count;
29 | int descriptorType;
30 | bool readAccess;
31 | bool writeAccess;
32 | };
33 |
34 | struct CgpuShaderReflectionDescriptorSet
35 | {
36 | std::vector bindings;
37 | };
38 |
39 | struct CgpuShaderReflection
40 | {
41 | std::vector descriptorSets;
42 | uint32_t pushConstantsSize;
43 | uint32_t maxRayPayloadSize;
44 | uint32_t maxRayHitAttributeSize;
45 | };
46 |
47 | bool cgpuReflectShader(const uint32_t* spv, uint64_t size, CgpuShaderReflection* reflection);
48 | }
49 |
--------------------------------------------------------------------------------
/src/gi/impl/GlslShaderCompiler.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace fs = std::filesystem;
25 |
26 | namespace gtl
27 | {
28 | class GiGlslShaderCompiler
29 | {
30 | public:
31 | enum class ShaderStage
32 | {
33 | AnyHit,
34 | ClosestHit,
35 | Compute,
36 | Miss,
37 | RayGen
38 | };
39 |
40 | public:
41 | GiGlslShaderCompiler(const fs::path& shaderPath);
42 |
43 | ~GiGlslShaderCompiler();
44 |
45 | public:
46 | bool compileGlslToSpv(ShaderStage stage,
47 | std::string_view source,
48 | std::vector& spv);
49 |
50 | private:
51 | std::shared_ptr m_fileIncluder;
52 | };
53 | }
54 |
--------------------------------------------------------------------------------
/src/gi/impl/GlslStitcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace fs = std::filesystem;
26 |
27 | namespace gtl
28 | {
29 | class GiGlslStitcher
30 | {
31 | public:
32 | GiGlslStitcher();
33 |
34 | void appendVersion();
35 |
36 | void appendDefine(std::string_view name);
37 | void appendDefine(std::string_view name, int32_t value);
38 | void appendDefine(std::string_view name, float value);
39 |
40 | void appendString(std::string_view value);
41 |
42 | bool appendSourceFile(fs::path path);
43 |
44 | bool replaceFirst(std::string_view substring, std::string_view replacement);
45 |
46 | std::string source();
47 |
48 | private:
49 | std::stringstream m_source;
50 | };
51 | }
52 |
--------------------------------------------------------------------------------
/src/hdGatling/mdlDiscoveryPlugin.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #if PXR_VERSION >= 2508
22 | #include
23 | #else
24 | #include
25 | #endif
26 |
27 | PXR_NAMESPACE_OPEN_SCOPE
28 |
29 | #if PXR_VERSION >= 2508
30 | class HdGatlingMdlDiscoveryPlugin final : public SdrDiscoveryPlugin
31 | {
32 | public:
33 | SdrShaderNodeDiscoveryResultVec DiscoverShaderNodes(const Context& ctx) override;
34 |
35 | const SdrStringVec& GetSearchURIs() const override;
36 | };
37 | #else
38 | class HdGatlingMdlDiscoveryPlugin final : public NdrDiscoveryPlugin
39 | {
40 | public:
41 | NdrNodeDiscoveryResultVec DiscoverNodes(const Context& ctx) override;
42 |
43 | const NdrStringVec& GetSearchURIs() const override;
44 | };
45 | #endif
46 |
47 | PXR_NAMESPACE_CLOSE_SCOPE
48 |
--------------------------------------------------------------------------------
/src/hdGatling/tokens.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "tokens.h"
19 |
20 | PXR_NAMESPACE_OPEN_SCOPE
21 |
22 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingSettingsTokens, HD_GATLING_SETTINGS_TOKENS);
23 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingNodeIdentifiers, HD_GATLING_NODE_IDENTIFIER_TOKENS);
24 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingSourceTypes, HD_GATLING_SOURCE_TYPE_TOKENS);
25 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingDiscoveryTypes, HD_GATLING_DISCOVERY_TYPE_TOKENS);
26 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingRenderContexts, HD_GATLING_RENDER_CONTEXT_TOKENS);
27 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingNodeContexts, HD_GATLING_NODE_CONTEXT_TOKENS);
28 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingNodeMetadata, HD_GATLING_NODE_METADATA_TOKENS);
29 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingAovTokens, HD_GATLING_AOV_TOKENS);
30 | TF_DEFINE_PUBLIC_TOKENS(HdGatlingCommandTokens, HD_GATLING_COMMAND_TOKENS);
31 |
32 | PXR_NAMESPACE_CLOSE_SCOPE
33 |
--------------------------------------------------------------------------------
/src/mc/impl/MdlLogger.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace gtl
25 | {
26 | class McMdlLogger : public mi::base::Interface_implement
27 | {
28 | public:
29 | void message(mi::base::Message_severity level,
30 | const char* moduleCategory,
31 | const mi::base::Message_details& details,
32 | const char* message) override;
33 |
34 | void message(mi::base::Message_severity level,
35 | const char* moduleCategory,
36 | const char* message) override;
37 |
38 | void message(mi::base::Message_severity level,
39 | const char* message);
40 |
41 | void flushContextMessages(mi::neuraylib::IMdl_execution_context* context);
42 | };
43 | }
44 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
2 |
3 | include(CMakeDependentOption)
4 |
5 | project(gatling VERSION 0.5.0)
6 |
7 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
8 |
9 | set(CMAKE_CXX_STANDARD 20)
10 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
11 | set(CMAKE_CXX_EXTENSIONS OFF)
12 |
13 | set(GTL_OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin")
14 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${GTL_OUTPUT_DIR}")
15 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${GTL_OUTPUT_DIR}")
16 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${GTL_OUTPUT_DIR}")
17 |
18 | foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
19 | string(TOUPPER ${CONFIG_TYPE} CONFIG_TYPE)
20 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${GTL_OUTPUT_DIR})
21 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${GTL_OUTPUT_DIR})
22 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${GTL_OUTPUT_DIR})
23 | endforeach()
24 |
25 | set(GTL_TEST_OUTPUT_DIR "${PROJECT_SOURCE_DIR}/TEST")
26 |
27 | option(GTL_VERBOSE "Enable verbose logging." OFF)
28 |
29 | include(cmake/BuildConfig.cmake)
30 |
31 | include(CheckLibraryExists)
32 | check_library_exists(m exp2f "" C_MATH_LIBRARY_EXISTS)
33 | if(C_MATH_LIBRARY_EXISTS)
34 | set(C_MATH_LIBRARY "m")
35 | endif()
36 |
37 | if(WIN32)
38 | add_compile_definitions(NOMINMAX)
39 | add_compile_definitions(_USE_MATH_DEFINES)
40 | endif()
41 |
42 | add_subdirectory(extern)
43 |
44 | find_package(OpenGL REQUIRED) # Required due to USD bug #3309
45 | find_package(MaterialX REQUIRED HINTS ${USD_ROOT})
46 | find_package(USD REQUIRED HINTS ${USD_ROOT} NAMES pxr)
47 | find_package(MDL REQUIRED)
48 | find_package(OpenMP)
49 |
50 | add_subdirectory(src)
51 |
--------------------------------------------------------------------------------
/src/mc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(
2 | mc STATIC
3 | gtl/mc/Backend.h
4 | gtl/mc/Frontend.h
5 | gtl/mc/Material.h
6 | gtl/mc/MaterialParameters.h
7 | gtl/mc/Runtime.h
8 | impl/Backend.cpp
9 | impl/Frontend.cpp
10 | impl/Material.cpp
11 | impl/MdlEntityResolver.cpp
12 | impl/MdlEntityResolver.h
13 | impl/MdlLogger.cpp
14 | impl/MdlLogger.h
15 | impl/MdlMaterial.cpp
16 | impl/MdlMaterial.h
17 | impl/MdlMaterialCompiler.cpp
18 | impl/MdlMaterialCompiler.h
19 | impl/MdlNeurayLoader.cpp
20 | impl/MdlNeurayLoader.h
21 | impl/MdlRuntime.cpp
22 | impl/MdlRuntime.h
23 | impl/MtlxDocumentPatcher.cpp
24 | impl/MtlxDocumentPatcher.h
25 | impl/MtlxMdlCodeGen.cpp
26 | impl/MtlxMdlCodeGen.h
27 | impl/Runtime.cpp
28 | )
29 |
30 | target_include_directories(
31 | mc
32 | PUBLIC
33 | ${CMAKE_CURRENT_SOURCE_DIR}
34 | PRIVATE
35 | gtl/mc
36 | impl
37 | ${MDL_INCLUDE_DIR}
38 | )
39 |
40 | target_link_libraries(
41 | mc
42 | PRIVATE
43 | gb
44 | MaterialXCore
45 | MaterialXFormat
46 | MaterialXGenMdl
47 | )
48 |
49 | math(EXPR MATERIALX_VERSION "${MaterialX_VERSION_MAJOR} * 100 * 100 +
50 | ${MaterialX_VERSION_MINOR} * 100 +
51 | ${MaterialX_VERSION_PATCH}")
52 | target_compile_definitions(
53 | mc
54 | PRIVATE
55 | MATERIALX_VERSION=${MATERIALX_VERSION}
56 | )
57 |
58 | if(DEFINED PXR_VERSION)
59 | target_compile_definitions(
60 | mc
61 | PRIVATE
62 | PXR_VERSION=${PXR_VERSION}
63 | )
64 | endif()
65 |
66 | # Required since library is linked into hdGatling DSO
67 | set_target_properties(mc PROPERTIES POSITION_INDEPENDENT_CODE ON)
68 |
--------------------------------------------------------------------------------
/src/hdGatling/renderParam.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "renderParam.h"
19 |
20 | PXR_NAMESPACE_OPEN_SCOPE
21 |
22 | void HdGatlingRenderParam::AddDomeLight(GiDomeLight* domeLight)
23 | {
24 | _domeLights.push_back(domeLight);
25 | }
26 |
27 | void HdGatlingRenderParam::SetDomeLightOverride(GiDomeLight* domeLight)
28 | {
29 | _domeLightOverride = domeLight;
30 | }
31 |
32 | void HdGatlingRenderParam::RemoveDomeLight(GiDomeLight* domeLight)
33 | {
34 | _domeLights.erase(std::remove(_domeLights.begin(), _domeLights.end(), domeLight), _domeLights.end());
35 |
36 | if (_domeLightOverride == domeLight)
37 | {
38 | _domeLightOverride = nullptr;
39 | }
40 | }
41 |
42 | GiDomeLight* HdGatlingRenderParam::ActiveDomeLight() const
43 | {
44 | if (_domeLightOverride)
45 | {
46 | return _domeLightOverride;
47 | }
48 |
49 | return _domeLights.size() > 0 ? _domeLights.back() : nullptr;
50 | }
51 |
52 | PXR_NAMESPACE_CLOSE_SCOPE
53 |
--------------------------------------------------------------------------------
/src/gi/impl/AssetReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include "Gi.h"
24 |
25 | namespace gtl
26 | {
27 | class GiMmapAssetReader : public GiAssetReader
28 | {
29 | public:
30 | GiAsset* open(const char* path) override;
31 |
32 | size_t size(const GiAsset* asset) const override;
33 |
34 | void* data(const GiAsset* asset) const override;
35 |
36 | void close(GiAsset* asset) override;
37 | };
38 |
39 | class GiAggregateAssetReader : public GiAssetReader
40 | {
41 | public:
42 | void addAssetReader(GiAssetReader* reader);
43 |
44 | public:
45 | GiAsset* open(const char* path) override;
46 |
47 | size_t size(const GiAsset* asset) const override;
48 |
49 | void* data(const GiAsset* asset) const override;
50 |
51 | void close(GiAsset* asset) override;
52 |
53 | private:
54 | std::vector m_readers;
55 | };
56 | }
57 |
--------------------------------------------------------------------------------
/src/hdGatling/instancer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | PXR_NAMESPACE_OPEN_SCOPE
25 |
26 | class HdGatlingInstancer final : public HdInstancer
27 | {
28 | public:
29 | HdGatlingInstancer(HdSceneDelegate* delegate,
30 | const SdfPath& id);
31 |
32 | ~HdGatlingInstancer() override;
33 |
34 | public:
35 | VtMatrix4fArray ComputeFlattenedTransforms(const SdfPath& prototypeId);
36 |
37 | std::vector ComputeFlattenedPrimvars(const SdfPath& prototypeId);
38 |
39 | void Sync(HdSceneDelegate* sceneDelegate,
40 | HdRenderParam* renderParam,
41 | HdDirtyBits* dirtyBits) override;
42 |
43 | private:
44 | std::vector MakeGiPrimvars(const SdfPath& prototypeId);
45 |
46 | TfHashMap _primvarMap;
47 | };
48 |
49 | PXR_NAMESPACE_CLOSE_SCOPE
50 |
--------------------------------------------------------------------------------
/src/hdGatling/mdlParserPlugin.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #if PXR_VERSION >= 2508
22 | #include
23 | #else
24 | #include
25 | #endif
26 |
27 | PXR_NAMESPACE_OPEN_SCOPE
28 |
29 | #if PXR_VERSION >= 2508
30 | class HdGatlingMdlParserPlugin final : public SdrParserPlugin
31 | {
32 | public:
33 | SdrShaderNodeUniquePtr ParseShaderNode(const SdrShaderNodeDiscoveryResult& discoveryResult) override;
34 |
35 | const SdrTokenVec& GetDiscoveryTypes() const override;
36 |
37 | const TfToken& GetSourceType() const override;
38 | };
39 | #else
40 | class HdGatlingMdlParserPlugin final : public NdrParserPlugin
41 | {
42 | public:
43 | NdrNodeUniquePtr Parse(const NdrNodeDiscoveryResult& discoveryResult) override;
44 |
45 | const NdrTokenVec& GetDiscoveryTypes() const override;
46 |
47 | const TfToken& GetSourceType() const override;
48 | };
49 | #endif
50 |
51 | PXR_NAMESPACE_CLOSE_SCOPE
52 |
--------------------------------------------------------------------------------
/src/ggpu/gtl/ggpu/ResizableBuffer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace gtl
25 | {
26 | class GgpuDelayedResourceDestroyer;
27 |
28 | class GgpuResizableBuffer
29 | {
30 | public:
31 | GgpuResizableBuffer(CgpuDevice device,
32 | GgpuDelayedResourceDestroyer& delayedResourceDestroyer,
33 | CgpuBufferUsage usageFlags,
34 | CgpuMemoryProperties memoryProperties);
35 |
36 | ~GgpuResizableBuffer();
37 |
38 | public:
39 | CgpuBuffer buffer() const;
40 |
41 | uint64_t size() const;
42 |
43 | bool resize(uint64_t newSize, CgpuCommandBuffer commandBuffer);
44 |
45 | private:
46 | CgpuDevice m_device;
47 | GgpuDelayedResourceDestroyer& m_delayedResourceDestroyer;
48 | CgpuBufferUsage m_usageFlags;
49 | CgpuMemoryProperties m_memoryProperties;
50 |
51 | CgpuBuffer m_buffer;
52 | uint64_t m_size = 0;
53 | };
54 | }
55 |
--------------------------------------------------------------------------------
/src/imgio/impl/TgaDecoder.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2025 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "TgaDecoder.h"
19 | #include "ErrorCodes.h"
20 | #include "Image.h"
21 |
22 | #define STB_IMAGE_IMPLEMENTATION
23 | #define STB_IMAGE_STATIC
24 | #define STBI_FAILURE_USERMSG
25 | #define STBI_ONLY_TGA
26 | #include
27 |
28 | #include
29 | #include
30 |
31 | namespace gtl
32 | {
33 | ImgioError ImgioTgaDecoder::decode(size_t size, const void* data, ImgioImage* img)
34 | {
35 | stbi_set_flip_vertically_on_load(1);
36 |
37 | int num_components;
38 | uint8_t* rgbaData = stbi_load_from_memory((const stbi_uc*) data, (int) size, (int*) &img->width, (int*) &img->height, &num_components, 4);
39 | if (!rgbaData)
40 | {
41 | return ImgioError::Unknown;
42 | }
43 |
44 | img->size = img->width * img->height * 4;
45 | img->data.resize(img->size);
46 | memcpy(&img->data[0], rgbaData, img->size);
47 |
48 | stbi_image_free(rgbaData);
49 | return ImgioError::None;
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/src/mc/impl/MtlxMdlCodeGen.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace gtl
28 | {
29 | class McMtlxDocumentPatcher;
30 |
31 | class McMtlxMdlCodeGen
32 | {
33 | public:
34 | explicit McMtlxMdlCodeGen(const MaterialX::DocumentPtr mtlxStdLib, const std::string& customNodesPath);
35 |
36 | public:
37 | bool translate(const MaterialX::DocumentPtr mtlxDoc, std::string& mdlSrc, std::string& subIdentifier, bool& hasCutoutTransparency);
38 | bool translate(std::string_view mtlxStr, std::string& mdlSrc, std::string& subIdentifier, bool& hasCutoutTransparency);
39 |
40 | private:
41 | MaterialX::FileSearchPath m_mtlxSearchPath;
42 | MaterialX::ShaderGeneratorPtr m_shaderGen;
43 | MaterialX::DocumentPtr m_baseDoc;
44 | std::shared_ptr m_docPatcher;
45 | };
46 | }
47 |
--------------------------------------------------------------------------------
/src/gb/gtl/gb/Enum.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #define GB_DECLARE_ENUM_BITOPS(ENUMTYPE) \
21 | inline constexpr ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) \
22 | { return ENUMTYPE((int) a | (int) b); } \
23 | inline ENUMTYPE& operator |= (ENUMTYPE& a, ENUMTYPE b) \
24 | { return (ENUMTYPE&) (((int&) a) |= ((int) b)); } \
25 | inline constexpr ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) \
26 | { return ENUMTYPE(((int) a) & ((int) b)); } \
27 | inline ENUMTYPE& operator &= (ENUMTYPE &a, ENUMTYPE b) \
28 | { return (ENUMTYPE&) (((int&) a) &= ((int) b)); } \
29 | inline constexpr ENUMTYPE operator ~ (ENUMTYPE a) \
30 | { return ENUMTYPE(~((int) a)); } \
31 | inline constexpr ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) \
32 | { return ENUMTYPE(((int) a) ^ ((int) b)); } \
33 | inline ENUMTYPE& operator ^= (ENUMTYPE &a, ENUMTYPE b) \
34 | { return (ENUMTYPE&) (((int&) a) ^= ((int) b)); }
35 |
--------------------------------------------------------------------------------
/src/ggpu/gtl/ggpu/DenseDataStore.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include "LinearDataStore.h"
26 |
27 | namespace gtl
28 | {
29 | class GgpuDelayedResourceDestroyer;
30 |
31 | class GgpuDenseDataStore : public GgpuLinearDataStore
32 | {
33 | public:
34 | GgpuDenseDataStore(CgpuDevice device,
35 | GgpuStager& stager,
36 | GgpuDelayedResourceDestroyer& delayedResourceDestroyer,
37 | uint64_t elementSize,
38 | uint32_t minCapacity);
39 |
40 | public:
41 | uint64_t allocate() override;
42 |
43 | void free(uint64_t handle) override;
44 |
45 | protected:
46 | uint8_t* readRaw(uint64_t handle) override;
47 |
48 | uint8_t* writeRaw(uint64_t handle) override;
49 |
50 | private:
51 | std::unordered_map m_indexMap;
52 | uint64_t m_elementSize;
53 | uint32_t m_highestIndex = 0;
54 | };
55 | }
56 |
--------------------------------------------------------------------------------
/src/gatling/SimpleRenderTask.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | PXR_NAMESPACE_OPEN_SCOPE
26 |
27 | class SimpleRenderTask final : public HdTask
28 | {
29 | public:
30 | SimpleRenderTask(const HdRenderPassSharedPtr& renderPass,
31 | const HdRenderPassStateSharedPtr& renderPassState,
32 | const TfTokenVector& renderTags);
33 |
34 | void Sync(HdSceneDelegate* sceneDelegate,
35 | HdTaskContext* taskContext,
36 | HdDirtyBits* dirtyBits) override;
37 |
38 | void Prepare(HdTaskContext* taskContext,
39 | HdRenderIndex* renderIndex) override;
40 |
41 | void Execute(HdTaskContext* taskContext) override;
42 |
43 | const TfTokenVector& GetRenderTags() const override;
44 |
45 | private:
46 | HdRenderPassSharedPtr m_renderPass;
47 | HdRenderPassStateSharedPtr m_renderPassState;
48 | TfTokenVector m_renderTags;
49 | };
50 |
51 | PXR_NAMESPACE_CLOSE_SCOPE
52 |
--------------------------------------------------------------------------------
/src/gb/gtl/gb/Log.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #define GB_ERROR(fmt, ...) QUILL_LOG_ERROR(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
30 | #define GB_ERROR_DYN(fmt, ...) QUILL_LOG_DYNAMIC(gtl::gbGetLogger(), quill::LogLevel::Error, fmt, ##__VA_ARGS__)
31 | #define GB_WARN(fmt, ...) QUILL_LOG_WARNING(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
32 | #define GB_LOG(fmt, ...) QUILL_LOG_INFO(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
33 | #define GB_DEBUG(fmt, ...) QUILL_LOG_DEBUG(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
34 | #define GB_DEBUG_DYN(fmt, ...) QUILL_LOG_DYNAMIC(gtl::gbGetLogger(), quill::LogLevel::Debug, fmt, ##__VA_ARGS__)
35 |
36 | namespace gtl
37 | {
38 | void gbLogInit(const std::vector>& extraSinks = {});
39 |
40 | quill::Logger* gbGetLogger();
41 |
42 | void gbLogFlush();
43 | }
44 |
--------------------------------------------------------------------------------
/src/hdGatling/material.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | namespace gtl
24 | {
25 | struct GiMaterial;
26 | struct GiScene;
27 | }
28 |
29 | PXR_NAMESPACE_OPEN_SCOPE
30 |
31 | class MaterialNetworkCompiler;
32 |
33 | class HdGatlingMaterial final : public HdMaterial
34 | {
35 | public:
36 | HdGatlingMaterial(const SdfPath& id,
37 | gtl::GiScene* scene,
38 | const MaterialNetworkCompiler& materialNetworkCompiler);
39 |
40 | void Finalize(HdRenderParam* renderParam) override;
41 |
42 | public:
43 | HdDirtyBits GetInitialDirtyBitsMask() const override;
44 |
45 | void Sync(HdSceneDelegate* sceneDelegate,
46 | HdRenderParam* renderParam,
47 | HdDirtyBits* dirtyBits) override;
48 |
49 | public:
50 | gtl::GiMaterial* GetGiMaterial() const;
51 |
52 | private:
53 | const MaterialNetworkCompiler& _materialNetworkCompiler;
54 | gtl::GiMaterial* _giMaterial = nullptr;
55 | gtl::GiScene* _giScene = nullptr;
56 | };
57 |
58 | PXR_NAMESPACE_CLOSE_SCOPE
59 |
--------------------------------------------------------------------------------
/src/hdGatling/rendererPlugin.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | PXR_NAMESPACE_OPEN_SCOPE
25 |
26 | class HdGatlingRendererPlugin final : public HdRendererPlugin
27 | {
28 | public:
29 | HdGatlingRendererPlugin();
30 |
31 | ~HdGatlingRendererPlugin() override;
32 |
33 | public:
34 | HdRenderDelegate* CreateRenderDelegate() override;
35 |
36 | HdRenderDelegate* CreateRenderDelegate(const HdRenderSettingsMap& settingsMap) override;
37 |
38 | void DeleteRenderDelegate(HdRenderDelegate* renderDelegate) override;
39 |
40 | #if PXR_VERSION >= 2511
41 | bool IsSupported(const HdRendererCreateArgs& createArgs,
42 | std::string* reasonWhyNot = nullptr) const;
43 | #else
44 | bool IsSupported(bool gpuEnabled) const override;
45 | #endif
46 |
47 | private:
48 | std::unique_ptr _materialNetworkCompiler;
49 | std::unique_ptr _arAssetReader;
50 | bool _hasTriedToInitialize = false;
51 | bool _isInitialized = false;
52 | };
53 |
54 | PXR_NAMESPACE_CLOSE_SCOPE
55 |
--------------------------------------------------------------------------------
/src/hdGatling/materialNetworkCompiler.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace gtl
25 | {
26 | struct GiMaterial;
27 | struct GiScene;
28 | }
29 |
30 | using namespace gtl;
31 |
32 | PXR_NAMESPACE_OPEN_SCOPE
33 |
34 | struct HdMaterialNetwork2;
35 |
36 | class MaterialNetworkCompiler
37 | {
38 | public:
39 | MaterialNetworkCompiler(const MaterialX::DocumentPtr mtlxStdLib);
40 |
41 | GiMaterial* CompileNetwork(GiScene* scene, const SdfPath& id, const HdMaterialNetwork2& network) const;
42 |
43 | private:
44 | GiMaterial* _TryCompileMdlNetwork(GiScene* scene, const SdfPath& id, const HdMaterialNetwork2& network) const;
45 |
46 | GiMaterial* _TryCompileMtlxNetwork(GiScene* scene, const SdfPath& id, const HdMaterialNetwork2& network) const;
47 |
48 | MaterialX::DocumentPtr _CreateMaterialXDocumentFromNetwork(const SdfPath& id,
49 | const HdMaterialNetwork2& network) const;
50 |
51 | private:
52 | MaterialX::DocumentPtr _mtlxStdLib;
53 | };
54 |
55 | PXR_NAMESPACE_CLOSE_SCOPE
56 |
--------------------------------------------------------------------------------
/src/mc/gtl/mc/Frontend.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | #include "MaterialParameters.h"
26 |
27 | namespace gtl
28 | {
29 | struct McMaterial;
30 | class McMdlMaterialCompiler;
31 | class McRuntime;
32 | class McMtlxMdlCodeGen;
33 |
34 | class McFrontend
35 | {
36 | public:
37 | McFrontend(const MaterialX::DocumentPtr mtlxStdLib,
38 | const std::string& customMtlxNodesPath,
39 | McRuntime& mdlRuntime);
40 |
41 | public:
42 | McMaterial* createFromMtlxStr(std::string_view docStr);
43 |
44 | McMaterial* createFromMtlxDoc(const MaterialX::DocumentPtr doc);
45 |
46 | McMaterial* createFromMdlFile(const char* filePath, std::string_view subIdentifier, const McMaterialParameters& parameters = {});
47 |
48 | private:
49 | McMaterial* createFromMdlStr(std::string_view mdlSrc, std::string_view subIdentifier, bool isOpaque);
50 |
51 | private:
52 | std::shared_ptr m_mdlMaterialCompiler;
53 | std::shared_ptr m_mtlxMdlCodeGen;
54 | };
55 | }
56 |
--------------------------------------------------------------------------------
/src/hdGatling/renderPass.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | using namespace gtl;
26 |
27 | PXR_NAMESPACE_OPEN_SCOPE
28 |
29 | class HdCamera;
30 | class HdGatlingCamera;
31 | class HdGatlingMesh;
32 | class MaterialNetworkCompiler;
33 |
34 | class HdGatlingRenderPass final : public HdRenderPass
35 | {
36 | public:
37 | HdGatlingRenderPass(HdRenderIndex* index,
38 | const HdRprimCollection& collection,
39 | const HdRenderSettingsMap& settings,
40 | GiScene* scene);
41 |
42 | ~HdGatlingRenderPass() override;
43 |
44 | public:
45 | bool IsConverged() const override;
46 |
47 | protected:
48 | void _Execute(const HdRenderPassStateSharedPtr& renderPassState,
49 | const TfTokenVector& renderTags) override;
50 |
51 | private:
52 | void _ConstructGiCamera(const HdCamera& camera, GiCameraDesc& giCamera) const;
53 |
54 | private:
55 | GiScene* _scene;
56 | const HdRenderSettingsMap& _settings;
57 | bool _isConverged;
58 | };
59 |
60 | PXR_NAMESPACE_CLOSE_SCOPE
61 |
--------------------------------------------------------------------------------
/src/gb/gtl/gb/LinearDataStore.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include "SmallVector.h"
25 | #include "HandleStore.h"
26 |
27 | namespace gtl
28 | {
29 | template
30 | class GbLinearDataStore
31 | {
32 | public:
33 | uint64_t allocate()
34 | {
35 | uint64_t handle = m_handleStore.allocateHandle();
36 |
37 | uint32_t index = uint32_t(handle);
38 | if (index >= m_objects.size())
39 | {
40 | m_objects.resize(index + 1);
41 | }
42 |
43 | return handle;
44 | }
45 |
46 | void free(uint64_t handle)
47 | {
48 | assert(m_handleStore.isHandleValid(handle));
49 |
50 | m_handleStore.freeHandle(handle);
51 | }
52 |
53 | bool get(uint64_t handle, T** object)
54 | {
55 | if (!m_handleStore.isHandleValid(handle))
56 | {
57 | assert(false);
58 | return false;
59 | }
60 |
61 | uint32_t index = uint32_t(handle);
62 |
63 | *object = &m_objects[index];
64 | return true;
65 | }
66 |
67 | private:
68 | GbHandleStore m_handleStore;
69 | GbSmallVector m_objects;
70 | };
71 | }
72 |
--------------------------------------------------------------------------------
/src/ggpu/gtl/ggpu/Stager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | namespace gtl
26 | {
27 | class GgpuStager
28 | {
29 | public:
30 | GgpuStager(CgpuDevice device);
31 | ~GgpuStager();
32 |
33 | bool allocate();
34 | void free();
35 |
36 | public:
37 | bool flush();
38 |
39 | bool stageToBuffer(const uint8_t* src, uint64_t size, CgpuBuffer dst, uint64_t dstOffset = 0);
40 |
41 | bool stageToImage(const uint8_t* src, uint64_t size, CgpuImage dst, uint32_t width, uint32_t height, uint32_t depth = 1, uint32_t bpp = 4);
42 |
43 | private:
44 | using CopyFunc = std::function;
45 |
46 | bool stage(const uint8_t* src, uint64_t size, CopyFunc copyFunc, uint32_t offsetAlign = 4);
47 |
48 | private:
49 | CgpuDevice m_device;
50 |
51 | uint32_t m_writeableHalf = 0;
52 | CgpuBuffer m_stagingBuffer;
53 | CgpuCommandBuffer m_commandBuffers[2];
54 | CgpuSemaphore m_semaphore;
55 | uint32_t m_semaphoreCounter = 0;
56 |
57 | bool m_commandsPending = false;
58 | uint64_t m_stagedBytes = 0;
59 | uint8_t* m_mappedMem = nullptr;
60 | };
61 | }
62 |
--------------------------------------------------------------------------------
/src/imgio/impl/Imgio.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "Imgio.h"
19 | #include "PngDecoder.h"
20 | #include "JpegDecoder.h"
21 | #include "ExrDecoder.h"
22 | #include "HdrDecoder.h"
23 | #include "TiffDecoder.h"
24 | #include "TgaDecoder.h"
25 |
26 | #include
27 |
28 | namespace gtl
29 | {
30 | ImgioError ImgioLoadImage(const void* data, size_t size, ImgioImage* img, ImgioLoadFlags flags)
31 | {
32 | bool keepHdr = (flags & ImgioLoadFlags::KeepHdr) != ImgioLoadFlags::None;
33 |
34 | ImgioError r = ImgioPngDecoder::decode(size, data, img);
35 |
36 | if (r == ImgioError::UnsupportedEncoding)
37 | {
38 | r = ImgioJpegDecoder::decode(size, data, img);
39 | }
40 |
41 | if (r == ImgioError::UnsupportedEncoding)
42 | {
43 | r = ImgioExrDecoder::decode(size, data, img, keepHdr);
44 | }
45 |
46 | if (r == ImgioError::UnsupportedEncoding)
47 | {
48 | r = ImgioHdrDecoder::decode(size, data, img, keepHdr);
49 | }
50 |
51 | if (r == ImgioError::UnsupportedEncoding)
52 | {
53 | r = ImgioTiffDecoder::decode(size, data, img);
54 | }
55 |
56 | if (r == ImgioError::UnsupportedEncoding)
57 | {
58 | r = ImgioTgaDecoder::decode(size, data, img);
59 | }
60 |
61 | return r;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/gi/shaders/rp_main.ahit:
--------------------------------------------------------------------------------
1 | #extension GL_GOOGLE_include_directive: require
2 | #extension GL_EXT_ray_tracing: require
3 | #extension GL_EXT_nonuniform_qualifier: enable
4 | #extension GL_EXT_samplerless_texture_functions: require
5 | #extension GL_EXT_shader_16bit_storage: require
6 | #extension GL_EXT_shader_explicit_arithmetic_types_float16: require
7 | #extension GL_EXT_shader_explicit_arithmetic_types_int16: require
8 | #extension GL_EXT_nonuniform_qualifier: require
9 | #extension GL_EXT_shader_explicit_arithmetic_types_int64: require
10 | #extension GL_EXT_buffer_reference: require
11 |
12 | #include "colormap.glsl"
13 |
14 | #if SCENE_DATA_COUNT > 0
15 | #include "mdl_renderer_state.glsl"
16 | #define RENDERER_STATE_TYPE mdl_renderer_state
17 | #endif
18 | #include "mdl_types.glsl"
19 | #include "rp_main_descriptors.glsl"
20 |
21 | #include "mdl_interface.glsl"
22 | #include "mdl_shading_state.glsl"
23 | #include "rp_main_payload.glsl"
24 |
25 | #pragma mdl_generated_code
26 |
27 | #ifndef SHADOW_TEST
28 | layout(location = PAYLOAD_INDEX_SHADE) rayPayloadInEXT ShadeRayPayload rayPayload;
29 | #else
30 | layout(location = PAYLOAD_INDEX_SHADOW) rayPayloadInEXT ShadowRayPayload rayPayload;
31 | #endif
32 |
33 | hitAttributeEXT vec2 baryCoord;
34 |
35 | void main()
36 | {
37 | State shading_state;
38 | vec2 hit_bc = baryCoord;
39 | bool isFrontFace;
40 | setup_mdl_shading_state(hit_bc, shading_state, isFrontFace);
41 |
42 | float opacity = mdl_cutout_opacity(shading_state);
43 |
44 | #ifndef SHADOW_TEST
45 | #if (AOV_MASK & AOV_BIT_DEBUG_OPACITY) != 0
46 | uint imageWidth = PC.imageDims & 0xFFFFu;
47 | uint pixelIndex = gl_LaunchIDEXT.x + gl_LaunchIDEXT.y * imageWidth;
48 | OpacityAov[pixelIndex] = (opacity == 0.0) ? vec3(1.0) : colormap_viridis(opacity);
49 | #endif
50 | #endif
51 |
52 | #ifdef RAND_4D
53 | float k = rng4d_next4f(rayPayload.rng_state).x;
54 | #else
55 | float k = rng1d_next1f(rayPayload.rng_state);
56 | #endif
57 | if (k > opacity)
58 | {
59 | ignoreIntersectionEXT;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/gb/impl/HandleStore.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "HandleStore.h"
19 |
20 | #include
21 |
22 | namespace gtl
23 | {
24 | GbHandleStore::GbHandleStore()
25 | {
26 | m_versions.reserve(1024);
27 | m_freeList.reserve(32);
28 | }
29 |
30 | uint64_t GbHandleStore::allocateHandle()
31 | {
32 | uint32_t index;
33 | uint32_t version;
34 |
35 | if (m_freeList.size() > 0)
36 | {
37 | index = m_freeList.back();
38 | m_freeList.pop_back();
39 | version = m_versions[index];
40 | }
41 | else
42 | {
43 | index = m_maxIndex++;
44 | version = 1;
45 |
46 | assert(m_maxIndex < UINT32_MAX);
47 |
48 | m_versions.resize(m_maxIndex);
49 | m_versions[index] = version;
50 | }
51 |
52 | return (uint64_t(version) << 32ul) | index;
53 | }
54 |
55 | bool GbHandleStore::isHandleValid(uint64_t handle) const
56 | {
57 | uint32_t index = uint32_t(handle);
58 | uint32_t version = uint32_t(handle >> 32ul);
59 |
60 | return version > 0 && index <= m_maxIndex && m_versions[index] == version;
61 | }
62 |
63 | void GbHandleStore::freeHandle(uint64_t handle)
64 | {
65 | uint32_t index = uint32_t(handle);
66 |
67 | m_versions[index]++;
68 | m_freeList.push_back(index);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/gi/impl/MeshProcessing.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace gtl
25 | {
26 | struct GiMeshBuffer
27 | {
28 | bool isCompressed;
29 | uint32_t uncompressedSize;
30 | std::vector data;
31 | };
32 |
33 | struct GiMeshPrimvar
34 | {
35 | std::string name;
36 | GiPrimvarType type;
37 | GiPrimvarInterpolation interpolation;
38 | GiMeshBuffer buffer;
39 | };
40 |
41 | struct GiMeshData
42 | {
43 | GiMeshBuffer faces;
44 | GiMeshBuffer faceIds;
45 | GiMeshBuffer vertices;
46 | std::vector primvars;
47 | uint32_t faceCount;
48 | uint32_t vertexCount;
49 | };
50 |
51 | GiMeshData giProcessMeshData(const std::vector& faces,
52 | const std::vector& faceIds,
53 | const std::vector& vertices,
54 | const std::vector& primvars);
55 |
56 | void giDecompressMeshData(const GiMeshData& cmd,
57 | std::vector& faces,
58 | std::vector& faceIds,
59 | std::vector& vertices,
60 | std::vector& primvars);
61 | }
62 |
--------------------------------------------------------------------------------
/src/gt/gtl/gt/LogFlushListener.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | namespace gtl
23 | {
24 | // This listener must be registered using the doctest
25 | // REGISTER_LISTENER(name, priority, class) macro.
26 | //
27 | // It prevents race conditions between gatling's logger
28 | // and doctest's iostream printing.
29 | struct GtLogFlushListener : doctest::IReporter
30 | {
31 | GtLogFlushListener(const doctest::ContextOptions&);
32 |
33 | void report_query(const doctest::QueryData&) override;
34 |
35 | void test_run_start() override;
36 |
37 | void test_run_end(const doctest::TestRunStats&) override;
38 |
39 | void test_case_start(const doctest::TestCaseData&) override;
40 |
41 | void test_case_reenter(const doctest::TestCaseData&) override;
42 |
43 | void test_case_end(const doctest::CurrentTestCaseStats&) override;
44 |
45 | void test_case_exception(const doctest::TestCaseException&) override;
46 |
47 | void subcase_start(const doctest::SubcaseSignature&) override;
48 |
49 | void subcase_end() override;
50 |
51 | void log_assert(const doctest::AssertData&) override;
52 |
53 | void log_message(const doctest::MessageData&) override;
54 |
55 | void test_case_skipped(const doctest::TestCaseData&) override;
56 | };
57 | }
58 |
--------------------------------------------------------------------------------
/src/gi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(
2 | gi STATIC
3 | gtl/gi/Gi.h
4 | impl/Gi.cpp
5 | impl/AssetReader.h
6 | impl/AssetReader.cpp
7 | impl/GlslShaderCompiler.h
8 | impl/GlslShaderCompiler.cpp
9 | impl/GlslShaderGen.h
10 | impl/GlslShaderGen.cpp
11 | impl/GlslStitcher.h
12 | impl/GlslStitcher.cpp
13 | impl/Mmap.h
14 | impl/Mmap.cpp
15 | impl/MeshProcessing.h
16 | impl/MeshProcessing.cpp
17 | impl/TextureManager.h
18 | impl/TextureManager.cpp
19 | impl/Turbo.h
20 | )
21 |
22 | target_include_directories(
23 | gi
24 | PUBLIC
25 | ${CMAKE_CURRENT_SOURCE_DIR}
26 | PRIVATE
27 | gtl/gi
28 | impl
29 | shaders
30 | )
31 |
32 | target_compile_definitions(
33 | gi
34 | PRIVATE
35 | GI_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
36 | GI_VERSION_MINOR=${PROJECT_VERSION_MINOR}
37 | GI_VERSION_PATCH=${PROJECT_VERSION_PATCH}
38 | GI_SHADER_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/shaders"
39 | )
40 |
41 | target_link_libraries(
42 | gi
43 | PUBLIC
44 | gb
45 | PRIVATE
46 | mc
47 | cgpu
48 | ggpu
49 | imgio
50 | glm
51 | MaterialXCore
52 | MaterialXFormat
53 | glslang
54 | glslang-default-resource-limits
55 | SPIRV
56 | meshoptimizer
57 | blosc2_static
58 | efsw-static
59 | OffsetAllocator
60 | xxHash
61 | )
62 |
63 | if(OpenMP_CXX_FOUND)
64 | target_link_libraries(gi PRIVATE OpenMP::OpenMP_CXX)
65 | endif()
66 |
67 | # Required since library is linked into hdGatling DSO
68 | set_target_properties(gi PROPERTIES POSITION_INDEPENDENT_CODE ON)
69 |
70 | install(
71 | FILES "${MDL_SHARED_LIB}"
72 | DESTINATION "./hdGatling/resources"
73 | COMPONENT hdGatling
74 | )
75 |
76 | install(
77 | DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/shaders"
78 | DESTINATION "./hdGatling/resources"
79 | COMPONENT hdGatling
80 | )
81 |
82 | install(
83 | DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/mdl/"
84 | DESTINATION "./hdGatling/resources/mdl"
85 | COMPONENT hdGatling
86 | )
87 |
88 | install(
89 | DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/mtlx/"
90 | DESTINATION "./hdGatling/resources/mtlx"
91 | COMPONENT hdGatling
92 | )
93 |
--------------------------------------------------------------------------------
/src/gt/impl/LogFlushListener.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "LogFlushListener.h"
19 |
20 | #include
21 |
22 | using namespace doctest;
23 |
24 | namespace gtl
25 | {
26 | // Unfortunately is it not enough to only hook report_query() or log_message().
27 |
28 | GtLogFlushListener::GtLogFlushListener(const ContextOptions&) { gbLogInit(); }
29 |
30 | void GtLogFlushListener::report_query(const QueryData&) { gbLogFlush(); }
31 |
32 | void GtLogFlushListener::test_run_start() { gbLogFlush(); }
33 |
34 | void GtLogFlushListener::test_run_end(const TestRunStats&) { gbLogFlush(); }
35 |
36 | void GtLogFlushListener::test_case_start(const TestCaseData&) { gbLogFlush(); }
37 |
38 | void GtLogFlushListener::test_case_reenter(const TestCaseData&) { gbLogFlush(); }
39 |
40 | void GtLogFlushListener::test_case_end(const CurrentTestCaseStats&) { gbLogFlush(); }
41 |
42 | void GtLogFlushListener::test_case_exception(const TestCaseException&) { gbLogFlush(); }
43 |
44 | void GtLogFlushListener::subcase_start(const SubcaseSignature&) { gbLogFlush(); }
45 |
46 | void GtLogFlushListener::subcase_end() { gbLogFlush(); }
47 |
48 | void GtLogFlushListener::log_assert(const AssertData&) { gbLogFlush(); }
49 |
50 | void GtLogFlushListener::log_message(const MessageData&) { gbLogFlush(); }
51 |
52 | void GtLogFlushListener::test_case_skipped(const TestCaseData&) { gbLogFlush(); }
53 | }
54 |
--------------------------------------------------------------------------------
/src/mc/gtl/mc/Backend.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #include
27 |
28 | namespace gtl
29 | {
30 | class McRuntime;
31 | struct McMdlMaterial;
32 |
33 | struct McTextureDescription
34 | {
35 | uint32_t binding;
36 | bool is3dImage;
37 | bool isFloat;
38 | uint32_t width;
39 | uint32_t height;
40 | uint32_t depth;
41 | std::vector data;
42 | std::string filePath;
43 | };
44 |
45 | struct McGlslGenResult
46 | {
47 | std::string source;
48 | std::vector textureDescriptions;
49 | };
50 |
51 | enum class McDf
52 | {
53 | Scattering,
54 | Emission,
55 | EmissionIntensity,
56 | ThinWalled,
57 | VolumeAbsorption,
58 | VolumeScattering,
59 | CutoutOpacity,
60 | Ior,
61 | BackfaceScattering,
62 | BackfaceEmission,
63 | BackfaceEmissionIntensity,
64 | COUNT
65 | };
66 |
67 | using McDfMap = std::unordered_map;
68 |
69 | class McBackend
70 | {
71 | public:
72 | bool init(McRuntime& runtime);
73 |
74 | bool genGlsl(const McMdlMaterial& material,
75 | McDfMap dfMap,
76 | McGlslGenResult& result);
77 |
78 | private:
79 | class _Impl;
80 | std::shared_ptr<_Impl> m_impl;
81 | };
82 | }
83 |
--------------------------------------------------------------------------------
/src/ggpu/gtl/ggpu/DelayedResourceDestroyer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 |
26 | namespace gtl
27 | {
28 | class GgpuDelayedResourceDestroyer
29 | {
30 | private:
31 | constexpr static uint32_t FrameCount = 4;
32 |
33 | public:
34 | GgpuDelayedResourceDestroyer(CgpuDevice device);
35 |
36 | ~GgpuDelayedResourceDestroyer();
37 |
38 | public:
39 | void nextFrame();
40 | void housekeep();
41 |
42 | void destroyAll();
43 |
44 | template
45 | void enqueueDestruction(T handle, U... moreHandles)
46 | {
47 | enqueueDestruction(handle);
48 | enqueueDestruction(moreHandles...);
49 | }
50 |
51 | void enqueueDestruction(CgpuBuffer handle);
52 | void enqueueDestruction(CgpuImage handle);
53 | void enqueueDestruction(CgpuPipeline handle);
54 | void enqueueDestruction(CgpuSemaphore handle);
55 | void enqueueDestruction(CgpuCommandBuffer handle);
56 | void enqueueDestruction(CgpuBlas handle);
57 | void enqueueDestruction(CgpuTlas handle);
58 |
59 | private:
60 | using DestroyFunc = std::function;
61 |
62 | void enqueueDestroyFunc(DestroyFunc fun);
63 |
64 | private:
65 | CgpuDevice m_device;
66 | uint32_t m_frameIndex = 0;
67 | std::vector m_pendingDestructions[FrameCount];
68 | };
69 | }
70 |
--------------------------------------------------------------------------------
/src/hdGatling/renderBuffer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | namespace gtl
23 | {
24 | struct GiRenderBuffer;
25 | }
26 |
27 | using namespace gtl;
28 |
29 | PXR_NAMESPACE_OPEN_SCOPE
30 |
31 | class HdGatlingRenderBuffer final : public HdRenderBuffer
32 | {
33 | public:
34 | HdGatlingRenderBuffer(const SdfPath& id);
35 |
36 | ~HdGatlingRenderBuffer() override;
37 |
38 | public:
39 | bool Allocate(const GfVec3i& dimensions,
40 | HdFormat format,
41 | bool multiSamples) override;
42 |
43 | public:
44 | unsigned int GetWidth() const override;
45 |
46 | unsigned int GetHeight() const override;
47 |
48 | unsigned int GetDepth() const override;
49 |
50 | HdFormat GetFormat() const override;
51 |
52 | bool IsMultiSampled() const override;
53 |
54 | GiRenderBuffer* GetGiRenderBuffer() const;
55 |
56 | public:
57 | bool IsConverged() const override;
58 |
59 | void SetConverged(bool converged);
60 |
61 | public:
62 | void* Map() override;
63 |
64 | bool IsMapped() const override;
65 |
66 | void Unmap() override;
67 |
68 | void Resolve() override;
69 |
70 | protected:
71 | void _Deallocate() override;
72 |
73 | private:
74 | uint32_t _width;
75 | uint32_t _height;
76 | HdFormat _format;
77 | bool _isMultiSampled;
78 | bool _isConverged;
79 | GiRenderBuffer* _renderBuffer = nullptr;
80 | };
81 |
82 | PXR_NAMESPACE_CLOSE_SCOPE
83 |
--------------------------------------------------------------------------------
/src/imgio/impl/JpegDecoder.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "JpegDecoder.h"
19 | #include "ErrorCodes.h"
20 | #include "Image.h"
21 |
22 | #include
23 | #include
24 |
25 | namespace gtl
26 | {
27 | ImgioError ImgioJpegDecoder::decode(size_t size, const void* data, ImgioImage* img)
28 | {
29 | tjhandle instance = tjInitDecompress();
30 | if (!instance)
31 | {
32 | return ImgioError::Unknown;
33 | }
34 |
35 | int subsamp;
36 | int colorspace;
37 | if (tjDecompressHeader3(instance, (const unsigned char*) data, (unsigned long) size,
38 | (int*) &img->width, (int*) &img->height,
39 | &subsamp, &colorspace) < 0)
40 | {
41 | tjDestroy(instance);
42 | return ImgioError::UnsupportedEncoding;
43 | }
44 |
45 | int pixelFormat = TJPF_RGBA;
46 | img->size = img->width * img->height * tjPixelSize[pixelFormat];
47 | img->data.resize(img->size);
48 |
49 | int result = tjDecompress2(instance, (const unsigned char*) data, (unsigned long) size,
50 | (unsigned char*) &img->data[0], (int) img->width, 0,
51 | (int) img->height, pixelFormat, TJFLAG_ACCURATEDCT | TJFLAG_BOTTOMUP);
52 | tjDestroy(instance);
53 |
54 | if (result < 0)
55 | {
56 | *img = {}; // free memory
57 | return ImgioError::Decode;
58 | }
59 |
60 | return ImgioError::None;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/imgio/impl/TiffDecoder.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2024 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "TiffDecoder.h"
19 | #include "ErrorCodes.h"
20 | #include "Image.h"
21 |
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 |
28 | namespace gtl
29 | {
30 | static std::atomic s_installedErrorHandler = false;
31 |
32 | void _SilentErrorHandler(const char* module, const char* fmt, va_list ap)
33 | {
34 | // Don't log to stderr.
35 | }
36 |
37 | ImgioError ImgioTiffDecoder::decode(size_t size, const void* data, ImgioImage* img)
38 | {
39 | if (!s_installedErrorHandler.exchange(true))
40 | {
41 | TIFFSetErrorHandler(_SilentErrorHandler);
42 | }
43 |
44 | const auto cData = (char*) data;
45 | std::istringstream stream(std::string(cData, cData + size)); // FIXME: don't copy; use custom istream
46 |
47 | TIFF* tiff = TIFFStreamOpen("MemTIFF", &stream);
48 | if (!tiff)
49 | {
50 | return ImgioError::UnsupportedEncoding;
51 | }
52 |
53 | TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &img->width);
54 | TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &img->height);
55 |
56 | img->size = img->width * img->height * 4;
57 | img->data.resize(img->size);
58 |
59 | int result = TIFFReadRGBAImageOriented(tiff, img->width, img->height, (uint32_t*) &img->data[0], ORIENTATION_BOTLEFT, 1);
60 |
61 | TIFFClose(tiff);
62 |
63 | return result ? ImgioError::None : ImgioError::Decode;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/gatling/SimpleRenderTask.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "SimpleRenderTask.h"
19 |
20 | PXR_NAMESPACE_OPEN_SCOPE
21 |
22 | SimpleRenderTask::SimpleRenderTask(const HdRenderPassSharedPtr& renderPass,
23 | const HdRenderPassStateSharedPtr& renderPassState,
24 | const TfTokenVector& renderTags)
25 | : HdTask(SdfPath::EmptyPath())
26 | , m_renderPass(renderPass)
27 | , m_renderPassState(renderPassState)
28 | , m_renderTags(renderTags)
29 | {
30 | }
31 |
32 | void SimpleRenderTask::Sync(HdSceneDelegate* sceneDelegate,
33 | HdTaskContext* taskContext,
34 | HdDirtyBits* dirtyBits)
35 | {
36 | TF_UNUSED(sceneDelegate);
37 | TF_UNUSED(taskContext);
38 |
39 | m_renderPass->Sync();
40 |
41 | *dirtyBits = HdChangeTracker::Clean;
42 | }
43 |
44 | void SimpleRenderTask::Prepare(HdTaskContext* taskContext,
45 | HdRenderIndex* renderIndex)
46 | {
47 | TF_UNUSED(taskContext);
48 |
49 | const HdResourceRegistrySharedPtr& resourceRegistry = renderIndex->GetResourceRegistry();
50 | m_renderPassState->Prepare(resourceRegistry);
51 | }
52 |
53 | void SimpleRenderTask::Execute(HdTaskContext* taskContext)
54 | {
55 | TF_UNUSED(taskContext);
56 |
57 | m_renderPass->Execute(m_renderPassState, m_renderTags);
58 | }
59 |
60 | const TfTokenVector& SimpleRenderTask::GetRenderTags() const
61 | {
62 | return m_renderTags;
63 | }
64 |
65 | PXR_NAMESPACE_CLOSE_SCOPE
66 |
--------------------------------------------------------------------------------
/src/gi/impl/TextureManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 | #include
26 |
27 | namespace gtl
28 | {
29 | class GgpuDelayedResourceDestroyer;
30 | class GgpuStager;
31 | class GiAssetReader;
32 |
33 | using GiImagePtr = std::shared_ptr;
34 |
35 | class GiTextureManager
36 | {
37 | public:
38 | GiTextureManager(CgpuDevice device, GiAssetReader& assetReader, gtl::GgpuStager& stager,
39 | GgpuDelayedResourceDestroyer& delayedResourceDestroyer);
40 |
41 | void housekeep();
42 |
43 | void destroy();
44 |
45 | public:
46 | GiImagePtr loadTextureFromFilePath(const char* filePath,
47 | bool destroyImmediately = false,
48 | bool keepHdr = false);
49 |
50 | bool loadTextureDescriptions(const std::vector& textureDescriptions,
51 | std::vector& images);
52 |
53 | private:
54 | GiImagePtr makeImagePtr(bool destroyImmediately = false);
55 |
56 | private:
57 | CgpuDevice m_device;
58 | GiAssetReader& m_assetReader;
59 | gtl::GgpuStager& m_stager;
60 | GgpuDelayedResourceDestroyer& m_delayedResourceDestroyer;
61 | std::unordered_map> m_fileCache;
62 | std::unordered_map> m_binaryCache;
63 | };
64 | }
65 |
--------------------------------------------------------------------------------
/src/gb/impl/Log.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "Log.h"
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 |
26 | namespace gtl
27 | {
28 | static quill::Logger* s_logger = nullptr;
29 |
30 | void gbLogInit(const std::vector>& extraSinks)
31 | {
32 | if (s_logger)
33 | {
34 | return;
35 | }
36 |
37 | quill::ConsoleSinkConfig::Colours consoleColors;
38 | consoleColors.apply_default_colours();
39 | consoleColors.assign_colour_to_log_level(quill::LogLevel::Info, quill::ConsoleSinkConfig::Colours::white);
40 |
41 | quill::ConsoleSinkConfig config;
42 | config.set_colours(consoleColors);
43 |
44 | auto sink = quill::Frontend::create_or_get_sink("console", config);
45 |
46 | std::vector> sinks = extraSinks;
47 | sinks.push_back(std::move(sink));
48 |
49 | quill::PatternFormatterOptions formatOptions("[%(time)] (%(log_level)) %(message)", "%H:%M:%S.%Qms");
50 | s_logger = quill::Frontend::create_or_get_logger("root", sinks, formatOptions);
51 | #ifdef GTL_VERBOSE
52 | s_logger->set_log_level(quill::LogLevel::Debug);
53 | #endif
54 |
55 | quill::BackendOptions options;
56 | options.thread_name = "GbLog";
57 | quill::Backend::start(options);
58 | }
59 |
60 | quill::Logger* gbGetLogger()
61 | {
62 | return s_logger;
63 | }
64 |
65 | void gbLogFlush()
66 | {
67 | assert(s_logger);
68 | s_logger->flush_log();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/dist/blender/engine.py:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 | #
3 | # SPDX-License-Identifier: Apache-2.0
4 |
5 | import bpy
6 |
7 | from pathlib import Path
8 | from pxr import Plug
9 | import os
10 |
11 |
12 | class GatlingHydraRenderEngine(bpy.types.HydraRenderEngine):
13 | bl_idname = 'HYDRA_GATLING'
14 | bl_label = "Hydra Gatling"
15 | bl_info = "A cross-platform GPU path tracer with hardware ray tracing"
16 |
17 | bl_use_preview = True
18 | bl_use_materialx = True
19 |
20 | bl_delegate_id = 'HdGatlingRendererPlugin'
21 |
22 | @classmethod
23 | def register(cls):
24 | delegate_dir = os.path.join(Path(__file__).parent, "render_delegate")
25 | os.environ['PATH'] = delegate_dir + os.pathsep + os.environ['PATH'] # prepend DLL search dir
26 | Plug.Registry().RegisterPlugins(str(os.path.join(delegate_dir, "hdGatling", "resources")))
27 |
28 | def get_render_settings(self, engine_type):
29 | settings = bpy.context.scene.hydra_gatling.viewport if engine_type == 'VIEWPORT' else \
30 | bpy.context.scene.hydra_gatling.final
31 | result = {
32 | 'spp': settings.spp,
33 | 'max-bounces': settings.max_bounces,
34 | 'rr-bounce-offset': settings.rr_bounce_offset,
35 | 'rr-inv-min-term-prob': settings.rr_inv_min_term_prob,
36 | 'max-sample-value': settings.max_sample_value,
37 | 'next-event-estimation': settings.next_event_estimation,
38 | 'clipping-planes': settings.clipping_planes,
39 | 'medium-stack-size': settings.medium_stack_size,
40 | 'max-volume-walk-length': settings.max_volume_walk_length,
41 | 'progressive-accumulation': settings.progressive_accumulation,
42 | 'enableInteractive': True if engine_type == 'VIEWPORT' else False
43 | }
44 |
45 | if engine_type != 'VIEWPORT':
46 | result |= {
47 | 'aovToken:Combined': "color"
48 | }
49 |
50 | return result
51 |
52 | def update_render_passes(self, scene, render_layer):
53 | if render_layer.use_pass_combined:
54 | self.register_pass(scene, render_layer, 'Combined', 4, 'RGBA', 'COLOR')
55 |
56 |
57 | register, unregister = bpy.utils.register_classes_factory((
58 | GatlingHydraRenderEngine,
59 | ))
60 |
--------------------------------------------------------------------------------
/src/hdGatling/utils.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "utils.h"
19 |
20 | #include
21 | #include
22 |
23 | using namespace gtl;
24 |
25 | PXR_NAMESPACE_OPEN_SCOPE
26 |
27 | bool HdGatlingIsPrimvarTypeSupported(const VtValue& value)
28 | {
29 | return value.IsHolding() ||
30 | value.IsHolding() ||
31 | value.IsHolding() ||
32 | value.IsHolding() ||
33 | value.IsHolding() ||
34 | value.IsHolding() ||
35 | value.IsHolding() ||
36 | value.IsHolding() ||
37 | value.IsHolding();
38 | }
39 |
40 | GiPrimvarType HdGatlingGetGiPrimvarType(HdType type)
41 | {
42 | switch (type)
43 | {
44 | case HdTypeFloat:
45 | return GiPrimvarType::Float;
46 | case HdTypeFloatVec2:
47 | return GiPrimvarType::Vec2;
48 | case HdTypeFloatVec3:
49 | return GiPrimvarType::Vec3;
50 | case HdTypeFloatVec4:
51 | return GiPrimvarType::Vec4;
52 | case HdTypeInt32:
53 | return GiPrimvarType::Int;
54 | case HdTypeInt32Vec2:
55 | return GiPrimvarType::Int2;
56 | case HdTypeInt32Vec3:
57 | return GiPrimvarType::Int3;
58 | case HdTypeInt32Vec4:
59 | return GiPrimvarType::Int4;
60 | default:
61 | TF_CODING_ERROR("primvar type %i unsupported", int(type));
62 | return GiPrimvarType::Float;
63 | }
64 | }
65 |
66 | void HdGatlingConvertVtBoolArrayToVtIntArray(VtValue& values)
67 | {
68 | auto boolArray = values.Get();
69 | VtIntArray intArray(boolArray.size());
70 |
71 | for (int i = 0; i < boolArray.size(); i++)
72 | {
73 | intArray[i] = boolArray[i] ? 1 : 0;
74 | }
75 |
76 | values = std::move(intArray);
77 | }
78 |
79 | PXR_NAMESPACE_CLOSE_SCOPE
80 |
--------------------------------------------------------------------------------
/.github/workflows/deploy-release.yml:
--------------------------------------------------------------------------------
1 | name: Deploy Release
2 |
3 | on:
4 | workflow_call:
5 | inputs:
6 | version-name:
7 | required: true
8 | type: string
9 | tag-name:
10 | required: true
11 | type: string
12 | release-notes:
13 | required: false
14 | type: string
15 | default: 'TBD'
16 | publish-prerelease:
17 | required: false
18 | default: false
19 | type: boolean
20 |
21 | jobs:
22 | build-usd2508:
23 | name: Build for USD v25.08
24 | uses: ./.github/workflows/build-usd.yml
25 | with:
26 | usd-version: 25.08
27 | upload-install-artifacts: true
28 | run-graphical-tests: true
29 |
30 | build-usd2505:
31 | name: Build for USD v25.05
32 | uses: ./.github/workflows/build-usd.yml
33 | with:
34 | usd-version: 25.05
35 | upload-install-artifacts: true
36 | run-graphical-tests: true
37 |
38 | build-usd2502:
39 | name: Build for USD v25.02
40 | uses: ./.github/workflows/build-usd.yml
41 | with:
42 | usd-version: 25.02
43 | upload-install-artifacts: true
44 | run-graphical-tests: true
45 |
46 | build-usd2411:
47 | name: Build for USD v24.11
48 | uses: ./.github/workflows/build-usd.yml
49 | with:
50 | usd-version: 24.11
51 | upload-install-artifacts: true
52 | run-graphical-tests: true
53 |
54 | build-houdini20:
55 | name: Build for Houdini 20.0
56 | uses: ./.github/workflows/build-houdini20.yml
57 |
58 | build-blender50:
59 | name: Build for Blender 5.0
60 | uses: ./.github/workflows/build-blender50.yml
61 |
62 | deploy-release:
63 | name: Deploy Release
64 | needs: [build-usd2508, build-usd2505, build-usd2502, build-usd2411, build-houdini20, build-blender50]
65 | runs-on: ubuntu-latest
66 |
67 | steps:
68 | - name: Download artifacts
69 | uses: actions/download-artifact@v4
70 | with:
71 | merge-multiple: true
72 |
73 | - name: Deploy release
74 | uses: softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b
75 | with:
76 | name: ${{ inputs.version-name }}
77 | body: ${{ inputs.release-notes }}
78 | files: |
79 | *.tar.gz
80 | *.zip
81 | fail_on_unmatched_files: true
82 | tag_name: ${{ inputs.tag-name }}
83 | prerelease: ${{ inputs.publish-prerelease }}
84 | draft: ${{ ! inputs.publish-prerelease }}
85 | make_latest: true
86 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "extern/volk"]
2 | path = extern/volk
3 | url = https://github.com/zeux/volk.git
4 | [submodule "extern/SPIRV-Headers"]
5 | path = extern/SPIRV-Headers
6 | url = https://github.com/KhronosGroup/SPIRV-Headers
7 | [submodule "extern/SPIRV-Tools"]
8 | path = extern/SPIRV-Tools
9 | url = https://github.com/KhronosGroup/SPIRV-Tools
10 | [submodule "extern/glslang"]
11 | path = extern/glslang
12 | url = https://github.com/KhronosGroup/glslang.git
13 | [submodule "extern/VulkanMemoryAllocator"]
14 | path = extern/VulkanMemoryAllocator
15 | url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
16 | [submodule "extern/libspng"]
17 | path = extern/libspng
18 | url = https://github.com/randy408/libspng.git
19 | [submodule "extern/libjpeg-turbo"]
20 | path = extern/libjpeg-turbo
21 | url = https://github.com/pablode/libjpeg-turbo
22 | [submodule "extern/zlib-ng"]
23 | path = extern/zlib-ng
24 | url = https://github.com/zlib-ng/zlib-ng
25 | [submodule "extern/Imath"]
26 | path = extern/Imath
27 | url = https://github.com/AcademySoftwareFoundation/Imath
28 | [submodule "extern/openexr"]
29 | path = extern/openexr
30 | url = https://github.com/AcademySoftwareFoundation/openexr
31 | [submodule "extern/Vulkan-Headers"]
32 | path = extern/Vulkan-Headers
33 | url = https://github.com/KhronosGroup/Vulkan-Headers.git
34 | [submodule "extern/stb"]
35 | path = extern/stb
36 | url = https://github.com/nothings/stb
37 | [submodule "extern/glm"]
38 | path = extern/glm
39 | url = https://github.com/g-truc/glm.git
40 | [submodule "extern/efsw"]
41 | path = extern/efsw
42 | url = https://github.com/SpartanJ/efsw.git
43 | [submodule "extern/SPIRV-Reflect"]
44 | path = extern/SPIRV-Reflect
45 | url = https://github.com/KhronosGroup/SPIRV-Reflect.git
46 | [submodule "extern/quill"]
47 | path = extern/quill
48 | url = https://github.com/odygrd/quill.git
49 | [submodule "extern/doctest"]
50 | path = extern/doctest
51 | url = https://github.com/doctest/doctest.git
52 | [submodule "extern/libtiff"]
53 | path = extern/libtiff
54 | url = https://gitlab.com/libtiff/libtiff.git
55 | [submodule "extern/meshoptimizer"]
56 | path = extern/meshoptimizer
57 | url = https://github.com/zeux/meshoptimizer.git
58 | [submodule "extern/c-blosc2"]
59 | path = extern/c-blosc2
60 | url = https://github.com/Blosc/c-blosc2.git
61 | [submodule "extern/OffsetAllocator"]
62 | path = extern/OffsetAllocator
63 | url = https://github.com/sebbbi/OffsetAllocator.git
64 | [submodule "extern/xxHash"]
65 | path = extern/xxHash
66 | url = https://github.com/Cyan4973/xxHash.git
67 |
--------------------------------------------------------------------------------
/src/ggpu/gtl/ggpu/SyncBuffer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 |
26 | #include "ResizableBuffer.h"
27 |
28 | namespace gtl
29 | {
30 | class GgpuStager;
31 | class GgpuDelayedResourceDestroyer;
32 |
33 | class GgpuSyncBuffer
34 | {
35 | public:
36 | GgpuSyncBuffer(CgpuDevice device,
37 | GgpuStager& stager,
38 | GgpuDelayedResourceDestroyer& delayedResourceDestroyer,
39 | uint64_t elementSize,
40 | CgpuBufferUsage bufferUsage = CgpuBufferUsage::Storage);
41 |
42 | ~GgpuSyncBuffer();
43 |
44 | public:
45 | uint8_t* read(uint64_t byteOffset, uint64_t byteSize);
46 |
47 | uint8_t* write(uint64_t byteOffset, uint64_t byteSize);
48 |
49 | template
50 | T* read(uint64_t offset, uint64_t range)
51 | {
52 | return (T*) write(offset * m_elementSize, range * m_elementSize);
53 | }
54 |
55 | template
56 | T* write(uint64_t offset, uint64_t range)
57 | {
58 | return (T*) write(offset * m_elementSize, range * m_elementSize);
59 | }
60 |
61 | bool resize(CgpuDevice device, CgpuCommandBuffer commandBuffer, uint64_t newSize);
62 |
63 | CgpuBuffer buffer() const;
64 |
65 | uint64_t byteSize() const;
66 |
67 | bool commitChanges();
68 |
69 | private:
70 | CgpuDevice m_device;
71 | GgpuStager& m_stager;
72 | uint64_t m_elementSize;
73 |
74 | uint64_t m_size = 0;
75 | GgpuResizableBuffer m_deviceBuffer; // only for OptimalStaging strategy
76 | GgpuResizableBuffer m_hostBuffer;
77 |
78 | uint8_t* m_mappedHostMem = nullptr;
79 | uint64_t m_dirtyRangeBegin = UINT64_MAX;
80 | uint64_t m_dirtyRangeEnd = 0;
81 | };
82 | }
83 |
--------------------------------------------------------------------------------
/src/ggpu/gtl/ggpu/LinearDataStore.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | #include
25 | #include
26 |
27 | #include "SyncBuffer.h"
28 |
29 | namespace gtl
30 | {
31 | class GgpuStager;
32 | class GgpuDelayedResourceDestroyer;
33 |
34 | class GgpuLinearDataStore
35 | {
36 | public:
37 | GgpuLinearDataStore(CgpuDevice device,
38 | GgpuStager& stager,
39 | GgpuDelayedResourceDestroyer& delayedResourceDestroyer,
40 | uint64_t elementSize,
41 | uint32_t minCapacity);
42 |
43 | virtual ~GgpuLinearDataStore();
44 |
45 | public:
46 | virtual uint64_t allocate();
47 |
48 | virtual void free(uint64_t handle);
49 |
50 | template
51 | T* read(uint64_t handle)
52 | {
53 | return (T*) readRaw(handle);
54 | }
55 |
56 | template
57 | T* write(uint64_t handle)
58 | {
59 | return (T*) writeRaw(handle);
60 | }
61 |
62 | CgpuBuffer buffer() const;
63 |
64 | uint64_t bufferSize() const;
65 |
66 | bool commitChanges();
67 |
68 | uint32_t elementCount() const;
69 |
70 | protected:
71 | virtual uint8_t* readRaw(uint64_t handle);
72 | virtual uint8_t* writeRaw(uint64_t handle);
73 | uint8_t* readFromIndex(uint32_t index);
74 | uint8_t* writeToIndex(uint32_t index);
75 |
76 | private:
77 | uint64_t returnOrAllocHandle(uint64_t handle);
78 | uint64_t returnOrAllocIndex(uint32_t index);
79 |
80 | private:
81 | CgpuDevice m_device;
82 | uint64_t m_elementSize;
83 | uint32_t m_minCapacity;
84 | uint32_t m_elementCount;
85 |
86 | GbHandleStore m_handleStore;
87 | GgpuSyncBuffer m_buffer;
88 | };
89 | }
90 |
--------------------------------------------------------------------------------
/src/gi/shaders/interface/gtl.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2023 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #ifndef GTL_H
19 | #define GTL_H
20 |
21 | #ifdef __cplusplus
22 |
23 | #include
24 |
25 | namespace gtl
26 | {
27 | namespace shader_interface
28 | {
29 | using GI_INT = int32_t;
30 | using GI_UINT = uint32_t;
31 | using GI_UINT64 = uint64_t;
32 | using GI_FLOAT = float;
33 | using GI_VEC2 = glm::vec2;
34 | using GI_VEC3 = glm::vec3;
35 | using GI_VEC4 = glm::vec4;
36 | using GI_IVEC2 = glm::ivec2;
37 | using GI_IVEC3 = glm::ivec3;
38 | using GI_IVEC4 = glm::ivec4;
39 | using GI_UVEC2 = glm::uvec2;
40 | using GI_UVEC3 = glm::uvec3;
41 | using GI_UVEC4 = glm::uvec4;
42 | using GI_MAT3 = glm::mat3;
43 | using GI_MAT3x4 = glm::mat3x4;
44 | }
45 | }
46 |
47 | #define GI_INTERFACE_BEGIN(NAME) \
48 | namespace gtl { \
49 | namespace shader_interface { \
50 | namespace NAME {
51 |
52 | #define GI_INTERFACE_END() \
53 | } \
54 | } \
55 | }
56 |
57 | #define GI_BINDING_INDEX(NAME, IDX) \
58 | constexpr static uint32_t BINDING_INDEX_##NAME = IDX;
59 |
60 | #else
61 |
62 | #define GI_INT int
63 | #define GI_UINT uint
64 | #define GI_UINT64 uint64_t
65 | #define GI_FLOAT float
66 | #define GI_VEC2 vec2
67 | #define GI_VEC3 vec3
68 | #define GI_VEC4 vec4
69 | #define GI_iVEC2 ivec2
70 | #define GI_iVEC3 ivec3
71 | #define GI_iVEC4 ivec4
72 | #define GI_UVEC2 uvec2
73 | #define GI_UVEC3 uvec3
74 | #define GI_UVEC4 uvec4
75 | #define GI_MAT3 mat3
76 | #define GI_MAT3x4 mat3x4
77 |
78 | #define GI_INTERFACE_BEGIN(NAME)
79 | #define GI_INTERFACE_END()
80 |
81 | #define GI_BINDING_INDEX(NAME,IDX) \
82 | const uint BINDING_INDEX_##NAME = IDX;
83 |
84 | #endif
85 |
86 | #endif
87 |
--------------------------------------------------------------------------------
/src/imgio/impl/HdrDecoder.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #include "HdrDecoder.h"
19 | #include "ErrorCodes.h"
20 | #include "Image.h"
21 |
22 | #define STB_IMAGE_IMPLEMENTATION
23 | #define STB_IMAGE_STATIC
24 | #define STBI_FAILURE_USERMSG
25 | #define STBI_ONLY_HDR
26 | #include
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | namespace gtl
33 | {
34 | ImgioError ImgioHdrDecoder::decode(size_t size, const void* data, ImgioImage* img, bool keepHdr)
35 | {
36 | if (!stbi_is_hdr_from_memory((const stbi_uc*) data, (int) size))
37 | {
38 | return ImgioError::UnsupportedEncoding;
39 | }
40 |
41 | stbi_set_flip_vertically_on_load(1);
42 |
43 | float* hdrData = stbi_loadf_from_memory((const stbi_uc*) data, (int) size, (int*) &img->width, (int*) &img->height, nullptr, 4);
44 |
45 | if (!hdrData)
46 | {
47 | return ImgioError::Decode;
48 | }
49 |
50 | uint32_t bytesPerPixel = keepHdr ? 8 : 4;
51 |
52 | img->size = img->width * img->height * bytesPerPixel;
53 | img->data.resize(img->size, 0);
54 | img->format = keepHdr ? ImgioFormat::RGBA16_FLOAT : ImgioFormat::RGBA8_UNORM;
55 |
56 | const float* floatDataIn = (const float*) hdrData;
57 | uint8_t* byteDataOut = &img->data[0];
58 | half* halfDataOut = (half*) &img->data[0];
59 |
60 | for (uint32_t i = 0; i < img->width; i++)
61 | for (uint32_t j = 0; j < img->height; j++)
62 | {
63 | uint32_t idx = (i + j * img->width) * 4;
64 |
65 | for (uint32_t k = 0; k < 4; k++)
66 | {
67 | if (keepHdr)
68 | {
69 | halfDataOut[idx + k] = half(floatDataIn[idx + k]);
70 | }
71 | else
72 | {
73 | byteDataOut[idx + k] = uint8_t(std::min(int(floatDataIn[idx + k] * 255.0f), 255));
74 | }
75 | }
76 | }
77 |
78 | stbi_image_free(hdrData);
79 | return ImgioError::None;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/mc/impl/MdlRuntime.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2019-2022 Pablo Delgado Krämer
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 | //
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | #include "MdlEntityResolver.h"
35 | #include "MdlLogger.h"
36 |
37 | namespace gtl
38 | {
39 | class McMdlLogger;
40 | class McMdlNeurayLoader;
41 |
42 | class McMdlRuntime
43 | {
44 | public:
45 | McMdlRuntime();
46 | ~McMdlRuntime();
47 |
48 | public:
49 | bool init(std::string_view libDir, const std::vector& mdlSearchPaths);
50 |
51 | mi::base::Handle getLogger();
52 | mi::base::Handle getDatabase();
53 | mi::base::Handle getTransaction();
54 | mi::base::Handle getFactory();
55 | mi::base::Handle getConfig();
56 | mi::base::Handle getImpExpApi();
57 | mi::base::Handle getBackendApi();
58 |
59 | private:
60 | std::shared_ptr m_loader;
61 |
62 | mi::base::Handle m_logger;
63 | mi::base::Handle m_entityResolver;
64 |
65 | mi::base::Handle m_neuray;
66 | mi::base::Handle