├── 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 m_database; 67 | mi::base::Handle m_transaction; 68 | mi::base::Handle m_config; 69 | mi::base::Handle m_factory; 70 | mi::base::Handle m_backendApi; 71 | mi::base::Handle m_impExpApi; 72 | }; 73 | } 74 | -------------------------------------------------------------------------------- /src/imgio/impl/PngDecoder.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 "PngDecoder.h" 19 | #include "ErrorCodes.h" 20 | #include "Image.h" 21 | 22 | #include 23 | #include 24 | 25 | namespace gtl 26 | { 27 | static void _FlipImage(ImgioImage* img) 28 | { 29 | for (uint32_t i = 0; i < img->height / 2; i++) 30 | for (uint32_t j = 0; j < img->width; j++) 31 | for (uint32_t k = 0; k < 4; k++) 32 | { 33 | uint32_t ipix = (i * img->width + j) * 4; 34 | uint32_t opix = ((img->height - i - 1) * img->width + j) * 4; 35 | 36 | std::swap(img->data[ipix + k], img->data[opix + k]); 37 | } 38 | } 39 | 40 | ImgioError ImgioPngDecoder::decode(size_t size, const void* data, ImgioImage* img) 41 | { 42 | int err; 43 | 44 | spng_ctx* ctx = spng_ctx_new(0); 45 | 46 | err = spng_set_png_buffer(ctx, data, size); 47 | if (err != SPNG_OK) 48 | { 49 | goto fail; 50 | } 51 | 52 | err = spng_decoded_image_size(ctx, SPNG_FMT_RGBA8, &img->size); 53 | if (err != SPNG_OK) 54 | { 55 | goto fail; 56 | } 57 | 58 | img->data.resize(img->size); 59 | 60 | err = spng_decode_image(ctx, &img->data[0], img->size, SPNG_FMT_RGBA8, 0); 61 | if (err != SPNG_OK) 62 | { 63 | goto fail; 64 | } 65 | 66 | spng_ihdr ihdr; 67 | err = spng_get_ihdr(ctx, &ihdr); 68 | if (err != SPNG_OK) 69 | { 70 | goto fail; 71 | } 72 | 73 | img->width = ihdr.width; 74 | img->height = ihdr.height; 75 | 76 | spng_ctx_free(ctx); 77 | 78 | _FlipImage(img); 79 | 80 | return ImgioError::None; 81 | 82 | fail: 83 | *img = {}; // free memory 84 | 85 | spng_ctx_free(ctx); 86 | 87 | if (err == SPNG_ESIGNATURE) 88 | { 89 | return ImgioError::UnsupportedEncoding; 90 | } 91 | else if (err == SPNG_IO_ERROR || err == SPNG_IO_EOF) 92 | { 93 | return ImgioError::CorruptData; 94 | } 95 | else 96 | { 97 | return ImgioError::Decode; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/hdGatling/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 | #include "materialNetworkCompiler.h" 20 | 21 | #include 22 | 23 | using namespace gtl; 24 | 25 | PXR_NAMESPACE_OPEN_SCOPE 26 | 27 | HdGatlingMaterial::HdGatlingMaterial(const SdfPath& id, 28 | GiScene* scene, 29 | const MaterialNetworkCompiler& materialNetworkCompiler) 30 | : HdMaterial(id) 31 | , _materialNetworkCompiler(materialNetworkCompiler) 32 | , _giScene(scene) 33 | { 34 | } 35 | 36 | void HdGatlingMaterial::Finalize(HdRenderParam* renderParam) 37 | { 38 | if (_giMaterial) 39 | { 40 | giDestroyMaterial(_giMaterial); 41 | _giMaterial = nullptr; 42 | } 43 | } 44 | 45 | HdDirtyBits HdGatlingMaterial::GetInitialDirtyBitsMask() const 46 | { 47 | return DirtyBits::DirtyParams; 48 | } 49 | 50 | void HdGatlingMaterial::Sync(HdSceneDelegate* sceneDelegate, 51 | HdRenderParam* renderParam, 52 | HdDirtyBits* dirtyBits) 53 | { 54 | TF_UNUSED(renderParam); 55 | 56 | bool pullMaterial = (*dirtyBits & DirtyBits::DirtyParams); 57 | 58 | *dirtyBits = DirtyBits::Clean; 59 | 60 | if (!pullMaterial) 61 | { 62 | return; 63 | } 64 | 65 | if (_giMaterial) 66 | { 67 | giDestroyMaterial(_giMaterial); 68 | _giMaterial = nullptr; 69 | } 70 | 71 | const SdfPath& id = GetId(); 72 | const VtValue& resource = sceneDelegate->GetMaterialResource(id); 73 | 74 | if (!resource.IsHolding()) 75 | { 76 | return; 77 | } 78 | 79 | const HdMaterialNetworkMap& networkMap = resource.UncheckedGet(); 80 | bool isVolume = false; 81 | 82 | HdMaterialNetwork2 network = HdConvertToHdMaterialNetwork2(networkMap, &isVolume); 83 | if (isVolume) 84 | { 85 | TF_WARN("Volume %s unsupported", id.GetText()); 86 | return; 87 | } 88 | 89 | _giMaterial = _materialNetworkCompiler.CompileNetwork(_giScene, id, network); 90 | } 91 | 92 | GiMaterial* HdGatlingMaterial::GetGiMaterial() const 93 | { 94 | return _giMaterial; 95 | } 96 | 97 | PXR_NAMESPACE_CLOSE_SCOPE 98 | -------------------------------------------------------------------------------- /src/hdGatling/mdlDiscoveryPlugin.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 "mdlDiscoveryPlugin.h" 19 | #include "tokens.h" 20 | 21 | #include 22 | 23 | PXR_NAMESPACE_OPEN_SCOPE 24 | 25 | #if PXR_VERSION >= 2508 26 | SdrShaderNodeDiscoveryResultVec HdGatlingMdlDiscoveryPlugin::DiscoverShaderNodes([[maybe_unused]] const Context& ctx) 27 | { 28 | SdrShaderNodeDiscoveryResultVec result; 29 | 30 | SdrShaderNodeDiscoveryResult mdlNode( 31 | HdGatlingNodeIdentifiers->mdl, // identifier 32 | SdrVersion(1), // version 33 | HdGatlingNodeIdentifiers->mdl, // name 34 | TfToken(), // family 35 | HdGatlingDiscoveryTypes->mdl, // discoveryType 36 | HdGatlingSourceTypes->mdl, // sourceType 37 | std::string(), // uri 38 | std::string() // resolvedUri 39 | ); 40 | result.push_back(mdlNode); 41 | 42 | return result; 43 | } 44 | 45 | const SdrStringVec& HdGatlingMdlDiscoveryPlugin::GetSearchURIs() const 46 | { 47 | static const SdrStringVec s_searchURIs; 48 | return s_searchURIs; 49 | } 50 | 51 | SDR_REGISTER_DISCOVERY_PLUGIN(HdGatlingMdlDiscoveryPlugin); 52 | 53 | #else 54 | 55 | NdrNodeDiscoveryResultVec HdGatlingMdlDiscoveryPlugin::DiscoverNodes([[maybe_unused]] const Context& ctx) 56 | { 57 | NdrNodeDiscoveryResultVec result; 58 | 59 | NdrNodeDiscoveryResult mdlNode( 60 | HdGatlingNodeIdentifiers->mdl, // identifier 61 | NdrVersion(1), // version 62 | HdGatlingNodeIdentifiers->mdl, // name 63 | TfToken(), // family 64 | HdGatlingDiscoveryTypes->mdl, // discoveryType 65 | HdGatlingSourceTypes->mdl, // sourceType 66 | std::string(), // uri 67 | std::string() // resolvedUri 68 | ); 69 | result.push_back(mdlNode); 70 | 71 | return result; 72 | } 73 | 74 | const NdrStringVec& HdGatlingMdlDiscoveryPlugin::GetSearchURIs() const 75 | { 76 | static const NdrStringVec s_searchURIs; 77 | return s_searchURIs; 78 | } 79 | 80 | NDR_REGISTER_DISCOVERY_PLUGIN(HdGatlingMdlDiscoveryPlugin); 81 | #endif 82 | 83 | PXR_NAMESPACE_CLOSE_SCOPE 84 | -------------------------------------------------------------------------------- /src/mc/impl/MdlEntityResolver.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 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace gtl 30 | { 31 | struct McMdlEntityResolverUserData : public mi::base::Interface_implement 32 | { 33 | std::string dirPrefix; 34 | }; 35 | 36 | class McMdlEntityResolver 37 | : public mi::base::Interface_implement 38 | { 39 | public: 40 | McMdlEntityResolver(mi::base::Handle impExpApi, 41 | mi::base::Handle standardResolver); 42 | 43 | mi::neuraylib::IMdl_resolved_module* resolve_module(const char* module_name, 44 | const char* owner_file_path, 45 | const char* owner_name, 46 | mi::Sint32 pos_line, 47 | mi::Sint32 pos_column, 48 | mi::neuraylib::IMdl_execution_context* context = 0) override; 49 | 50 | mi::neuraylib::IMdl_resolved_resource* resolve_resource(const char* file_path, 51 | const char* owner_file_path, 52 | const char* owner_name, 53 | mi::Sint32 pos_line, 54 | mi::Sint32 pos_column, 55 | mi::neuraylib::IMdl_execution_context* context = 0) override; 56 | private: 57 | mi::base::Handle m_standardResolver; 58 | mi::base::Handle m_impExpApi; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /src/imgio/impl/main.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 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include "Imgio.h" 25 | 26 | namespace fs = std::filesystem; 27 | using namespace gtl; 28 | 29 | bool _ReadFile(const fs::path& filePath, std::vector& data) 30 | { 31 | std::ifstream file(filePath, std::ios_base::in | std::ios_base::binary); 32 | if (!file.is_open()) 33 | { 34 | return false; 35 | } 36 | file.seekg(0, std::ios_base::end); 37 | data.resize(file.tellg()); 38 | file.seekg(0, std::ios_base::beg); 39 | file.read((char*) &data[0], data.size()); 40 | return file.good() && data.size() > 0; 41 | } 42 | 43 | void _LoadOriented(const char* fileName, const std::vector& ref) 44 | { 45 | ImgioImage img; 46 | std::vector fileData; 47 | 48 | REQUIRE(_ReadFile(fs::path(IMGIO_TESTENV_DIR) / fileName, fileData)); 49 | CHECK_EQ(ImgioLoadImage(&fileData[0], fileData.size(), &img), ImgioError::None); 50 | CHECK_EQ(img.data, ref); 51 | } 52 | 53 | static const std::vector REF_4C = {255, 0, 0, 255, // red 54 | 0, 0, 255, 255, // blue 55 | 255, 255, 255, 255, // white 56 | 0, 255, 0, 255}; // green 57 | 58 | static const std::vector REF_4C_JPG = {254, 0, 0, 255, // red 59 | 0, 0, 254, 255, // blue 60 | 255, 255, 255, 255, // white 61 | 1, 255, 1, 255}; // green 62 | 63 | TEST_CASE("LoadOriented.Png") 64 | { 65 | _LoadOriented("4c.png", REF_4C); 66 | } 67 | 68 | TEST_CASE("LoadOriented.Tiff") 69 | { 70 | _LoadOriented("4c.tiff", REF_4C); 71 | } 72 | 73 | TEST_CASE("LoadOriented.Exr") 74 | { 75 | _LoadOriented("4c.exr", REF_4C); 76 | } 77 | 78 | TEST_CASE("LoadOriented.Hdr") 79 | { 80 | _LoadOriented("4c.hdr", REF_4C); 81 | } 82 | 83 | TEST_CASE("LoadOriented.Jpg") 84 | { 85 | _LoadOriented("4c.jpg", REF_4C_JPG); 86 | } 87 | 88 | TEST_CASE("LoadOriented.Tga") 89 | { 90 | _LoadOriented("4c.tga", REF_4C); 91 | } 92 | -------------------------------------------------------------------------------- /src/ggpu/impl/DenseDataStore.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 "DenseDataStore.h" 19 | 20 | #include 21 | 22 | namespace gtl 23 | { 24 | GgpuDenseDataStore::GgpuDenseDataStore(CgpuDevice device, 25 | GgpuStager& stager, 26 | GgpuDelayedResourceDestroyer& delayedResourceDestroyer, 27 | uint64_t elementSize, 28 | uint32_t minCapacity) 29 | : GgpuLinearDataStore(device, stager, delayedResourceDestroyer, elementSize, minCapacity) 30 | , m_elementSize(elementSize) 31 | { 32 | m_indexMap.reserve(minCapacity); 33 | } 34 | 35 | uint64_t GgpuDenseDataStore::allocate() 36 | { 37 | uint64_t handle = GgpuLinearDataStore::allocate(); 38 | 39 | m_indexMap[handle] = m_highestIndex; 40 | m_highestIndex += 1; 41 | 42 | return handle; 43 | } 44 | 45 | void GgpuDenseDataStore::free(uint64_t handle) 46 | { 47 | if (m_highestIndex == 1) 48 | { 49 | // No swapping needed/possible. 50 | m_highestIndex = 0; 51 | return; 52 | } 53 | 54 | auto indexIt = m_indexMap.find(handle); 55 | if (indexIt == m_indexMap.end()) 56 | { 57 | assert(false); 58 | return; 59 | } 60 | 61 | uint32_t freedIndex = indexIt->second; 62 | uint8_t* dstPtr = GgpuLinearDataStore::writeToIndex(freedIndex); 63 | uint8_t* srcPtr = GgpuLinearDataStore::readFromIndex(m_highestIndex); 64 | 65 | memcpy((void*) dstPtr, (void*) srcPtr, m_elementSize); 66 | m_highestIndex--; 67 | 68 | GgpuLinearDataStore::free(handle); 69 | } 70 | 71 | uint8_t* GgpuDenseDataStore::readRaw(uint64_t handle) 72 | { 73 | auto indexIt = m_indexMap.find(handle); 74 | if (indexIt == m_indexMap.end()) 75 | { 76 | assert(false); 77 | return nullptr; 78 | } 79 | 80 | return GgpuLinearDataStore::readFromIndex(indexIt->second); 81 | } 82 | 83 | uint8_t* GgpuDenseDataStore::writeRaw(uint64_t handle) 84 | { 85 | auto indexIt = m_indexMap.find(handle); 86 | if (indexIt == m_indexMap.end()) 87 | { 88 | assert(false); 89 | return nullptr; 90 | } 91 | 92 | return GgpuLinearDataStore::writeToIndex(indexIt->second); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/gi/shaders/rp_main.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_nonuniform_qualifier: require 7 | #extension GL_EXT_shader_explicit_arithmetic_types_int64: require 8 | #extension GL_EXT_buffer_reference: require 9 | 10 | #include "rp_main_payload.glsl" 11 | #include "rp_main_descriptors.glsl" 12 | 13 | layout(location = PAYLOAD_INDEX_SHADE) rayPayloadInEXT ShadeRayPayload rayPayload; 14 | 15 | #if MEDIUM_STACK_SIZE > 0 16 | void stepVolume(uint mediumIdx) 17 | { 18 | float distance = gl_RayTmaxEXT * PC.metersPerSceneUnit; 19 | 20 | Medium m = rayPayload.media[mediumIdx - 1]; 21 | 22 | vec3 transmittance = exp(m.sigma_t * -distance); 23 | 24 | vec3 density = m.sigma_t * transmittance; 25 | 26 | float pdf = dot(rayPayload.walkSegmentPdf, density); 27 | 28 | rayPayload.throughput *= (m.sigma_s * transmittance) / pdf; 29 | 30 | rayPayload.ray_origin += gl_WorldRayDirectionEXT * distance; 31 | 32 | rayPayload.bitfield |= SHADE_RAY_PAYLOAD_VOLUME_WALK_MISS_FLAG; 33 | shadeRayPayloadIncrementWalk(rayPayload); 34 | } 35 | #endif 36 | 37 | // Optimized implementation from GLM with only cross products: 38 | // https://github.com/g-truc/glm/blob/47585fde0c49fa77a2bf2fb1d2ead06999fd4b6e/glm/detail/type_quat.inl#L356-L363 39 | vec3 quatRotateDir(vec4 q, vec3 dir) 40 | { 41 | vec3 a = cross(q.xyz, dir); 42 | vec3 b = cross(q.xyz, a); 43 | return dir + ((a * q.w) + b) * 2.0; 44 | } 45 | 46 | vec3 sampleDomeLight(uint domeLightIndex, vec3 rayDir) 47 | { 48 | float u = (atan(rayDir.z, rayDir.x) + 0.5 * PI) / (2.0 * PI); 49 | float v = 1.0 - acos(rayDir.y) / PI; 50 | 51 | const uint lodLevel = 0; 52 | return textureLod(sampler2D(textures_2d[nonuniformEXT(domeLightIndex)], tex_sampler), vec2(u, v), lodLevel).rgb; 53 | } 54 | 55 | void main() 56 | { 57 | #if MEDIUM_STACK_SIZE > 0 58 | uint mediumIdx = shadeRayPayloadGetMediumIdx(rayPayload); 59 | 60 | if (mediumIdx > 0) 61 | { 62 | stepVolume(mediumIdx); 63 | 64 | return; 65 | } 66 | #endif 67 | 68 | rayPayload.bitfield |= SHADE_RAY_PAYLOAD_TERMINATE_FLAG; 69 | 70 | #if (AOV_MASK & AOV_BIT_COLOR) == 0 71 | return; // early-out if color AOV not requested 72 | #endif 73 | 74 | bool useFallbackDomeLight = false; 75 | 76 | #ifndef DOME_LIGHT_CAMERA_VISIBLE 77 | bool isPrimaryRay = (rayPayload.bitfield & SHADE_RAY_PAYLOAD_BOUNCES_MASK) == 0; 78 | 79 | useFallbackDomeLight = isPrimaryRay; 80 | #endif 81 | 82 | uint domeLightIndex = useFallbackDomeLight ? 0 : 1; 83 | vec3 sampleDir = normalize(quatRotateDir(PC.domeLightRotation, gl_WorldRayDirectionEXT)); 84 | vec3 radiance = sampleDomeLight(domeLightIndex, sampleDir) * PC.domeLightEmissionMultiplier; 85 | 86 | rayPayload.radiance += rayPayload.throughput * radiance; 87 | } 88 | -------------------------------------------------------------------------------- /src/hdGatling/mdlParserPlugin.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 "mdlParserPlugin.h" 19 | #include "tokens.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | PXR_NAMESPACE_OPEN_SCOPE 28 | 29 | #if PXR_VERSION >= 2508 30 | SdrShaderNodeUniquePtr HdGatlingMdlParserPlugin::ParseShaderNode(const SdrShaderNodeDiscoveryResult& discoveryResult) 31 | { 32 | SdrTokenMap metadata = discoveryResult.metadata; 33 | metadata[HdGatlingNodeMetadata->subIdentifier] = discoveryResult.subIdentifier; 34 | 35 | return std::make_unique( 36 | discoveryResult.identifier, 37 | discoveryResult.version, 38 | discoveryResult.name, 39 | discoveryResult.family, 40 | HdGatlingNodeContexts->mdl, 41 | discoveryResult.sourceType, 42 | discoveryResult.uri, 43 | discoveryResult.resolvedUri, 44 | SdrShaderPropertyUniquePtrVec{}, 45 | metadata 46 | ); 47 | } 48 | 49 | const SdrTokenVec& HdGatlingMdlParserPlugin::GetDiscoveryTypes() const 50 | { 51 | static SdrTokenVec s_discoveryTypes{ HdGatlingDiscoveryTypes->mdl }; 52 | return s_discoveryTypes; 53 | } 54 | 55 | #else 56 | 57 | NdrNodeUniquePtr HdGatlingMdlParserPlugin::Parse(const NdrNodeDiscoveryResult& discoveryResult) 58 | { 59 | NdrTokenMap metadata = discoveryResult.metadata; 60 | metadata[HdGatlingNodeMetadata->subIdentifier] = discoveryResult.subIdentifier; 61 | 62 | return std::make_unique( 63 | discoveryResult.identifier, 64 | discoveryResult.version, 65 | discoveryResult.name, 66 | discoveryResult.family, 67 | HdGatlingNodeContexts->mdl, 68 | discoveryResult.sourceType, 69 | discoveryResult.uri, 70 | discoveryResult.resolvedUri, 71 | NdrPropertyUniquePtrVec{}, 72 | metadata 73 | ); 74 | } 75 | 76 | const NdrTokenVec& HdGatlingMdlParserPlugin::GetDiscoveryTypes() const 77 | { 78 | static NdrTokenVec s_discoveryTypes{ HdGatlingDiscoveryTypes->mdl }; 79 | return s_discoveryTypes; 80 | } 81 | #endif 82 | 83 | const TfToken& HdGatlingMdlParserPlugin::GetSourceType() const 84 | { 85 | return HdGatlingSourceTypes->mdl; 86 | } 87 | 88 | #if PXR_VERSION >= 2508 89 | SDR_REGISTER_PARSER_PLUGIN(HdGatlingMdlParserPlugin); 90 | #else 91 | NDR_REGISTER_PARSER_PLUGIN(HdGatlingMdlParserPlugin); 92 | #endif 93 | 94 | PXR_NAMESPACE_CLOSE_SCOPE 95 | -------------------------------------------------------------------------------- /src/gi/impl/GlslStitcher.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 "GlslStitcher.h" 19 | 20 | #include 21 | #include 22 | 23 | namespace detail 24 | { 25 | bool readTextFromFile(const fs::path& filePath, std::string& text) 26 | { 27 | std::ifstream file(filePath, std::ios_base::in | std::ios_base::binary); 28 | if (!file.is_open()) 29 | { 30 | return false; 31 | } 32 | file.seekg(0, std::ios_base::end); 33 | text.resize(file.tellg(), ' '); 34 | file.seekg(0, std::ios_base::beg); 35 | file.read(&text[0], text.size()); 36 | return file.good(); 37 | } 38 | } 39 | 40 | namespace gtl 41 | { 42 | GiGlslStitcher::GiGlslStitcher() 43 | { 44 | // Full float precision so that we don't cut off epsilons 45 | m_source.precision(std::numeric_limits::max_digits10); 46 | // Ensure no integer literals are emitted for floats 47 | m_source.setf(std::ios::fixed | std::ios::showpoint); 48 | } 49 | 50 | void GiGlslStitcher::appendVersion() 51 | { 52 | m_source << "#version 460 core\n"; 53 | } 54 | 55 | void GiGlslStitcher::appendDefine(std::string_view name) 56 | { 57 | m_source << "#define " << name << "\n"; 58 | } 59 | 60 | void GiGlslStitcher::appendDefine(std::string_view name, int32_t value) 61 | { 62 | m_source << "#define " << name << " " << value << "\n"; 63 | } 64 | 65 | void GiGlslStitcher::appendDefine(std::string_view name, float value) 66 | { 67 | m_source << "#define " << name << " " << value << "\n"; 68 | } 69 | 70 | void GiGlslStitcher::appendString(std::string_view value) 71 | { 72 | m_source << value; 73 | } 74 | 75 | bool GiGlslStitcher::appendSourceFile(fs::path path) 76 | { 77 | std::string text; 78 | if (!detail::readTextFromFile(path, text)) 79 | { 80 | return false; 81 | } 82 | 83 | appendString(text); 84 | return true; 85 | } 86 | 87 | bool GiGlslStitcher::replaceFirst(std::string_view substring, std::string_view replacement) 88 | { 89 | std::string tmp = m_source.str(); 90 | 91 | size_t location = tmp.find(substring); 92 | if (location == std::string::npos) 93 | { 94 | return false; 95 | } 96 | 97 | tmp.replace(location, substring.length(), replacement); 98 | 99 | m_source = std::stringstream(tmp); 100 | return true; 101 | } 102 | 103 | std::string GiGlslStitcher::source() 104 | { 105 | return m_source.str(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/gi/shaders/rp_main_payload.glsl: -------------------------------------------------------------------------------- 1 | #include "common.glsl" 2 | 3 | #define SHADE_RAY_PAYLOAD_VOLUME_WALK_MISS_FLAG 0x40000000u 4 | #define SHADE_RAY_PAYLOAD_MEDIUM_IDX_MASK 0x0f000000u 5 | #define SHADE_RAY_PAYLOAD_MEDIUM_IDX_OFFSET 24 6 | #define SHADE_RAY_PAYLOAD_WALK_MASK 0x00fff000u 7 | #define SHADE_RAY_PAYLOAD_WALK_OFFSET 12 8 | #define SHADE_RAY_PAYLOAD_BOUNCES_MASK 0x00000fffu 9 | #define SHADE_RAY_PAYLOAD_TERMINATE_FLAG 0x80000000u 10 | 11 | struct Medium 12 | { 13 | vec3 ior; 14 | vec3 sigma_s; 15 | vec3 sigma_t; // sigma_a + sigma_s 16 | float bias; 17 | }; 18 | 19 | // NOTE: size needs to match _GetRpMainMaxRayPayloadSize() 20 | struct ShadeRayPayload 21 | { 22 | /* inout */ vec3 throughput; 23 | 24 | /* 1000 0000 0000 0000 0000 0000 0000 0000 terminate 25 | * 0100 0000 0000 0000 0000 0000 0000 0000 volume walk miss 26 | * 0011 0000 0000 0000 0000 0000 0000 0000 unused 27 | * 0000 1111 0000 0000 0000 0000 0000 0000 medium index [0, 256) 28 | * 0000 0000 1111 1111 1111 0000 0000 0000 walk length [0, 4096) 29 | * 0000 0000 0000 0000 0000 1111 1111 1111 bounces [0, 4096) */ 30 | /* inout */ uint bitfield; 31 | 32 | /* inout */ vec3 radiance; 33 | 34 | /* inout */ RNG_STATE_TYPE rng_state; 35 | 36 | #if MEDIUM_STACK_SIZE > 0 37 | /* inout */ Medium media[MEDIUM_STACK_SIZE]; 38 | /* inout */ vec3 walkSegmentPdf; 39 | #endif 40 | 41 | /* out */ vec3 ray_origin; 42 | /* out */ vec3 ray_dir; 43 | /* out */ vec3 neeToLight; 44 | /* out */ vec3 neeContrib; 45 | }; 46 | 47 | struct ShadowRayPayload 48 | { 49 | #ifdef RAND_4D 50 | /* inout */ uvec4 rng_state; 51 | #else 52 | /* inout */ uint rng_state; 53 | #endif 54 | /* out */ bool shadowed; 55 | }; 56 | 57 | #if MEDIUM_STACK_SIZE > 0 58 | void shadeRayPayloadIncrementWalk(inout ShadeRayPayload payload) 59 | { 60 | uint bitfield = payload.bitfield; 61 | bitfield &= SHADE_RAY_PAYLOAD_WALK_MASK; 62 | bitfield = min(bitfield + 1, SHADE_RAY_PAYLOAD_WALK_MASK); 63 | 64 | payload.bitfield &= ~SHADE_RAY_PAYLOAD_WALK_MASK; 65 | payload.bitfield |= bitfield; 66 | } 67 | 68 | uint shadeRayPayloadGetWalk(in ShadeRayPayload payload) 69 | { 70 | return (payload.bitfield & SHADE_RAY_PAYLOAD_WALK_MASK) >> SHADE_RAY_PAYLOAD_WALK_OFFSET; 71 | } 72 | #endif 73 | 74 | uint shadeRayPayloadGetMediumIdx(in ShadeRayPayload payload) 75 | { 76 | uint bitfield = payload.bitfield; 77 | bitfield &= SHADE_RAY_PAYLOAD_MEDIUM_IDX_MASK; 78 | bitfield >>= SHADE_RAY_PAYLOAD_MEDIUM_IDX_OFFSET; 79 | 80 | // The medium index can exceed the max stack size. This is used to ensure an 81 | // equal number of stack pushes/pops when the number of nested media exceeds 82 | // the max stack size. The case is only relevant when we push to the stack; 83 | // for common use we want to choose the uppermost/current medium. 84 | uint maxMediumIdx = max(1, MEDIUM_STACK_SIZE); 85 | 86 | return min(bitfield, maxMediumIdx); 87 | } 88 | 89 | void shadeRayPayloadSetMediumIdx(inout ShadeRayPayload payload, uint idx) 90 | { 91 | payload.bitfield &= ~SHADE_RAY_PAYLOAD_MEDIUM_IDX_MASK; 92 | payload.bitfield |= min(idx << SHADE_RAY_PAYLOAD_MEDIUM_IDX_OFFSET, SHADE_RAY_PAYLOAD_MEDIUM_IDX_MASK); 93 | } 94 | 95 | const int PAYLOAD_INDEX_SHADE = 0; 96 | const int PAYLOAD_INDEX_SHADOW = 1; 97 | -------------------------------------------------------------------------------- /src/hdGatling/mesh.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 | #include 26 | 27 | using namespace gtl; 28 | 29 | PXR_NAMESPACE_OPEN_SCOPE 30 | 31 | class HdGatlingMesh final : public HdMesh 32 | { 33 | public: 34 | HdGatlingMesh(const SdfPath& id, 35 | GiScene* scene, 36 | GiMaterial* defaultMaterial); 37 | 38 | void Finalize(HdRenderParam* renderParam) override; 39 | 40 | public: 41 | void Sync(HdSceneDelegate* delegate, 42 | HdRenderParam* renderParam, 43 | HdDirtyBits* dirtyBits, 44 | const TfToken& reprToken) override; 45 | 46 | HdDirtyBits GetInitialDirtyBitsMask() const override; 47 | 48 | protected: 49 | HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override; 50 | 51 | void _InitRepr(const TfToken& reprName, 52 | HdDirtyBits *dirtyBits) override; 53 | 54 | private: 55 | void _AnalyzePrimvars(HdSceneDelegate* sceneDelegate, 56 | bool& foundNormals, 57 | bool& indexingAllowed); 58 | 59 | struct ProcessedPrimvar 60 | { 61 | HdInterpolation interpolation; 62 | HdType type; 63 | TfToken role; 64 | VtValue indexMatchingData; 65 | }; 66 | 67 | using PrimvarMap = std::unordered_map; 68 | 69 | std::vector _CollectSecondaryPrimvars(const PrimvarMap& primvarMap); 70 | 71 | std::optional _ProcessPrimvar(HdSceneDelegate* sceneDelegate, 72 | const VtIntArray& primitiveParams, 73 | const HdPrimvarDescriptor& primvarDesc, 74 | const VtVec3iArray& faces, 75 | uint32_t vertexCount, 76 | bool indexingAllowed, 77 | bool constantAllowed); 78 | 79 | PrimvarMap _ProcessPrimvars(HdSceneDelegate* sceneDelegate, 80 | const VtIntArray& primitiveParams, 81 | const VtVec3iArray& faces, 82 | uint32_t vertexCount, 83 | bool indexingAllowed); 84 | 85 | void _CreateGiMeshes(HdSceneDelegate* sceneDelegate); 86 | 87 | private: 88 | GiMesh* _baseMesh = nullptr; 89 | std::vector _subMeshes; 90 | 91 | GiScene* _scene; 92 | GiMaterial* _defaultMaterial; 93 | }; 94 | 95 | PXR_NAMESPACE_CLOSE_SCOPE 96 | -------------------------------------------------------------------------------- /dist/houdini/HdGatlingRendererPlugin_Viewport.ds: -------------------------------------------------------------------------------- 1 | /// 2 | /// UI controls for the Gatling Render Delegate 3 | /// 4 | 5 | #include "$HFS/houdini/soho/parameters/CommonMacros.ds" 6 | 7 | { 8 | name "Gatling" 9 | label "Gatling" 10 | parmtag { spare_opfilter "!!SHOP/PROPERTIES!!" } 11 | parmtag { spare_classtags "render" } 12 | 13 | parm { 14 | name "spp" 15 | label "Samples per pixel" 16 | type int 17 | default { 1 } 18 | range { 1! 1000 } 19 | parmtag { "spare_category" "Sampling" } 20 | parmtag { "uiscope" "viewport" } 21 | } 22 | 23 | parm { 24 | name "maxBounces" 25 | label "Max bounces" 26 | type int 27 | default { 7 } 28 | range { 1! 64 } 29 | parmtag { "spare_category" "Sampling" } 30 | parmtag { "uiscope" "viewport" } 31 | } 32 | 33 | parm { 34 | name "rrBounceOffset" 35 | label "Russian roulette bounce offset" 36 | type int 37 | default { 3 } 38 | range { 0! 64 } 39 | parmtag { "spare_category" "Sampling" } 40 | parmtag { "uiscope" "viewport" } 41 | } 42 | 43 | parm { 44 | name "rrInvMinTermProb" 45 | label "Russian roulette inverse minimum terminate probability" 46 | type float 47 | default { 0.95 } 48 | range { 0! 1 } 49 | parmtag { "spare_category" "Sampling" } 50 | parmtag { "uiscope" "viewport" } 51 | } 52 | 53 | parm { 54 | name "maxSampleValue" 55 | label "Max sample value" 56 | type float 57 | default { 10.0 } 58 | range { 0.00001! 10000.0 } 59 | parmtag { "spare_category" "Sampling" } 60 | parmtag { "uiscope" "viewport" } 61 | } 62 | 63 | parm { 64 | name "filterImportanceSampling" 65 | label "Filter Importance Sampling" 66 | type toggle 67 | default { 1 } 68 | parmtag { "spare_category" "Sampling" } 69 | parmtag { "uiscope" "viewport" } 70 | } 71 | 72 | parm { 73 | name "depthOfField" 74 | label "Depth of field" 75 | type toggle 76 | default { 1 } 77 | parmtag { "spare_category" "Shading" } 78 | parmtag { "uiscope" "viewport" } 79 | } 80 | 81 | parm { 82 | name "lightIntensityMultiplier" 83 | label "Light intensity multiplier" 84 | type float 85 | default { 1.0 } 86 | range { 0.001! 10000.0 } 87 | parmtag { "spare_category" "Tweaks" } 88 | parmtag { "uiscope" "viewport" } 89 | } 90 | 91 | parm { 92 | name "nextEventEstimation" 93 | label "Next event estimation" 94 | type toggle 95 | default { 1 } 96 | parmtag { "spare_category" "Shading" } 97 | parmtag { "uiscope" "viewport toolbar" } 98 | parmtag { "uiicon" "OBJ_light_pxrdome" } 99 | } 100 | 101 | parm { 102 | name "clippingPlanes" 103 | label "Clipping planes" 104 | type toggle 105 | default { 0 } 106 | parmtag { "spare_category" "Tweaks" } 107 | parmtag { "uiscope" "viewport toolbar" } 108 | parmtag { "uiicon" "BUTTONS_cut" } // BUTTONS_box 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/mc/impl/MdlMaterialCompiler.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 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "MaterialParameters.h" 35 | #include "MdlLogger.h" 36 | 37 | namespace gtl 38 | { 39 | class McMdlRuntime; 40 | 41 | class McMdlMaterialCompiler 42 | { 43 | public: 44 | McMdlMaterialCompiler(McMdlRuntime& runtime); 45 | 46 | public: 47 | bool compileFromString(std::string_view srcStr, 48 | std::string_view identifier, 49 | mi::base::Handle& compiledMaterial); 50 | 51 | bool compileFromFile(const char* filePath, 52 | std::string_view identifier, 53 | mi::base::Handle& compiledMaterial, 54 | const McMaterialParameters& params = {}); 55 | 56 | private: 57 | bool compile(std::string_view identifier, 58 | std::string_view moduleName, 59 | std::function modCreateFunc, 60 | mi::base::Handle& compiledMaterial, 61 | const McMaterialParameters& params = {}); 62 | 63 | bool createCompiledMaterial(mi::neuraylib::IMdl_execution_context* context, 64 | std::string_view moduleName, 65 | std::string_view identifier, 66 | mi::base::Handle& compiledMaterial, 67 | const McMaterialParameters& params = {}); 68 | 69 | private: 70 | mi::base::Handle m_logger; 71 | mi::base::Handle m_database; 72 | mi::base::Handle m_transaction; 73 | mi::base::Handle m_config; 74 | mi::base::Handle m_factory; 75 | mi::base::Handle m_impExpApi; 76 | mi::base::Handle m_vf; 77 | mi::base::Handle m_tf; 78 | mi::base::Handle m_ef; 79 | }; 80 | } 81 | -------------------------------------------------------------------------------- /src/gi/impl/AssetReader.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 "AssetReader.h" 19 | #include "Mmap.h" 20 | 21 | namespace gtl 22 | { 23 | struct GiMmapAsset 24 | { 25 | GiFile* file; 26 | size_t size; 27 | void* data; 28 | }; 29 | 30 | GiAsset* GiMmapAssetReader::open(const char* path) 31 | { 32 | GiFile* file; 33 | if (!giFileOpen(path, GiFileUsage::Read, &file)) 34 | { 35 | return nullptr; 36 | } 37 | 38 | size_t size = giFileSize(file); 39 | void* data = giMmap(file, 0, size); 40 | if (!data) 41 | { 42 | giFileClose(file); 43 | return nullptr; 44 | } 45 | 46 | auto iasset = new GiMmapAsset; 47 | iasset->file = file; 48 | iasset->size = size; 49 | iasset->data = data; 50 | return (GiAsset*)iasset; 51 | } 52 | 53 | size_t GiMmapAssetReader::size(const GiAsset* asset) const 54 | { 55 | auto iasset = (GiMmapAsset*)asset; 56 | return iasset->size; 57 | } 58 | 59 | void* GiMmapAssetReader::data(const GiAsset* asset) const 60 | { 61 | auto iasset = (GiMmapAsset*)asset; 62 | return iasset->data; 63 | } 64 | 65 | void GiMmapAssetReader::close(GiAsset* asset) 66 | { 67 | auto iasset = (GiMmapAsset*)asset; 68 | giMunmap(iasset->file, iasset->data); 69 | giFileClose(iasset->file); 70 | delete iasset; 71 | } 72 | 73 | struct GiAggregateAsset 74 | { 75 | GiAssetReader* reader; 76 | GiAsset* asset; 77 | }; 78 | 79 | void GiAggregateAssetReader::addAssetReader(GiAssetReader* reader) 80 | { 81 | m_readers.push_back(reader); 82 | } 83 | 84 | GiAsset* GiAggregateAssetReader::open(const char* path) 85 | { 86 | for (GiAssetReader* reader : m_readers) 87 | { 88 | GiAsset* asset = reader->open(path); 89 | if (!asset) 90 | { 91 | continue; 92 | } 93 | 94 | auto iasset = new GiAggregateAsset; 95 | iasset->reader = reader; 96 | iasset->asset = asset; 97 | return (GiAsset*)iasset; 98 | } 99 | return nullptr; 100 | } 101 | 102 | size_t GiAggregateAssetReader::size(const GiAsset* asset) const 103 | { 104 | auto iasset = (GiAggregateAsset*)asset; 105 | return iasset->reader->size(iasset->asset); 106 | } 107 | 108 | void* GiAggregateAssetReader::data(const GiAsset* asset) const 109 | { 110 | auto iasset = (GiAggregateAsset*)asset; 111 | return iasset->reader->data(iasset->asset); 112 | } 113 | 114 | void GiAggregateAssetReader::close(GiAsset* asset) 115 | { 116 | auto iasset = (GiAggregateAsset*)asset; 117 | iasset->reader->close(iasset->asset); 118 | delete iasset; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/ggpu/impl/ResizableBuffer.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 "ResizableBuffer.h" 19 | 20 | #include "DelayedResourceDestroyer.h" 21 | 22 | namespace gtl 23 | { 24 | GgpuResizableBuffer::GgpuResizableBuffer(CgpuDevice device, 25 | GgpuDelayedResourceDestroyer& delayedResourceDestroyer, 26 | CgpuBufferUsage usageFlags, 27 | CgpuMemoryProperties memoryProperties) 28 | : m_device(device) 29 | , m_delayedResourceDestroyer(delayedResourceDestroyer) 30 | , m_usageFlags(usageFlags | CgpuBufferUsage::TransferSrc | CgpuBufferUsage::TransferDst) 31 | , m_memoryProperties(memoryProperties) 32 | { 33 | } 34 | 35 | GgpuResizableBuffer::~GgpuResizableBuffer() 36 | { 37 | if (m_buffer.handle) 38 | { 39 | m_delayedResourceDestroyer.enqueueDestruction(m_buffer); 40 | } 41 | } 42 | 43 | CgpuBuffer GgpuResizableBuffer::buffer() const 44 | { 45 | return m_buffer; 46 | } 47 | 48 | uint64_t GgpuResizableBuffer::size() const 49 | { 50 | return m_size; 51 | } 52 | 53 | bool GgpuResizableBuffer::resize(uint64_t newSize, CgpuCommandBuffer commandBuffer) 54 | { 55 | if (newSize == m_size) 56 | { 57 | return true; 58 | } 59 | 60 | if (newSize == 0) 61 | { 62 | if (m_buffer.handle) 63 | { 64 | m_delayedResourceDestroyer.enqueueDestruction(m_buffer); 65 | m_buffer.handle = 0; 66 | } 67 | 68 | m_size = 0; 69 | return true; 70 | } 71 | 72 | // Create new, larger buffer. 73 | bool result = false; 74 | 75 | CgpuBuffer buffer; 76 | if (!cgpuCreateBuffer(m_device, { 77 | .usage = m_usageFlags, 78 | .memoryProperties = m_memoryProperties, 79 | .size = newSize, 80 | .debugName = "[resizable buffer]" 81 | }, &buffer)) 82 | { 83 | goto cleanup; 84 | } 85 | 86 | // Copy old buffer data if needed. 87 | if (m_size > 0) 88 | { 89 | cgpuCmdCopyBuffer(commandBuffer, m_buffer, 0, buffer, 0, m_size);; 90 | } 91 | 92 | // Swap buffers, so that we always destroy the unused one. 93 | { 94 | CgpuBuffer temp = m_buffer; 95 | m_buffer = buffer; 96 | buffer = temp; 97 | } 98 | 99 | m_size = newSize; 100 | 101 | result = true; 102 | 103 | cleanup: 104 | if (buffer.handle) 105 | { 106 | m_delayedResourceDestroyer.enqueueDestruction(buffer); 107 | } 108 | 109 | return result; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /.github/workflows/build-blender50.yml: -------------------------------------------------------------------------------- 1 | name: Build for Blender 5.0 2 | 3 | on: 4 | workflow_call: 5 | 6 | defaults: 7 | run: 8 | shell: bash 9 | 10 | jobs: 11 | build-plugin: 12 | name: Build gatling 13 | 14 | env: 15 | archive-name: gatling_Blender5.0_Windows_x64 16 | 17 | # NOTE: make sure to adjust occurrence below 18 | runs-on: windows-2022 19 | 20 | steps: 21 | - name: Check out repository 22 | uses: actions/checkout@v4 23 | with: 24 | submodules: recursive 25 | show-progress: false 26 | 27 | - name: Make dirs 28 | run: mkdir -p BUILD INSTALL 29 | 30 | - name: Check out deps 31 | run: | 32 | git clone --filter=blob:none --no-checkout --depth 1 --sparse --branch blender-v5.0-release https://projects.blender.org/blender/lib-windows_x64 DEPS 33 | cd DEPS 34 | git sparse-checkout init --cone 35 | git sparse-checkout add boost imath MaterialX opensubdiv python tbb usd vulkan 36 | git checkout 37 | 38 | - name: Apply patches 39 | run: | 40 | patch --binary DEPS/usd/pxrConfig.cmake .github/patches/blender50/pxrConfig.cmake.patch 41 | patch --binary DEPS/usd/cmake/pxrTargets.cmake .github/patches/blender50/pxrTargets.cmake.patch 42 | patch --binary DEPS/MaterialX/lib/cmake/MaterialX/MaterialXConfig.cmake .github/patches/blender50/MaterialXConfig.cmake.patch 43 | 44 | - name: Fetch FindTBB.cmake 45 | run: curl https://raw.githubusercontent.com/PixarAnimationStudios/OpenUSD/v23.11/cmake/modules/FindTBB.cmake --output cmake/FindTBB.cmake 46 | 47 | - name: Fetch & unpack MDL SDK binaries 48 | run: | 49 | curl "https://github.com/NVIDIA/MDL-SDK/releases/download/2024.1.4/MDL-SDK-2024.1.4-381500.6583-nt-x86-64.zip" -L --progress-bar -o MDL_SDK.zip 50 | mkdir -p MDL-SDK 51 | unzip MDL_SDK.zip -d MDL-SDK 52 | mv MDL-SDK/*/* MDL-SDK/. 53 | 54 | - name: Generate build system files using CMake 55 | working-directory: BUILD 56 | run: | 57 | MaterialX_DIR=../DEPS/MaterialX/lib/cmake/MaterialX \ 58 | VulkanHeaders_DIR=../DEPS/vulkan/share/cmake/VulkanHeaders \ 59 | VulkanUtilityLibraries_DIR=../DEPS/vulkan/lib/cmake/VulkanUtilityLibraries \ 60 | Imath_DIR=../DEPS/imath \ 61 | OpenSubdiv_DIR=../DEPS/opensubdiv \ 62 | BOOST_ROOT=../DEPS/boost \ 63 | cmake .. \ 64 | -DCMAKE_CXX_FLAGS="-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR" \ 65 | -DPython3_ROOT_DIR=../DEPS/python/311 \ 66 | -DPython3_EXECUTABLE="../DEPS/python/311/bin/python.exe" \ 67 | -DPython3_LIBRARY="../DEPS/python/311/libs/python311.lib" \ 68 | -DPXR_CMAKE_DIR=../DEPS/usd \ 69 | -DTBB_ROOT=../DEPS/tbb \ 70 | -DUSD_ROOT=../DEPS/usd \ 71 | -DMDL_ROOT=../MDL-SDK \ 72 | -DCMAKE_INSTALL_PREFIX="$PWD/../INSTALL/render_delegate" \ 73 | -DCMAKE_BUILD_TYPE=Release \ 74 | -G"Visual Studio 17 2022" \ 75 | -Ax64 76 | 77 | - name: Compile gatling 78 | working-directory: BUILD 79 | run: | 80 | cmake --build . --target hdGatling -j 2 --config Release 81 | cmake --install . --component hdGatling --config Release 82 | 83 | - name: Copy plugin files 84 | run: cp -r dist/blender/* INSTALL 85 | 86 | - name: Upload archive 87 | uses: actions/upload-artifact@v4 88 | with: 89 | name: ${{ env.archive-name }} 90 | path: INSTALL/* 91 | if-no-files-found: error 92 | retention-days: 7 93 | -------------------------------------------------------------------------------- /src/ggpu/impl/DelayedResourceDestroyer.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 "DelayedResourceDestroyer.h" 19 | 20 | #include 21 | 22 | namespace gtl 23 | { 24 | GgpuDelayedResourceDestroyer::GgpuDelayedResourceDestroyer(CgpuDevice device) 25 | : m_device(device) 26 | { 27 | } 28 | 29 | GgpuDelayedResourceDestroyer::~GgpuDelayedResourceDestroyer() 30 | { 31 | for (uint32_t i = 0; i < FrameCount; i++) 32 | { 33 | assert(m_pendingDestructions[i].empty()); 34 | } 35 | } 36 | 37 | void GgpuDelayedResourceDestroyer::housekeep() 38 | { 39 | auto& oldestFrameDestructions = m_pendingDestructions[m_frameIndex]; 40 | for (const DestroyFunc& fun : oldestFrameDestructions) 41 | { 42 | fun(); 43 | } 44 | 45 | oldestFrameDestructions.clear(); 46 | } 47 | 48 | void GgpuDelayedResourceDestroyer::nextFrame() 49 | { 50 | m_frameIndex = (m_frameIndex + 1) % FrameCount; 51 | } 52 | 53 | void GgpuDelayedResourceDestroyer::destroyAll() 54 | { 55 | for (uint32_t i = 0; i < FrameCount; i++) 56 | { 57 | nextFrame(); 58 | housekeep(); 59 | } 60 | } 61 | 62 | void GgpuDelayedResourceDestroyer::enqueueDestruction(CgpuBuffer handle) 63 | { 64 | assert(handle.handle); 65 | enqueueDestroyFunc([this, handle]() { cgpuDestroyBuffer(m_device, handle); }); 66 | } 67 | 68 | void GgpuDelayedResourceDestroyer::enqueueDestruction(CgpuImage handle) 69 | { 70 | assert(handle.handle); 71 | enqueueDestroyFunc([this, handle]() { cgpuDestroyImage(m_device, handle); }); 72 | } 73 | 74 | void GgpuDelayedResourceDestroyer::enqueueDestruction(CgpuPipeline handle) 75 | { 76 | assert(handle.handle); 77 | enqueueDestroyFunc([this, handle]() { cgpuDestroyPipeline(m_device, handle); }); 78 | } 79 | 80 | void GgpuDelayedResourceDestroyer::enqueueDestruction(CgpuSemaphore handle) 81 | { 82 | assert(handle.handle); 83 | enqueueDestroyFunc([this, handle]() { cgpuDestroySemaphore(m_device, handle); }); 84 | } 85 | 86 | void GgpuDelayedResourceDestroyer::enqueueDestruction(CgpuCommandBuffer handle) 87 | { 88 | assert(handle.handle); 89 | enqueueDestroyFunc([this, handle]() { cgpuDestroyCommandBuffer(m_device, handle); }); 90 | } 91 | 92 | void GgpuDelayedResourceDestroyer::enqueueDestruction(CgpuBlas handle) 93 | { 94 | assert(handle.handle); 95 | enqueueDestroyFunc([this, handle]() { cgpuDestroyBlas(m_device, handle); }); 96 | } 97 | 98 | void GgpuDelayedResourceDestroyer::enqueueDestruction(CgpuTlas handle) 99 | { 100 | assert(handle.handle); 101 | enqueueDestroyFunc([this, handle]() { cgpuDestroyTlas(m_device, handle); }); 102 | } 103 | 104 | void GgpuDelayedResourceDestroyer::enqueueDestroyFunc(DestroyFunc fun) 105 | { 106 | m_pendingDestructions[m_frameIndex].push_back(fun); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /.github/workflows/build-usd.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_call: 3 | inputs: 4 | build-config: 5 | description: "Name of the CMake build configuration" 6 | required: false 7 | type: string 8 | default: "Release" 9 | usd-version: 10 | description: "Name of the USD release, in the form 'XX.XX'" 11 | required: true 12 | type: string 13 | upload-install-artifacts: 14 | description: "Whether build results should be uploaded or not" 15 | required: false 16 | type: boolean 17 | default: false 18 | run-graphical-tests: 19 | required: false 20 | type: boolean 21 | default: false 22 | upload-test-artifacts: 23 | required: false 24 | type: boolean 25 | default: false 26 | 27 | jobs: 28 | build: 29 | name: ${{ matrix.name }} 30 | 31 | strategy: 32 | matrix: 33 | include: 34 | - name: Ubuntu (GCC) 35 | image: ubuntu-22.04 36 | mdl-download-url: "https://github.com/NVIDIA/MDL-SDK/releases/download/2024.1.4/MDL-SDK-2024.1.4-381500.6583-linux-x86-64.tgz" 37 | usd-download-url: "https://github.com/pablode/USD/releases/download/v${{ inputs.usd-version }}-ci-release/USD${{ inputs.usd-version }}_Linux_x64.tar.gz" 38 | usd-install-path: "/home/runner/work/USD/USD/INSTALL" 39 | upload-install-artifacts: ${{ inputs.upload-install-artifacts }} 40 | archive-name: gatling_USD${{ inputs.usd-version }}_Ubuntu22.04_x64 41 | cmake-params: 42 | run-graphical-tests: ${{ inputs.run-graphical-tests }} 43 | executable-suffix: 44 | 45 | - name: Ubuntu (clang) 46 | image: ubuntu-22.04 47 | mdl-download-url: "https://github.com/NVIDIA/MDL-SDK/releases/download/2024.1.4/MDL-SDK-2024.1.4-381500.6583-linux-x86-64.tgz" 48 | usd-download-url: "https://github.com/pablode/USD/releases/download/v${{ inputs.usd-version }}-ci-release/USD${{ inputs.usd-version }}_Linux_x64.tar.gz" 49 | usd-install-path: "/home/runner/work/USD/USD/INSTALL" 50 | # Don't upload clang build results -- we already have GCC's 51 | upload-install-artifacts: false 52 | cmake-params: -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ 53 | run-graphical-tests: false 54 | executable-suffix: 55 | 56 | - name: Windows (MSVC) 57 | image: windows-2022 58 | 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" 59 | usd-download-url: "https://github.com/pablode/USD/releases/download/v${{ inputs.usd-version }}-ci-release/USD${{ inputs.usd-version }}_Windows_x64.tar.gz" 60 | usd-install-path: "C:/INSTALL" 61 | upload-install-artifacts: ${{ inputs.upload-install-artifacts }} 62 | archive-name: gatling_USD${{ inputs.usd-version }}_Windows_x64 63 | cmake-params: -G"Visual Studio 17 2022" -Ax64 64 | run-graphical-tests: false 65 | executable-suffix: ".exe" 66 | 67 | uses: ./.github/workflows/build.yml 68 | with: 69 | image: ${{ matrix.image }} 70 | build-config: ${{ inputs.build-config }} 71 | mdl-download-url: ${{ matrix.mdl-download-url }} 72 | usd-download-url: ${{ matrix.usd-download-url }} 73 | usd-install-path: ${{ matrix.usd-install-path }} 74 | upload-install-artifacts: ${{ matrix.upload-install-artifacts }} 75 | archive-name: ${{ matrix.archive-name }} 76 | cmake-params: ${{ matrix.cmake-params }} 77 | run-graphical-tests: ${{ matrix.run-graphical-tests }} 78 | upload-test-artifacts: ${{ inputs.upload-test-artifacts }} 79 | executable-suffix: ${{ matrix.executable-suffix }} 80 | --------------------------------------------------------------------------------