├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── README.md ├── anari ├── .clang-format ├── Array.h ├── BarneyDeviceQueries.cpp ├── BarneyDeviceQueries.h ├── BarneyGlobalState.cpp ├── BarneyGlobalState.h ├── CMakeLists.txt ├── Camera.cpp ├── Camera.h ├── Device.cpp ├── Device.h ├── Frame.cpp ├── Frame.h ├── Geometry.cpp ├── Geometry.h ├── Group.cpp ├── Group.h ├── Instance.cpp ├── Instance.h ├── Library.cpp ├── Material.cpp ├── Material.h ├── Object.cpp ├── Object.h ├── Renderer.cpp ├── Renderer.h ├── Sampler.cpp ├── Sampler.h ├── SpatialField.cpp ├── SpatialField.h ├── Surface.cpp ├── Surface.h ├── Volume.cpp ├── Volume.h ├── World.cpp ├── World.h ├── barney_device.json ├── barney_math.h ├── common.h ├── dummy.cu ├── light │ ├── Directional.cpp │ ├── Directional.h │ ├── HDRI.cpp │ ├── HDRI.h │ ├── Light.cpp │ ├── Light.h │ ├── Point.cpp │ └── Point.h ├── nv_frame_buffers_cuda.json └── test │ ├── anariTest.cpp │ └── stb_image_write.h ├── barney ├── CMakeLists.txt ├── Camera.cu ├── Camera.h ├── Context.cpp ├── Context.h ├── DeviceGroup.cpp ├── DeviceGroup.h ├── GlobalModel.cpp ├── GlobalModel.h ├── Group.cpp ├── Group.h ├── LocalContext.cpp ├── LocalContext.h ├── MPIContext.cpp ├── MPIContext.h ├── ModelSlot.cpp ├── ModelSlot.h ├── Object.cpp ├── Object.h ├── amr │ ├── BlockStructuredCUBQLSampler.cu │ ├── BlockStructuredCUBQLSampler.h │ ├── BlockStructuredField.cu │ ├── BlockStructuredField.h │ └── BlockStructuredMC.dev.cu ├── api │ ├── Context.h │ ├── barney.cu │ └── common.h ├── common │ ├── CUBQL.h │ ├── Data.cpp │ ├── Data.h │ ├── MPIWrappers.cpp │ ├── MPIWrappers.h │ ├── Texture.cpp │ ├── Texture.h │ ├── barney-common.h │ ├── barneyConfig.cmake.in │ ├── barneyConfig.h.in │ ├── half.h │ ├── hilbert.h │ ├── mat4.h │ ├── math.h │ └── random.h ├── fb │ ├── DistFB.cu │ ├── DistFB.h │ ├── FrameBuffer.cu │ ├── FrameBuffer.h │ ├── LocalFB.cpp │ ├── LocalFB.h │ ├── TiledFB.cu │ └── TiledFB.h ├── geometry │ ├── Capsules.cpp │ ├── Capsules.dev.cu │ ├── Capsules.h │ ├── Cones.cpp │ ├── Cones.dev.cu │ ├── Cones.h │ ├── Cylinders.cpp │ ├── Cylinders.dev.cu │ ├── Cylinders.h │ ├── Geometry.cpp │ ├── Geometry.h │ ├── Spheres.cpp │ ├── Spheres.dev.cu │ ├── Spheres.h │ ├── Triangles.cpp │ ├── Triangles.dev.cu │ └── Triangles.h ├── include │ ├── barney.h │ └── barney_mpi.h ├── kernels │ ├── generateRays.cu │ ├── shadeRays.cu │ ├── traceRays.cu │ └── traceRays.dev.cu ├── light │ ├── DirLight.cu │ ├── DirLight.h │ ├── EnvMap.cu │ ├── EnvMap.h │ ├── Light.cpp │ ├── Light.h │ ├── PointLight.cu │ ├── PointLight.h │ ├── QuadLight.cu │ └── QuadLight.h ├── material │ ├── AnariMatte.cpp │ ├── AnariMatte.h │ ├── AnariPBR.cpp │ ├── AnariPBR.h │ ├── DeviceMaterial.h │ ├── Material.cpp │ └── Material.h ├── packedBSDF │ ├── Glass.h │ ├── Lambertian.h │ ├── NVisii.h │ ├── PackedBSDF.h │ └── Phase.h ├── render │ ├── DG.h │ ├── GeometryAttributes.cpp │ ├── GeometryAttributes.h │ ├── HitAttributes.h │ ├── HitIDs.h │ ├── MaterialInputs.h │ ├── MaterialRegistry.cpp │ ├── MaterialRegistry.h │ ├── OptixGlobals.h │ ├── Ray.h │ ├── RayQueue.cpp │ ├── RayQueue.h │ ├── Renderer.cpp │ ├── Renderer.h │ ├── Sampler.cpp │ ├── Sampler.h │ ├── SamplerRegistry.cpp │ ├── SamplerRegistry.h │ ├── World.cpp │ ├── World.h │ └── floatN.h ├── run-tests.sh ├── umesh │ ├── common │ │ ├── ElementIntersection.h │ │ ├── UMeshField.cu │ │ └── UMeshField.h │ ├── mc │ │ ├── UMeshCUBQLSampler.cu │ │ ├── UMeshCUBQLSampler.h │ │ └── UMeshMC.dev.cu │ └── os │ │ ├── AWT.cu │ │ ├── AWT.dev.cu │ │ ├── AWT.h │ │ ├── ObjectSpace-common.h │ │ ├── RTXObjectSpace.cu │ │ ├── RTXObjectSpace.dev.cu │ │ └── RTXObjectSpace.h └── volume │ ├── DDA.h │ ├── MCAccelerator.h │ ├── MCGrid.cu │ ├── MCGrid.cuh │ ├── MCGrid.h │ ├── ScalarField.cpp │ ├── ScalarField.h │ ├── StructuredData.cu │ ├── StructuredData.dev.cu │ ├── StructuredData.h │ ├── TransferFunction.cpp │ ├── TransferFunction.h │ ├── Volume.cpp │ └── Volume.h ├── doc ├── ANARI.md └── BarneyNative.md ├── jpg ├── dns-isosurface-2b-triangles.jpg ├── engine.jpg ├── jets.jpg ├── ls-collage.jpg ├── ls-pond.jpg ├── ls.jpg ├── make_collages.sh ├── rotstrat-dense.jpg ├── rotstrat-fuzzy.jpg └── structured-collage.jpg ├── rtcore ├── AppInterface.h ├── CMakeLists.txt ├── ComputeInterface.h ├── TraceInterface.h ├── common │ └── rtcore-common.h ├── cuda │ ├── AppInterface.h │ ├── Buffer.cpp │ ├── Buffer.h │ ├── ComputeInterface.h │ ├── Device.cu │ ├── Device.h │ ├── Geom.cpp │ ├── Geom.h │ ├── GeomType.cpp │ ├── GeomType.h │ ├── Group.cu │ ├── Group.h │ ├── ProgramInterface.h │ ├── TraceInterface.h │ ├── TraceKernel.cpp │ └── TraceKernel.h ├── cudaCommon │ ├── ComputeInterface.h │ ├── ComputeKernel.h │ ├── Device.cu │ ├── Device.h │ ├── Texture.cu │ ├── Texture.h │ ├── TextureData.cu │ ├── TextureData.h │ ├── cuda-common.h │ ├── cuda-helper.cpp │ └── cuda-helper.h ├── embree │ ├── AppInterface.h │ ├── Buffer.cpp │ ├── Buffer.h │ ├── Compute.cpp │ ├── ComputeInterface.h │ ├── ComputeKernel.h │ ├── Denoiser.cpp │ ├── Denoiser.h │ ├── Device.cpp │ ├── Device.h │ ├── EmbreeBackend.cpp │ ├── EmbreeBackend.h │ ├── Float16.cpp │ ├── Float16.h │ ├── Geom.cpp │ ├── Geom.h │ ├── GeomType.cpp │ ├── GeomType.h │ ├── Group.cpp │ ├── Group.h │ ├── Texture.cpp │ ├── Texture.h │ ├── TraceInterface.h │ ├── Triangles.cpp │ ├── Triangles.h │ ├── UserGeom.cpp │ ├── UserGeom.h │ └── embree-common.h └── optix │ ├── AppInterface.h │ ├── Buffer.cpp │ ├── Buffer.h │ ├── ComputeInterface.h │ ├── Denoiser.cpp │ ├── Denoiser.h │ ├── Device.cpp │ ├── Device.h │ ├── Geom.cpp │ ├── Geom.h │ ├── Group.cpp │ ├── Group.h │ └── TraceInterface.h ├── samples ├── collage-triangles.jpg ├── collage-usergeom.jpg ├── collage-volumes.jpg ├── make-collages.sh ├── sample-capsules.png ├── sample-chest.png ├── sample-cones.jpg ├── sample-curves.jpg ├── sample-cylinders.jpg ├── sample-headlight.png ├── sample-kingsnake.png ├── sample-landscape.png ├── sample-pynari1.jpg ├── sample-spheres.png ├── sample-testorb.jpg ├── sample-umesh.png └── sample-umesh1.png ├── testing ├── furnace1.py ├── loop_frame_get.py ├── loop_rebuild_tris.py ├── loop_root_rebuild.py └── loop_spheres_rebuild.py └── win-build-all-variants.bat /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | textures 3 | backends 4 | barney/backends 5 | *# 6 | .#* 7 | bin 8 | dbg 9 | *.user* 10 | build* 11 | *.sw? 12 | tags 13 | .ycm_extra_conf.pyc 14 | *.autosave 15 | *DS_Store* 16 | *.gz 17 | *.rpm 18 | *.zip 19 | *.bak 20 | *.patch 21 | .vscode 22 | deps 23 | tbb 24 | ispc 25 | *.aux 26 | *.bbl 27 | *.blg 28 | *.brf 29 | *.dvi 30 | *.lbl 31 | *.log 32 | paper/pointQueries/rtxPointQueries.pdf 33 | paper/pointQueries/rtxPointQueries-compressed.pdf 34 | *.swp 35 | *.out 36 | Session.vim 37 | .idea 38 | !*png/*.pdf 39 | .vs/ 40 | samples/advanced/optix7course/models/ 41 | 42 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/owl"] 2 | path = submodules/owl 3 | url = https://github.com/owl-project/owl 4 | [submodule "submodules/cuBQL"] 5 | path = submodules/cuBQL 6 | url = https://github.com/ingowald/cuBQL 7 | [submodule "submodules/embree"] 8 | path = submodules/embree 9 | url = https://github.com/embree/embree 10 | -------------------------------------------------------------------------------- /anari/Array.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "BarneyGlobalState.h" 7 | // helium 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace barney_device { 14 | 15 | using Array1D = helium::Array1D; 16 | using Array2D = helium::Array2D; 17 | using Array3D = helium::Array3D; 18 | using ObjectArray = helium::ObjectArray; 19 | 20 | // Inlined definitions //////////////////////////////////////////////////////// 21 | 22 | inline size_t getNumBytes(const helium::Array &arr) 23 | { 24 | return arr.totalCapacity() * anari::sizeOf(arr.elementType()); 25 | } 26 | 27 | inline size_t getNumBytes(const helium::IntrusivePtr &arr) 28 | { 29 | return arr ? getNumBytes(*arr) : size_t(0); 30 | } 31 | 32 | inline size_t getNumBytes(const helium::IntrusivePtr &arr) 33 | { 34 | return arr ? getNumBytes(*arr) : size_t(0); 35 | } 36 | 37 | inline size_t getNumBytes(const helium::IntrusivePtr &arr) 38 | { 39 | return arr ? getNumBytes(*arr) : size_t(0); 40 | } 41 | 42 | template 43 | inline size_t getNumBytes(const std::vector &v) 44 | { 45 | return v.size() * sizeof(T); 46 | } 47 | 48 | } // namespace barney_device 49 | -------------------------------------------------------------------------------- /anari/BarneyDeviceQueries.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Khronos Group 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // This file was generated by generate_queries.py 5 | // Don't make changes to this directly 6 | 7 | #include 8 | namespace barney_device { 9 | #define ANARI_INFO_required 0 10 | #define ANARI_INFO_default 1 11 | #define ANARI_INFO_minimum 2 12 | #define ANARI_INFO_maximum 3 13 | #define ANARI_INFO_description 4 14 | #define ANARI_INFO_elementType 5 15 | #define ANARI_INFO_value 6 16 | #define ANARI_INFO_sourceExtension 7 17 | #define ANARI_INFO_extension 8 18 | #define ANARI_INFO_parameter 9 19 | #define ANARI_INFO_channel 10 20 | #define ANARI_INFO_use 11 21 | const int extension_count = 14; 22 | const char ** query_extensions(); 23 | const char ** query_object_types(ANARIDataType type); 24 | const ANARIParameter * query_params(ANARIDataType type, const char *subtype); 25 | const void * query_param_info_enum(ANARIDataType type, const char *subtype, const char *paramName, ANARIDataType paramType, int infoName, ANARIDataType infoType); 26 | const void * query_param_info(ANARIDataType type, const char *subtype, const char *paramName, ANARIDataType paramType, const char *infoNameString, ANARIDataType infoType); 27 | const void * query_object_info_enum(ANARIDataType type, const char *subtype, int infoName, ANARIDataType infoType); 28 | const void * query_object_info(ANARIDataType type, const char *subtype, const char *infoNameString, ANARIDataType infoType); 29 | } 30 | -------------------------------------------------------------------------------- /anari/BarneyGlobalState.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #define ANARI_BARNEY_MATH_DEFINITIONS 1 5 | 6 | #include "BarneyGlobalState.h" 7 | #include "Frame.h" 8 | 9 | namespace barney_device { 10 | 11 | BarneyGlobalState::BarneyGlobalState(ANARIDevice d) 12 | : helium::BaseGlobalDeviceState(d) 13 | {} 14 | 15 | void BarneyGlobalState::markSceneChanged() 16 | { 17 | objectUpdates.lastSceneChange = helium::newTimeStamp(); 18 | } 19 | 20 | bool Tether::allDevicesPresent() 21 | { 22 | for (auto dev : devices) 23 | if (dev == 0) return false; 24 | return true; 25 | } 26 | 27 | TetheredModel *Tether::getModel(int uniqueID) 28 | { 29 | std::lock_guard lock(mutex); 30 | auto &pair = activeModels[uniqueID]; 31 | if (!pair.second) { 32 | pair.second = std::make_shared(); 33 | pair.second->model = bnModelCreate(context); 34 | } 35 | pair.first++; 36 | return pair.second.get(); 37 | } 38 | 39 | void Tether::releaseModel(int uniqueID) 40 | { 41 | std::lock_guard lock(mutex); 42 | auto &tm = activeModels[uniqueID]; 43 | if (--tm.first == 0) { 44 | if (tm.second->model) 45 | bnRelease(tm.second->model); 46 | activeModels.erase(activeModels.find(uniqueID)); 47 | } 48 | 49 | } 50 | 51 | } // namespace barney_device 52 | -------------------------------------------------------------------------------- /anari/BarneyGlobalState.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "barney_math.h" 7 | // helium 8 | #include "helium/BaseGlobalDeviceState.h" 9 | #include 10 | #include 11 | 12 | namespace barney_device { 13 | 14 | inline void bnSetAndRelease(BNObject o, const char *n, BNObject v) 15 | { 16 | bnSetObject(o,n,v); 17 | bnRelease(v); 18 | } 19 | inline void bnSetAndRelease(BNObject o, const char *n, BNData v) 20 | { 21 | bnSetData(o,n,v); 22 | bnRelease(v); 23 | } 24 | 25 | struct Frame; 26 | struct World; 27 | 28 | struct BarneyDevice; 29 | 30 | struct TetheredModel { 31 | BNModel model; 32 | }; 33 | 34 | /*! keeps info on multiple (banari-)devices that are tethered 35 | together onto a singel barney ncontext */ 36 | struct Tether { 37 | BNContext context{nullptr}; 38 | 39 | bool allDevicesPresent(); 40 | 41 | TetheredModel *getModel(int uniqueID); 42 | void releaseModel(int uniqueID); 43 | std::map>> activeModels; 44 | std::mutex mutex; 45 | 46 | int numDevicesAlreadyTethered = 0; 47 | std::vector devices; 48 | int numReadyToRender = 0; 49 | }; 50 | 51 | struct BarneyGlobalState : public helium::BaseGlobalDeviceState 52 | { 53 | struct ObjectUpdates 54 | { 55 | helium::TimeStamp lastSceneChange{0}; 56 | } objectUpdates; 57 | 58 | // World *currentWorld{nullptr}; 59 | int slot = -1; 60 | bool allowInvalidSurfaceMaterials{true}; 61 | math::float4 invalidMaterialColor{1.f, 0.f, 1.f, 1.f}; 62 | 63 | // BNHardwareInfo bnInfo; 64 | std::shared_ptr tether; 65 | 66 | /*! created models get consecutive IDs, which allows us for 67 | identifying which models created by which (tethered) device(s) 68 | belong togther. Ie, if two devices A and B are tethered, then 69 | the i'th model of A is always tethered with the i'th model of 70 | B (and vice versa) */ 71 | int nextUniqueModelID = 0; 72 | // Helper methods // 73 | 74 | bool hasBeenCommitted = false; 75 | 76 | BarneyGlobalState(ANARIDevice d); 77 | void markSceneChanged(); 78 | }; 79 | 80 | // Helper functions/macros //////////////////////////////////////////////////// 81 | 82 | inline BarneyGlobalState *asBarneyState(helium::BaseGlobalDeviceState *s) 83 | { 84 | return (BarneyGlobalState *)s; 85 | } 86 | 87 | #define BARNEY_ANARI_TYPEFOR_SPECIALIZATION(type, anari_type) \ 88 | namespace anari { \ 89 | ANARI_TYPEFOR_SPECIALIZATION(type, anari_type); \ 90 | } 91 | 92 | #define BARNEY_ANARI_TYPEFOR_DEFINITION(type) \ 93 | namespace anari { \ 94 | ANARI_TYPEFOR_DEFINITION(type); \ 95 | } 96 | 97 | } // namespace barney_device 98 | -------------------------------------------------------------------------------- /anari/Camera.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "Camera.h" 5 | 6 | namespace barney_device { 7 | 8 | Camera::Camera(BarneyGlobalState *s) : Object(ANARI_CAMERA, s) {} 9 | 10 | Camera::~Camera() 11 | { 12 | if (m_barneyCamera) 13 | bnRelease(m_barneyCamera); 14 | } 15 | 16 | Camera *Camera::createInstance(std::string_view type, BarneyGlobalState *s) 17 | { 18 | if (type == "perspective") 19 | return new Perspective(s); 20 | else 21 | return (Camera *)new UnknownObject(ANARI_CAMERA, s); 22 | } 23 | 24 | void Camera::commitParameters() 25 | { 26 | m_pos = getParam("position", math::float3(0.f, 0.f, 0.f)); 27 | m_dir = math::normalize( 28 | getParam("direction", math::float3(0.f, 0.f, 1.f))); 29 | m_up = math::normalize( 30 | getParam("up", math::float3(0.f, 1.f, 0.f))); 31 | m_imageRegion = math::float4(0.f, 0.f, 1.f, 1.f); 32 | getParam("imageRegion", ANARI_FLOAT32_BOX2, &m_imageRegion); 33 | } 34 | 35 | BNCamera Camera::barneyCamera() const 36 | { 37 | return m_barneyCamera; 38 | } 39 | 40 | // Subtypes /////////////////////////////////////////////////////////////////// 41 | 42 | Perspective::Perspective(BarneyGlobalState *s) : Camera(s) 43 | { 44 | assert(deviceState()); 45 | assert(deviceState()->tether); 46 | assert(deviceState()->tether->context); 47 | m_barneyCamera = bnCameraCreate(deviceState()->tether->context, "perspective"); 48 | } 49 | 50 | void Perspective::commitParameters() 51 | { 52 | Camera::commitParameters(); 53 | m_aspect = getParam("aspect", 1.f); 54 | m_fovy = getParam("fovy", anari::radians(60.f)); 55 | m_focusDistance = getParam("focusDistance", 0.f); 56 | m_apertureRadius = getParam("apertureRadius", 0.f); 57 | } 58 | 59 | void Perspective::finalize() 60 | { 61 | bnSet3fc(m_barneyCamera, "up", m_up); 62 | bnSet3fc(m_barneyCamera, "position", m_pos); 63 | bnSet3fc(m_barneyCamera, "direction", m_dir); 64 | bnSet1f(m_barneyCamera, "aspect", m_aspect); 65 | bnSet1f(m_barneyCamera, "focusDistance", m_focusDistance); 66 | bnSet1f(m_barneyCamera, "apertureRadius", m_apertureRadius); 67 | bnSet1f(m_barneyCamera, "fovy", anari::degrees(m_fovy)); 68 | bnCommit(m_barneyCamera); 69 | } 70 | 71 | } // namespace barney_device 72 | 73 | BARNEY_ANARI_TYPEFOR_DEFINITION(barney_device::Camera *); 74 | -------------------------------------------------------------------------------- /anari/Camera.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Object.h" 7 | 8 | namespace barney_device { 9 | 10 | struct Camera : public Object 11 | { 12 | Camera(BarneyGlobalState *s); 13 | ~Camera() override; 14 | 15 | virtual void commitParameters() override; 16 | 17 | static Camera *createInstance( 18 | std::string_view type, BarneyGlobalState *state); 19 | 20 | math::float4 imageRegion() const; 21 | 22 | BNCamera barneyCamera() const; 23 | 24 | protected: 25 | math::float3 m_pos; 26 | math::float3 m_dir; 27 | math::float3 m_up; 28 | math::float4 m_imageRegion; 29 | 30 | BNCamera m_barneyCamera{nullptr}; 31 | }; 32 | 33 | // Subtypes /////////////////////////////////////////////////////////////////// 34 | 35 | struct Perspective : public Camera 36 | { 37 | Perspective(BarneyGlobalState *s); 38 | 39 | void commitParameters() override; 40 | void finalize() override; 41 | 42 | private: 43 | float m_fovy{30.f}; 44 | float m_aspect{1.f}; 45 | float m_focusDistance = 0.f; 46 | float m_apertureRadius = 0.f; 47 | }; 48 | 49 | } // namespace barney_device 50 | 51 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Camera *, ANARI_CAMERA); 52 | -------------------------------------------------------------------------------- /anari/Frame.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Camera.h" 7 | #include "Renderer.h" 8 | #include "World.h" 9 | // helium 10 | #include "helium/BaseFrame.h" 11 | // std 12 | #include 13 | 14 | namespace barney_device { 15 | 16 | struct Frame : public helium::BaseFrame 17 | { 18 | Frame(BarneyGlobalState *s); 19 | ~Frame() override; 20 | 21 | bool isValid() const override; 22 | 23 | BarneyGlobalState *deviceState() const; 24 | 25 | bool getProperty(const std::string_view &name, 26 | ANARIDataType type, 27 | void *ptr, 28 | uint32_t flags) override; 29 | 30 | void commitParameters() override; 31 | void finalize() override; 32 | 33 | void renderFrame() override; 34 | 35 | void *map(std::string_view channel, 36 | uint32_t *width, 37 | uint32_t *height, 38 | ANARIDataType *pixelType) override; 39 | void unmap(std::string_view channel) override; 40 | int frameReady(ANARIWaitMask m) override; 41 | void discard() override; 42 | 43 | bool ready() const; 44 | void wait() const; 45 | 46 | private: 47 | void cleanup(); 48 | 49 | bool m_valid {false}; 50 | bool m_enableDenoising {true}; 51 | math::uint2 m_size { 0,0 }; 52 | 53 | struct { 54 | // color cold be uint or float4; if float4 we just allocate 55 | // 4uints and store in those 56 | uint32_t *color{nullptr}; 57 | float *depth{nullptr}; 58 | int *primID{nullptr}; 59 | int *instID{nullptr}; 60 | int *objID{nullptr}; 61 | } m_channelBuffers; 62 | struct { 63 | /* for performance warnings; initialize all to 'true' so they 64 | won't throw a perf warning on first time renderframe */ 65 | bool color = true; 66 | bool depth = true; 67 | bool primID = true; 68 | bool instID = true; 69 | bool objID = true; 70 | } m_didMapChannel; 71 | bool m_lastFrameWasFirstFrame = true; 72 | 73 | struct { 74 | anari::DataType color{ANARI_UNKNOWN}; 75 | anari::DataType depth{ANARI_UNKNOWN}; 76 | anari::DataType primID{ANARI_UNKNOWN}; 77 | anari::DataType instID{ANARI_UNKNOWN}; 78 | anari::DataType objID{ANARI_UNKNOWN}; 79 | } m_channelTypes; 80 | 81 | helium::ChangeObserverPtr m_renderer; 82 | helium::IntrusivePtr m_camera; 83 | helium::IntrusivePtr m_world; 84 | 85 | helium::TimeStamp m_lastCommitFlush{0}; 86 | 87 | mutable float m_duration{0.f}; 88 | 89 | BNFrameBuffer m_bnFrameBuffer{nullptr}; 90 | }; 91 | 92 | } // namespace barney_device 93 | 94 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Frame *, ANARI_FRAME); 95 | -------------------------------------------------------------------------------- /anari/Group.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "light/Light.h" 7 | #include "Surface.h" 8 | #include "Volume.h" 9 | // std 10 | #include 11 | 12 | namespace barney_device { 13 | 14 | struct Group : public Object 15 | { 16 | Group(BarneyGlobalState *s); 17 | ~Group() override; 18 | 19 | void commitParameters() override; 20 | void markFinalized() override; 21 | 22 | BNGroup makeBarneyGroup() const; 23 | 24 | box3 bounds() const; 25 | 26 | private: 27 | helium::ChangeObserverPtr m_surfaceData; 28 | helium::ChangeObserverPtr m_volumeData; 29 | helium::ChangeObserverPtr m_lightData; 30 | }; 31 | 32 | } // namespace barney_device 33 | 34 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Group *, ANARI_GROUP); 35 | -------------------------------------------------------------------------------- /anari/Instance.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Group.h" 7 | 8 | namespace barney_device { 9 | 10 | struct Instance : public Object 11 | { 12 | struct Attributes { 13 | enum { count = 5 }; 14 | // for sake of easier processing we store those as jsut five 15 | // unnamed attributes; at the time fo thise writing attibute[4] 16 | // is implicitly color (across all anari apps, not just banrey), 17 | // but that may of course change going forward 18 | math::float4 values[count]; 19 | }; 20 | 21 | Instance(BarneyGlobalState *s); 22 | ~Instance() override; 23 | 24 | void commitParameters() override; 25 | void finalize() override; 26 | void markFinalized() override; 27 | 28 | bool isValid() const override; 29 | 30 | const Group *group() const; 31 | 32 | /*! writes the anari 4x4 matrix out into a barney-style 4x3 33 | matrix, into the memory location indicated by the provided 34 | pointer */ 35 | void writeTransform(BNTransform *out) const; 36 | 37 | box3 bounds() const; 38 | 39 | /*! attributes for that instance, if specified. if not specifies 40 | this will be a null pointer */ 41 | Attributes *attributes = 0; 42 | int m_id = ~0; 43 | private: 44 | math::mat4 m_transform; 45 | helium::IntrusivePtr m_group; 46 | }; 47 | 48 | } // namespace barney_device 49 | 50 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Instance *, ANARI_INSTANCE); 51 | -------------------------------------------------------------------------------- /anari/Library.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "Device.h" 5 | // anari 6 | #include "BarneyDeviceQueries.h" 7 | #include "anari/backend/LibraryImpl.h" 8 | #include "anari_library_barney_export.h" 9 | 10 | namespace barney_device { 11 | 12 | struct BarneyLibrary : public anari::LibraryImpl 13 | { 14 | BarneyLibrary(void *lib, 15 | ANARIStatusCallback defaultStatusCB, 16 | const void *statusCBPtr); 17 | 18 | ANARIDevice newDevice(const char *subtype) override; 19 | const char **getDeviceExtensions(const char *deviceType) override; 20 | }; 21 | 22 | // Definitions //////////////////////////////////////////////////////////////// 23 | 24 | BarneyLibrary::BarneyLibrary(void *lib, 25 | ANARIStatusCallback defaultStatusCB, 26 | const void *statusCBPtr) 27 | : anari::LibraryImpl(lib, defaultStatusCB, statusCBPtr) 28 | {} 29 | 30 | ANARIDevice BarneyLibrary::newDevice(const char *subType) 31 | { 32 | return (ANARIDevice) new BarneyDevice(this_library(),subType); 33 | } 34 | 35 | const char **BarneyLibrary::getDeviceExtensions(const char * /*deviceType*/) 36 | { 37 | return query_extensions(); 38 | } 39 | 40 | 41 | } // namespace barney_device 42 | 43 | // Define library entrypoint ////////////////////////////////////////////////// 44 | #if BARNEY_MPI 45 | extern "C" 46 | BARNEY_LIBRARY_INTERFACE 47 | ANARI_DEFINE_LIBRARY_ENTRYPOINT(barney_mpi, handle, scb, scbPtr) 48 | { 49 | return (ANARILibrary) new barney_device::BarneyLibrary(handle, scb, scbPtr); 50 | } 51 | #else 52 | extern "C" 53 | BARNEY_LIBRARY_INTERFACE 54 | ANARI_DEFINE_LIBRARY_ENTRYPOINT(barney, handle, scb, scbPtr) 55 | { 56 | return (ANARILibrary) new barney_device::BarneyLibrary(handle, scb, scbPtr); 57 | } 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /anari/Object.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Khronos Group 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "Object.h" 5 | // std 6 | #include 7 | #include 8 | 9 | namespace barney_device { 10 | 11 | // Object definitions ///////////////////////////////////////////////////////// 12 | 13 | Object::Object(ANARIDataType type, BarneyGlobalState *s) 14 | : helium::BaseObject(type, s) 15 | {} 16 | 17 | void Object::commitParameters() 18 | { 19 | // no-op 20 | } 21 | 22 | void Object::finalize() 23 | { 24 | // no-op 25 | } 26 | 27 | bool Object::getProperty( 28 | const std::string_view &name, ANARIDataType type, void *ptr, uint32_t flags) 29 | { 30 | if (name == "valid" && type == ANARI_BOOL) { 31 | helium::writeToVoidP(ptr, isValid()); 32 | return true; 33 | } 34 | 35 | return false; 36 | } 37 | 38 | bool Object::isValid() const 39 | { 40 | return true; 41 | } 42 | 43 | BarneyGlobalState *Object::deviceState() const 44 | { 45 | return (BarneyGlobalState *)helium::BaseObject::m_state; 46 | } 47 | 48 | // BNContext Object::getContext() const 49 | // { 50 | // return deviceState()->context; 51 | // } 52 | 53 | // UnknownObject definitions ////////////////////////////////////////////////// 54 | 55 | UnknownObject::UnknownObject(ANARIDataType type, BarneyGlobalState *s) 56 | : Object(type, s) 57 | {} 58 | 59 | UnknownObject::~UnknownObject() = default; 60 | 61 | bool UnknownObject::isValid() const 62 | { 63 | return false; 64 | } 65 | 66 | } // namespace barney_device 67 | 68 | BARNEY_ANARI_TYPEFOR_DEFINITION(barney_device::Object *); 69 | -------------------------------------------------------------------------------- /anari/Object.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "BarneyGlobalState.h" 7 | #include "common.h" 8 | // helium 9 | #include "helium/BaseObject.h" 10 | #include "helium/utility/ChangeObserverPtr.h" 11 | // std 12 | #include 13 | 14 | namespace barney_device { 15 | 16 | struct Object : public helium::BaseObject 17 | { 18 | Object(ANARIDataType type, BarneyGlobalState *s); 19 | virtual ~Object() = default; 20 | 21 | bool getProperty(const std::string_view &name, 22 | ANARIDataType type, 23 | void *ptr, 24 | uint32_t flags) override; 25 | 26 | void commitParameters() override; 27 | void finalize() override; 28 | bool isValid() const override; 29 | 30 | // BNContext getContext() const; 31 | BarneyGlobalState *deviceState() const; 32 | }; 33 | 34 | struct UnknownObject : public Object 35 | { 36 | UnknownObject(ANARIDataType type, BarneyGlobalState *s); 37 | ~UnknownObject() override; 38 | bool isValid() const override; 39 | }; 40 | 41 | } // namespace barney_device 42 | 43 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Object *, ANARI_OBJECT); 44 | -------------------------------------------------------------------------------- /anari/Renderer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "Renderer.h" 5 | 6 | namespace barney_device { 7 | 8 | Renderer::Renderer(BarneyGlobalState *s) 9 | : Object(ANARI_RENDERER, s), m_backgroundImage(this) 10 | { 11 | barneyRenderer = bnRendererCreate(deviceState()->tether->context, "default"); 12 | } 13 | 14 | Renderer::~Renderer() 15 | { 16 | bnRelease(barneyRenderer); 17 | } 18 | 19 | void Renderer::commitParameters() 20 | { 21 | m_pixelSamples = getParam("pixelSamples", 1); 22 | m_ambientRadiance = getParam("ambientRadiance", 1.f); 23 | m_crosshairs = getParam("crosshairs", false); 24 | m_denoise = getParam("denoise", true); 25 | m_background = getParam("background", math::float4(0, 0, 0, 1)); 26 | m_backgroundImage = getParamObject("background"); 27 | } 28 | 29 | void Renderer::finalize() 30 | { 31 | bnSet4fc(barneyRenderer, "bgColor", m_background); 32 | bnSet1i(barneyRenderer, "crosshairs", (int)m_crosshairs); 33 | bnSet1i(barneyRenderer, "pathsPerPixel", (int)m_pixelSamples); 34 | bnSet1f(barneyRenderer, "ambientRadiance", m_ambientRadiance); 35 | 36 | if (m_backgroundImage) { 37 | int sx = m_backgroundImage->size().x; 38 | int sy = m_backgroundImage->size().y; 39 | const bn_float4 *texels 40 | = (const bn_float4 *)m_backgroundImage->data(); 41 | barneyBackgroundImage 42 | = bnTexture2DCreate(deviceState()->tether->context,-1, 43 | BN_FLOAT4,sx,sy, 44 | texels, 45 | BN_TEXTURE_LINEAR, 46 | BN_TEXTURE_CLAMP,BN_TEXTURE_CLAMP); 47 | bnSetObject(barneyRenderer,"bgTexture",barneyBackgroundImage); 48 | } else { 49 | if (barneyBackgroundImage) { 50 | bnRelease(barneyBackgroundImage); 51 | barneyBackgroundImage = 0; 52 | bnSetObject(barneyRenderer,"bgTexture",0); 53 | } 54 | } 55 | bnCommit(barneyRenderer); 56 | } 57 | 58 | bool Renderer::crosshairs() const 59 | { 60 | return m_crosshairs; 61 | } 62 | 63 | bool Renderer::denoise() const 64 | { 65 | return m_denoise; 66 | } 67 | 68 | bool Renderer::isValid() const 69 | { 70 | return barneyRenderer != 0; 71 | } 72 | 73 | } // namespace barney_device 74 | 75 | BARNEY_ANARI_TYPEFOR_DEFINITION(barney_device::Renderer *); 76 | -------------------------------------------------------------------------------- /anari/Renderer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Array.h" 7 | #include "Object.h" 8 | 9 | namespace barney_device { 10 | 11 | struct Renderer : public Object 12 | { 13 | Renderer(BarneyGlobalState *s); 14 | ~Renderer() override; 15 | 16 | void commitParameters() override; 17 | void finalize() override; 18 | 19 | bool crosshairs() const; 20 | bool denoise() const; 21 | bool isValid() const override; 22 | 23 | BNRenderer barneyRenderer{nullptr}; 24 | 25 | private: 26 | BNTexture2D barneyBackgroundImage{nullptr}; 27 | 28 | int m_pixelSamples{1}; 29 | float m_ambientRadiance{0.8f}; 30 | bool m_crosshairs{false}; 31 | bool m_denoise{true}; 32 | anari::math::float4 m_background{0.f, 0.f, 0.f, 1.f}; 33 | helium::ChangeObserverPtr m_backgroundImage; 34 | }; 35 | 36 | } // namespace barney_device 37 | 38 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Renderer *, ANARI_RENDERER); 39 | -------------------------------------------------------------------------------- /anari/Sampler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Object.h" 7 | #include "common.h" 8 | #include "helium/array/Array1D.h" 9 | #include "helium/array/Array2D.h" 10 | 11 | namespace barney_device { 12 | 13 | struct Sampler : public Object 14 | { 15 | Sampler(BarneyGlobalState *s); 16 | ~Sampler() override; 17 | 18 | static Sampler *createInstance(std::string_view subtype, 19 | BarneyGlobalState *s); 20 | 21 | BNSampler getBarneySampler(); 22 | 23 | protected: 24 | virtual void createBarneySampler() = 0; 25 | void cleanup(); 26 | 27 | mutable BNSampler m_bnSampler{nullptr}; 28 | 29 | // this should atually live with the data array that the image 30 | // sampler(s) are referencing: 31 | mutable BNTextureData m_bnTextureData{nullptr}; 32 | }; 33 | 34 | // Subtypes /////////////////////////////////////////////////////////////////// 35 | 36 | struct Image1D : public Sampler 37 | { 38 | Image1D(BarneyGlobalState *s); 39 | ~Image1D() override; 40 | void commitParameters() override; 41 | 42 | bool isValid() const override; 43 | 44 | private: 45 | void createBarneySampler() override; 46 | 47 | helium::IntrusivePtr m_image; 48 | std::string m_inAttribute; 49 | BNTextureAddressMode m_wrapMode{BN_TEXTURE_CLAMP}; 50 | bool m_linearFilter{true}; 51 | math::mat4 m_inTransform{math::identity}; 52 | math::float4 m_inOffset{0.f, 0.f, 0.f, 0.f}; 53 | math::mat4 m_outTransform{math::identity}; 54 | math::float4 m_outOffset{0.f, 0.f, 0.f, 0.f}; 55 | }; 56 | 57 | struct Image2D : public Sampler 58 | { 59 | Image2D(BarneyGlobalState *s); 60 | ~Image2D() override; 61 | void commitParameters() override; 62 | 63 | bool isValid() const override; 64 | 65 | private: 66 | void createBarneySampler() override; 67 | 68 | helium::IntrusivePtr m_image; 69 | std::string m_inAttribute; 70 | BNTextureAddressMode m_wrapMode1{BN_TEXTURE_CLAMP}; 71 | BNTextureAddressMode m_wrapMode2{BN_TEXTURE_CLAMP}; 72 | bool m_linearFilter{true}; 73 | math::mat4 m_inTransform{math::identity}; 74 | math::float4 m_inOffset{0.f, 0.f, 0.f, 0.f}; 75 | math::mat4 m_outTransform{math::identity}; 76 | math::float4 m_outOffset{0.f, 0.f, 0.f, 0.f}; 77 | }; 78 | 79 | struct TransformSampler : public Sampler 80 | { 81 | TransformSampler(BarneyGlobalState *s); 82 | ~TransformSampler() override; 83 | void commitParameters() override; 84 | 85 | private: 86 | void createBarneySampler() override; 87 | 88 | std::string m_inAttribute; 89 | math::mat4 m_outTransform{math::identity}; 90 | math::float4 m_outOffset{0.f, 0.f, 0.f, 0.f}; 91 | }; 92 | 93 | } // namespace barney_device 94 | 95 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Sampler *, ANARI_SAMPLER); 96 | -------------------------------------------------------------------------------- /anari/Surface.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "Surface.h" 5 | 6 | namespace barney_device { 7 | 8 | Surface::Surface(BarneyGlobalState *s) : Object(ANARI_SURFACE, s) {} 9 | 10 | Surface::~Surface() 11 | { 12 | cleanup(); 13 | } 14 | 15 | void Surface::commitParameters() 16 | { 17 | m_id = getParam("id", ~0u); 18 | m_geometry = getParamObject("geometry"); 19 | m_material = getParamObject("material"); 20 | } 21 | 22 | void Surface::finalize() 23 | { 24 | if (!m_material) { 25 | reportMessage(ANARI_SEVERITY_WARNING, "missing 'material' on ANARISurface"); 26 | return; 27 | } 28 | 29 | if (!m_geometry) { 30 | reportMessage(ANARI_SEVERITY_WARNING, "missing 'geometry' on ANARISurface"); 31 | return; 32 | } 33 | 34 | setBarneyParameters(); 35 | } 36 | 37 | void Surface::markFinalized() 38 | { 39 | deviceState()->markSceneChanged(); 40 | Object::markFinalized(); 41 | } 42 | 43 | const Geometry *Surface::geometry() const 44 | { 45 | return m_geometry.ptr; 46 | } 47 | 48 | const Material *Surface::material() const 49 | { 50 | return m_material.ptr; 51 | } 52 | 53 | BNGeom Surface::getBarneyGeom() 54 | { 55 | int slot = deviceState()->slot; 56 | auto context = deviceState()->tether->context; 57 | 58 | cleanup(); 59 | m_bnGeom = bnGeometryCreate(context, slot, m_geometry->bnSubtype()); 60 | setBarneyParameters(); 61 | 62 | return m_bnGeom; 63 | } 64 | 65 | bool Surface::isValid() const 66 | { 67 | return m_geometry && m_material && m_geometry->isValid() 68 | && m_material->isValid(); 69 | } 70 | 71 | void Surface::setBarneyParameters() 72 | { 73 | if (!isValid() || !m_bnGeom) 74 | return; 75 | bnSetObject(m_bnGeom, "material", m_material->getBarneyMaterial()); 76 | bnSet1i(m_bnGeom,"userID",m_id); 77 | m_geometry->setBarneyParameters(m_bnGeom); 78 | bnCommit(m_bnGeom); 79 | } 80 | 81 | void Surface::cleanup() 82 | { 83 | if (m_bnGeom) 84 | bnRelease(m_bnGeom); 85 | m_bnGeom = nullptr; 86 | } 87 | 88 | } // namespace barney_device 89 | 90 | BARNEY_ANARI_TYPEFOR_DEFINITION(barney_device::Surface *); 91 | -------------------------------------------------------------------------------- /anari/Surface.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Geometry.h" 7 | #include "Material.h" 8 | 9 | namespace barney_device { 10 | 11 | struct Surface : public Object 12 | { 13 | Surface(BarneyGlobalState *s); 14 | ~Surface() override; 15 | 16 | void commitParameters() override; 17 | void finalize() override; 18 | void markFinalized() override; 19 | 20 | uint32_t id() const; 21 | const Geometry *geometry() const; 22 | const Material *material() const; 23 | 24 | BNGeom getBarneyGeom(); 25 | 26 | bool isValid() const override; 27 | 28 | private: 29 | void setBarneyParameters(); 30 | void cleanup(); 31 | 32 | uint32_t m_id{~0u}; 33 | helium::IntrusivePtr m_geometry; 34 | helium::IntrusivePtr m_material; 35 | 36 | BNGeom m_bnGeom{nullptr}; 37 | BNMaterial m_bnMat{nullptr}; 38 | }; 39 | 40 | } // namespace barney_device 41 | 42 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Surface *, ANARI_SURFACE); 43 | -------------------------------------------------------------------------------- /anari/Volume.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Array.h" 7 | #include "Object.h" 8 | #include "SpatialField.h" 9 | 10 | namespace barney_device { 11 | 12 | struct Volume : public Object 13 | { 14 | Volume(BarneyGlobalState *s); 15 | ~Volume() override; 16 | 17 | static Volume *createInstance(std::string_view subtype, BarneyGlobalState *s); 18 | 19 | void markFinalized() override; 20 | 21 | BNVolume getBarneyVolume(); 22 | 23 | virtual box3 bounds() const = 0; 24 | void commitParameters() override; 25 | 26 | protected: 27 | virtual BNVolume createBarneyVolume() = 0; 28 | virtual void setBarneyParameters() = 0; 29 | void cleanup(); 30 | 31 | uint32_t m_id{~0u}; 32 | BNVolume m_bnVolume{nullptr}; 33 | }; 34 | 35 | // Subtypes /////////////////////////////////////////////////////////////////// 36 | 37 | struct TransferFunction1D : public Volume 38 | { 39 | TransferFunction1D(BarneyGlobalState *s); 40 | 41 | void commitParameters() override; 42 | void finalize() override; 43 | bool isValid() const override; 44 | 45 | BNVolume createBarneyVolume() override; 46 | 47 | box3 bounds() const override; 48 | 49 | private: 50 | void setBarneyParameters() override; 51 | 52 | helium::IntrusivePtr m_field; 53 | 54 | box3 m_bounds; 55 | 56 | box1 m_valueRange{0.f, 1.f}; 57 | float m_densityScale{1.f}; 58 | math::float4 m_uniformColor{1.f, 1.f, 1.f, 1.f}; 59 | float m_uniformOpacity{1.f}; 60 | 61 | helium::ChangeObserverPtr m_colorData; 62 | helium::ChangeObserverPtr m_opacityData; 63 | bool needsOpacityData; 64 | 65 | std::vector m_rgbaMap; 66 | }; 67 | 68 | } // namespace barney_device 69 | 70 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Volume *, ANARI_VOLUME); 71 | -------------------------------------------------------------------------------- /anari/World.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Array.h" 7 | #include "Instance.h" 8 | 9 | namespace barney_device { 10 | 11 | struct World : public Object 12 | { 13 | World(BarneyGlobalState *s); 14 | ~World() override; 15 | 16 | bool getProperty(const std::string_view &name, 17 | ANARIDataType type, 18 | void *ptr, 19 | uint32_t flags) override; 20 | 21 | void commitParameters() override; 22 | void finalize() override; 23 | 24 | BNModel makeCurrent(); 25 | 26 | private: 27 | void buildBarneyModel(); 28 | 29 | helium::ChangeObserverPtr m_zeroSurfaceData; 30 | helium::ChangeObserverPtr m_zeroVolumeData; 31 | helium::ChangeObserverPtr m_zeroLightData; 32 | helium::ChangeObserverPtr m_instanceData; 33 | 34 | helium::IntrusivePtr m_zeroGroup; 35 | helium::IntrusivePtr m_zeroInstance; 36 | 37 | std::vector m_instances; 38 | 39 | // BNModel m_barneyModel{nullptr}; 40 | int uniqueID = -1; 41 | 42 | BNData m_attributesData[Instance::Attributes::count] = {0,0,0,0,0}; 43 | helium::TimeStamp m_lastBarneyModelBuild{0}; 44 | }; 45 | 46 | } // namespace barney_device 47 | 48 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::World *, ANARI_WORLD); 49 | -------------------------------------------------------------------------------- /anari/barney_device.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "name": "BARNEY_DEVICE", 4 | "type": "device", 5 | "dependencies": [ 6 | "anari_core_1_0", 7 | "anari_core_objects_base_1_0", 8 | "khr_camera_depth_of_field", 9 | "khr_camera_perspective", 10 | "khr_device_synchronization", 11 | "khr_frame_accumulation", 12 | "khr_frame_channel_primitive_id", 13 | "khr_frame_channel_object_id", 14 | "khr_frame_channel_instance_id", 15 | "khr_geometry_cone", 16 | "khr_geometry_cylinder", 17 | "khr_geometry_curve", 18 | "khr_geometry_quad", 19 | "khr_geometry_sphere", 20 | "khr_geometry_triangle", 21 | "khr_instance_transform", 22 | "khr_light_directional", 23 | "khr_light_hdri", 24 | "khr_light_point", 25 | "khr_material_matte", 26 | "khr_material_physically_based", 27 | "khr_renderer_ambient_light", 28 | "khr_renderer_background_color", 29 | "khr_renderer_background_image", 30 | "khr_sampler_image1d", 31 | "khr_sampler_image2d", 32 | "khr_sampler_image3d", 33 | "khr_sampler_transform", 34 | "khr_spatial_field_structured_regular", 35 | "khr_volume_transfer_function1d", 36 | "nv_frame_buffers_cuda" 37 | ] 38 | }, 39 | "objects": [ 40 | { 41 | "type": "ANARI_RENDERER", 42 | "name": "default", 43 | "parameters": [ 44 | { 45 | "name": "background", 46 | "types": [ 47 | "ANARI_FLOAT32_VEC4" 48 | ], 49 | "tags": [], 50 | "default": [ 51 | 0.0, 52 | 0.0, 53 | 0.0, 54 | 1.0 55 | ], 56 | "description": "background color and alpha (RGBA)" 57 | }, 58 | { 59 | "name": "pixelSamples", 60 | "types": [ 61 | "ANARI_INT32" 62 | ], 63 | "tags": [], 64 | "default": 1, 65 | "description": "number of pixel samples per-frame" 66 | }, 67 | { 68 | "name": "ambientRadiance", 69 | "types": [ 70 | "ANARI_FLOAT32" 71 | ], 72 | "tags": [], 73 | "default": 1.0, 74 | "description": "ambient light intensity" 75 | }, 76 | { 77 | "name": "denoise", 78 | "types": [ 79 | "ANARI_BOOL" 80 | ], 81 | "tags": [], 82 | "default": true, 83 | "description": "denoise image" 84 | }, 85 | { 86 | "name": "crosshairs", 87 | "types": [ 88 | "ANARI_BOOL" 89 | ], 90 | "tags": [], 91 | "default": false, 92 | "description": "enable crosshairs" 93 | } 94 | ] 95 | } 96 | ] 97 | } -------------------------------------------------------------------------------- /anari/dummy.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | __global__ void dummyKernel() 5 | { 6 | printf("dummuy\n"); 7 | } 8 | 9 | extern "C" void dummy_anari() 10 | { 11 | dummyKernel<<<32, 32>>>(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /anari/light/Directional.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "light/Directional.h" 5 | 6 | namespace barney_device { 7 | 8 | Directional::Directional(BarneyGlobalState *s) : Light(s) {} 9 | 10 | void Directional::commitParameters() 11 | { 12 | Light::commitParameters(); 13 | m_irradiance = getParam("irradiance", NAN); 14 | m_radiance = getParam("radiance", 1.f); 15 | m_direction = 16 | getParam("direction", math::float3(0.f, 0.f, -1.f)); 17 | } 18 | 19 | const char *Directional::bnSubtype() const 20 | { 21 | return "directional"; 22 | } 23 | 24 | void Directional::setBarneyParameters() 25 | { 26 | if (!m_bnLight) 27 | return; 28 | bnSet3fc(m_bnLight, "direction", m_direction); 29 | bnSet3fc(m_bnLight, "color", m_color); 30 | bnSet1f (m_bnLight, "radiance", m_radiance); 31 | bnSet1f (m_bnLight, "irradiance", m_irradiance); 32 | bnCommit(m_bnLight); 33 | } 34 | 35 | } // ::barney_device 36 | -------------------------------------------------------------------------------- /anari/light/Directional.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "light/Light.h" 7 | 8 | namespace barney_device { 9 | 10 | struct Directional : public Light 11 | { 12 | Directional(BarneyGlobalState *s); 13 | 14 | void commitParameters() override; 15 | 16 | private: 17 | const char *bnSubtype() const override; 18 | void setBarneyParameters() override; 19 | 20 | /*! SPEC: main emission direction of the directional light */ 21 | math::float3 m_direction{0.f, 0.f, -1.f}; 22 | 23 | /*! SPEC: the amount of light arriving at a surface point, 24 | assuming the light is oriented towards to the surface, in 25 | W/m2 */ 26 | float m_irradiance = NAN; 27 | /*! the amount of light emitted in a direction, in W/sr/m2; 28 | irradiance takes precedence if also specified */ 29 | float m_radiance = 1.f; 30 | }; 31 | 32 | } // ::barney_device 33 | -------------------------------------------------------------------------------- /anari/light/HDRI.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "light/HDRI.h" 5 | 6 | namespace barney_device { 7 | 8 | HDRILight::HDRILight(BarneyGlobalState *s) 9 | : Light(s) 10 | {} 11 | 12 | void HDRILight::commitParameters() 13 | { 14 | Light::commitParameters(); 15 | m_scale = getParam("scale", 1.f); 16 | m_up = getParam("up", math::float3(0.f, 0.f, 1.f)); 17 | m_direction = getParam("direction", math::float3(1.f, 0.f, 0.f)); 18 | m_radiance = getParamObject("radiance"); 19 | } 20 | 21 | void HDRILight::finalize() 22 | { 23 | if (!m_radiance) { 24 | throw std::runtime_error 25 | ("banari - created hdri light without any radiance values!?"); 26 | return; 27 | } 28 | Light::finalize(); 29 | } 30 | 31 | const char *HDRILight::bnSubtype() const 32 | { 33 | return "envmap"; 34 | } 35 | 36 | void HDRILight::setBarneyParameters() 37 | { 38 | if (!m_bnLight) 39 | return; 40 | 41 | int slot = deviceState()->slot; 42 | auto context = deviceState()->tether->context; 43 | 44 | bnSet3fc(m_bnLight, "direction", m_direction); 45 | bnSet3fc(m_bnLight, "up", m_up); 46 | bnSet1f (m_bnLight, "scale", m_scale); 47 | 48 | assert(m_radiance); 49 | int width = m_radiance->size().x; 50 | int height = m_radiance->size().y; 51 | const math::float3 *radianceValues 52 | = m_radiance->dataAs(); 53 | // cuda textures have to be float4, not float3, so barney only 54 | // supports float3, too 55 | std::vector asFloat4(width * height); 56 | for (int i = 0; i < width * height; i++) { 57 | (math::float3 &)asFloat4[i] = radianceValues[i]; 58 | } 59 | 60 | BNTexture texture = bnTexture2DCreate(context,slot, 61 | BN_FLOAT4, 62 | width, 63 | height, 64 | asFloat4.data(), 65 | BN_TEXTURE_LINEAR, 66 | BN_TEXTURE_WRAP, 67 | BN_TEXTURE_CLAMP, 68 | BN_COLOR_SPACE_LINEAR); 69 | 70 | bnSetObject(m_bnLight, "texture", texture); 71 | bnRelease(texture); 72 | 73 | bnCommit(m_bnLight); 74 | } 75 | 76 | } // ::barney_device 77 | -------------------------------------------------------------------------------- /anari/light/HDRI.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "light/Light.h" 7 | #include "helium/array/Array1D.h" 8 | #include "helium/array/Array2D.h" 9 | 10 | namespace barney_device { 11 | 12 | typedef helium::IntrusivePtr Array2DPtr; 13 | struct HDRILight : public Light 14 | { 15 | HDRILight(BarneyGlobalState *s); 16 | 17 | void commitParameters() override; 18 | void finalize() override; 19 | 20 | private: 21 | const char *bnSubtype() const override; 22 | void setBarneyParameters() override; 23 | 24 | float m_scale { 1.f }; 25 | math::float3 m_up { 0.f, 0.f, 1.f }; 26 | math::float3 m_direction { 1.f, 0.f, 0.f }; 27 | Array2DPtr m_radiance; 28 | }; 29 | 30 | } // ::barney_device 31 | 32 | -------------------------------------------------------------------------------- /anari/light/Light.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "light/Light.h" 5 | #include "light/Directional.h" 6 | #include "light/Point.h" 7 | #include "light/HDRI.h" 8 | 9 | namespace barney_device { 10 | 11 | Light::Light(BarneyGlobalState *s) : Object(ANARI_LIGHT, s) {} 12 | 13 | Light::~Light() 14 | { 15 | cleanup(); 16 | } 17 | 18 | Light *Light::createInstance(std::string_view type, BarneyGlobalState *s) 19 | { 20 | if (type == "directional") 21 | return new Directional(s); 22 | else if (type == "hdri") 23 | return new HDRILight(s); 24 | else if (type == "point") 25 | return new PointLight(s); 26 | else 27 | return (Light *)new UnknownObject(ANARI_LIGHT, s); 28 | } 29 | 30 | void Light::markFinalized() 31 | { 32 | // NOTE: shouldn't need to override this to cause a BNContext rebuild... 33 | deviceState()->markSceneChanged(); 34 | Object::markFinalized(); 35 | } 36 | 37 | void Light::commitParameters() 38 | { 39 | m_color = getParam("color", math::float3(1.f, 1.f, 1.f)); 40 | } 41 | 42 | void Light::finalize() 43 | { 44 | setBarneyParameters(); 45 | } 46 | 47 | BNLight Light::getBarneyLight() 48 | { 49 | int slot = deviceState()->slot; 50 | auto context = deviceState()->tether->context; 51 | 52 | m_bnLight = bnLightCreate(context,slot,bnSubtype()); 53 | setBarneyParameters(); 54 | return m_bnLight; 55 | } 56 | 57 | void Light::cleanup() 58 | { 59 | if (m_bnLight) 60 | bnRelease(m_bnLight); 61 | m_bnLight = nullptr; 62 | } 63 | 64 | } // ::barney_device 65 | 66 | BARNEY_ANARI_TYPEFOR_DEFINITION(barney_device::Light *); 67 | -------------------------------------------------------------------------------- /anari/light/Light.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "Object.h" 7 | 8 | namespace barney_device { 9 | 10 | struct Light : public Object 11 | { 12 | Light(BarneyGlobalState *s); 13 | ~Light() override; 14 | 15 | static Light *createInstance(std::string_view type, BarneyGlobalState *state); 16 | 17 | void markFinalized() override; 18 | virtual void commitParameters() override; 19 | void finalize() override; 20 | 21 | BNLight getBarneyLight(); 22 | 23 | protected: 24 | virtual const char *bnSubtype() const = 0; 25 | virtual void setBarneyParameters() = 0; 26 | 27 | void cleanup(); 28 | 29 | math::float3 m_color{1.f, 1.f, 1.f}; 30 | 31 | BNLight m_bnLight{nullptr}; 32 | }; 33 | 34 | } // ::barney_device 35 | 36 | BARNEY_ANARI_TYPEFOR_SPECIALIZATION(barney_device::Light *, ANARI_LIGHT); 37 | -------------------------------------------------------------------------------- /anari/light/Point.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "light/Point.h" 5 | 6 | namespace barney_device { 7 | 8 | PointLight::PointLight(BarneyGlobalState *s) : Light(s) {} 9 | 10 | void PointLight::commitParameters() 11 | { 12 | Light::commitParameters(); 13 | m_power = getParam("power", 1.f); 14 | m_intensity = getParam("intensity", NAN); 15 | } 16 | 17 | const char *PointLight::bnSubtype() const 18 | { 19 | return "point"; 20 | } 21 | 22 | void PointLight::setBarneyParameters() 23 | { 24 | if (!m_bnLight) 25 | return; 26 | bnSet3fc(m_bnLight, "direction", m_position); 27 | bnSet3fc(m_bnLight, "color", m_color); 28 | bnSet1f(m_bnLight, "intensity", m_intensity); 29 | bnSet1f(m_bnLight, "power", m_power); 30 | bnCommit(m_bnLight); 31 | } 32 | 33 | } // ::barney_device 34 | -------------------------------------------------------------------------------- /anari/light/Point.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Ingo Wald 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "light/Light.h" 7 | 8 | namespace barney_device { 9 | 10 | struct PointLight : public Light 11 | { 12 | PointLight(BarneyGlobalState *s); 13 | 14 | void commitParameters() override; 15 | 16 | private: 17 | const char *bnSubtype() const override; 18 | void setBarneyParameters() override; 19 | 20 | math::float3 m_position{0.f, 0.f, 0.f}; 21 | 22 | /*! SPEC: the overall amount of light emitted by the light in a 23 | direction, in W/sr */ 24 | float m_intensity = NAN; 25 | 26 | /*! SPEC: the overall amount of light energy emitted, in W; 27 | intensity takes precedence if also specified */ 28 | float m_power = 1.f; 29 | }; 30 | 31 | } // ::barney_device 32 | -------------------------------------------------------------------------------- /anari/nv_frame_buffers_cuda.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "name": "NV_FRAME_BUFFERS_CUDA", 4 | "type": "extension", 5 | "dependencies": [] 6 | }, 7 | "objects": [] 8 | } -------------------------------------------------------------------------------- /barney/Camera.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/common/barney-common.h" 20 | #include "barney/Object.h" 21 | 22 | namespace BARNEY_NS { 23 | 24 | /*! the camera model we use in barney */ 25 | struct Camera : public barney_api::Camera { 26 | typedef std::shared_ptr SP; 27 | typedef enum { UNDEFINED=0, PERSPECTIVE } Type; 28 | /*! device-data for the camera object; to avoid virtual functions 29 | this currently uses a 'type'-switch, so the camera code on the 30 | device will have to 'interpret' what the actual fields 31 | mean. on the host side, all derived cameras will have to fill 32 | in this one shared struct */ 33 | struct DD { 34 | Type type = UNDEFINED; 35 | 36 | /*! vector from camera center to to lower-left pixel (i.e., pixel 37 | (0,0)) on the focal plane */ 38 | vec3f dir_00; 39 | /* vector along u direction, for ONE pixel */ 40 | vec3f dir_du; 41 | /* vector along v direction, for ONE pixel */ 42 | vec3f dir_dv; 43 | /*! lens center ... */ 44 | vec3f lens_00; 45 | /* radius of lens, for DOF */ 46 | float apertureRadius; 47 | /* distance to focal plane, for DOF */ 48 | float focusDistance; 49 | }; 50 | DD dd; 51 | 52 | Camera(Context *owner); 53 | virtual ~Camera() = default; 54 | 55 | static Camera::SP create(Context *owner, const std::string &type); 56 | 57 | DD getDD() { return dd; } 58 | }; 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /barney/GlobalModel.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "barney/GlobalModel.h" 18 | 19 | namespace BARNEY_NS { 20 | 21 | GlobalModel::GlobalModel(Context *context) 22 | : barney_api::Model(context) 23 | { 24 | for (int slot=0;slotperSlot.size();slot++) { 25 | assert(context->perSlot[slot].devices); 26 | ModelSlot::SP modelSlot 27 | = std::make_shared(this,context->perSlot[slot].devices, 28 | slot); 29 | modelSlots.push_back(modelSlot); 30 | } 31 | } 32 | 33 | GlobalModel::~GlobalModel() 34 | {} 35 | 36 | void GlobalModel::render(barney_api::Renderer *renderer, 37 | barney_api::Camera *_camera, 38 | barney_api::FrameBuffer *_fb) 39 | { 40 | assert(context); 41 | FrameBuffer *fb = (FrameBuffer *)_fb; 42 | Camera *camera = (Camera *)_camera; 43 | assert(fb); 44 | Context *context = (Context *)this->context; 45 | context->ensureRayQueuesLargeEnoughFor(fb); 46 | context->render((Renderer*)renderer,this,camera,fb); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /barney/GlobalModel.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/Context.h" 20 | #include "barney/ModelSlot.h" 21 | 22 | namespace BARNEY_NS { 23 | 24 | struct ModelSlot; 25 | 26 | struct GlobalModel : public barney_api::Model {//SlottedObject { 27 | typedef std::shared_ptr SP; 28 | 29 | static SP create(Context *ctx) { return std::make_shared(ctx); } 30 | 31 | GlobalModel(Context *context); 32 | virtual ~GlobalModel(); 33 | 34 | /*! pretty-printer for printf-debugging */ 35 | std::string toString() const override 36 | { return "Model{}"; } 37 | 38 | void render(barney_api::Renderer *renderer, 39 | barney_api::Camera *camera, 40 | barney_api::FrameBuffer *fb) override; 41 | 42 | ModelSlot *getSlot(int whichSlot) 43 | { 44 | assert(whichSlot >= 0); 45 | assert(whichSlot < modelSlots.size()); 46 | return modelSlots[whichSlot].get(); 47 | } 48 | std::vector modelSlots; 49 | 50 | void setInstances(int slot, 51 | barney_api::Group **groups, 52 | const affine3f *xfms, 53 | int numInstances) override 54 | { getSlot(slot)->setInstances(groups,xfms,numInstances); } 55 | 56 | void setInstanceAttributes(int slot, 57 | const std::string &which, 58 | Data::SP data) override 59 | { getSlot(slot)->setInstanceAttributes(which,data?data->as():PODData::SP{}); } 60 | 61 | void build(int slot) override 62 | { getSlot(slot)->build(); } 63 | 64 | }; 65 | 66 | } // ::BARNEY_NS 67 | -------------------------------------------------------------------------------- /barney/LocalContext.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/Context.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | /*! a barney context for "local"-node rendering - no MPI */ 24 | struct LocalContext : public Context { 25 | 26 | LocalContext(const std::vector &dataGroupIDs, 27 | const std::vector &gpuIDs); 28 | 29 | virtual ~LocalContext(); 30 | 31 | /*! pretty-printer for printf-debugging */ 32 | std::string toString() const override 33 | { return "LocalFB{}"; } 34 | 35 | void render(Renderer *renderer, 36 | GlobalModel *model, 37 | Camera *camera, 38 | FrameBuffer *fb) override; 39 | 40 | /*! forward rays (during global trace); returns if _after_ that 41 | forward the rays need more tracing (true) or whether they're 42 | done (false) */ 43 | bool forwardRays(bool needHitIDs) override; 44 | 45 | /*! returns how many rays are active in all ray queues, across all 46 | devices and, where applicable, across all ranks */ 47 | int numRaysActiveGlobally() override; 48 | 49 | int myRank() override { return 0; } 50 | int mySize() override { return 1; } 51 | 52 | /*! create a frame buffer object suitable to this context */ 53 | std::shared_ptr 54 | createFrameBuffer(int owningRank) override; 55 | 56 | int numTimesForwarded = 0; 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /barney/Object.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "barney/Object.h" 18 | #include "barney/Context.h" 19 | #include "barney/ModelSlot.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | // Object::Object(Context *context) 24 | // : context(context) 25 | // {} 26 | 27 | SlottedObject::SlottedObject(Context *context, 28 | const DevGroup::SP &devices) 29 | : barney_api::Object(context), 30 | devices(devices) 31 | { 32 | assert(devices); 33 | assert(!devices->empty()); 34 | } 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /barney/Object.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/common/barney-common.h" 20 | #include "api/Context.h" 21 | #include "barney/DeviceGroup.h" 22 | 23 | namespace BARNEY_NS { 24 | 25 | struct Context; 26 | struct ModelSlot; 27 | using barney_api::Data; 28 | 29 | namespace render { 30 | struct World; 31 | }; 32 | 33 | /*! a object owned (only) in a particular data group */ 34 | struct SlottedObject : public barney_api::Object { 35 | SlottedObject(Context *context, const DevGroup::SP &devices); 36 | virtual ~SlottedObject() = default; 37 | 38 | /*! pretty-printer for printf-debugging */ 39 | std::string toString() const override { return ""; } 40 | 41 | const DevGroup::SP devices; 42 | }; 43 | 44 | // ================================================================== 45 | // INLINE IMPLEMENTATION SECTION 46 | // ================================================================== 47 | 48 | } 49 | -------------------------------------------------------------------------------- /barney/api/common.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2025++ Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/barneyConfig.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "barney/barney.h" 28 | // #include "barney/api/mat4.h" 29 | 30 | #include "owl/common/math/AffineSpace.h" 31 | 32 | namespace barney_api { 33 | using namespace owl::common; 34 | 35 | typedef owl::common::interval range1f; 36 | } 37 | -------------------------------------------------------------------------------- /barney/common/CUBQL.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2023 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/common/barney-common.h" 20 | #include "cuBQL/bvh.h" 21 | #if BARNEY_CUBQL_HOST 22 | # include "cuBQL/builder/cpu.h" 23 | #else 24 | # include "cuBQL/builder/cuda.h" 25 | #endif 26 | #include "cuBQL/traversal/shrinkingRadiusQuery.h" 27 | 28 | #ifdef __CUDACC__ 29 | namespace cuBQL { 30 | using float3 = ::float3; 31 | using float4 = ::float4; 32 | } 33 | #endif 34 | 35 | namespace BARNEY_NS { 36 | 37 | inline __both__ vec3f to_barney(cuBQL::float3 v) 38 | { return vec3f(v.x,v.y,v.z); } 39 | 40 | inline __both__ cuBQL::float3 to_cubql(vec3f v) 41 | { return {v.x,v.y,v.z}; } 42 | 43 | } // ::barney 44 | -------------------------------------------------------------------------------- /barney/common/barneyConfig.cmake.in: -------------------------------------------------------------------------------- 1 | ## Copyright 2021-2024 The Khronos Group 2 | ## SPDX-License-Identifier: Apache-2.0 3 | 4 | @PACKAGE_INIT@ 5 | 6 | include(CMakeFindDependencyMacro) 7 | 8 | set(THREADS_PREFER_PTHREAD_FLAG ON) 9 | find_dependency(Threads) 10 | 11 | include(${CMAKE_CURRENT_LIST_DIR}/barney-config.cmake) 12 | 13 | if (NOT TARGET barney::barney) 14 | message(FATAL_ERROR "CMAKE_PREFIX_PATH or barney_DIR are pointing to a \ 15 | barney build directory. Please do a full install of barney \ 16 | (e.g. 'make install') and point to where you installed it \ 17 | (CMAKE_INSTALL_PREFIX in your build of barney). \ 18 | Consuming barney from a build directory is not supported.") 19 | endif() 20 | set(barney_FOUND ON) 21 | 22 | set(BARNEY_DATAROOTDIR 23 | ${CMAKE_CURRENT_LIST_DIR}/../../../@CMAKE_INSTALL_DATAROOTDIR@/barney 24 | ) 25 | 26 | if (@BARNEY_MPI@) 27 | find_dependency(MPI) 28 | set(BARNEY_FEATURE_MPI ON) 29 | endif() 30 | 31 | 32 | foreach(component ${barney_FIND_COMPONENTS}) 33 | # For requested component, execute its "config" script 34 | message("cfind component ${component}") 35 | if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${component}-config.cmake") 36 | include(${CMAKE_CURRENT_LIST_DIR}/${component}-config.cmake) 37 | set(${component}_FOUND ON) 38 | else() 39 | set(${component}_FOUND OFF) 40 | endif() 41 | endforeach() 42 | 43 | check_required_components(@PROJECT_NAME@) 44 | -------------------------------------------------------------------------------- /barney/common/barneyConfig.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine01 BARNEY_HAVE_CUDA 2 | #cmakedefine01 BARNEY_OIDN_CPU 3 | #cmakedefine01 BARNEY_OIDN_GPU 4 | 5 | #cmakedefine01 BARNEY_DISABLE_DENOISING 6 | -------------------------------------------------------------------------------- /barney/common/random.h: -------------------------------------------------------------------------------- 1 | // https://www.shadertoy.com/view/md3BDs 2 | 3 | // ---8<---------------------------------------------------------------------- 4 | // Random number generator 5 | 6 | // https://www.pcg-random.org/ 7 | inline __rtc_device uint32_t pcg(uint32_t v) 8 | { 9 | uint32_t state = v * 747796405u + 2891336453u; 10 | uint32_t word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; 11 | return (word >> 22u) ^ word; 12 | } 13 | 14 | #if 0 15 | uvec2 pcg2d(uvec2 v) 16 | { 17 | v = v * 1664525u + 1013904223u; 18 | 19 | v.x += v.y * 1664525u; 20 | v.y += v.x * 1664525u; 21 | 22 | v = v ^ (v>>16u); 23 | 24 | v.x += v.y * 1664525u; 25 | v.y += v.x * 1664525u; 26 | 27 | v = v ^ (v>>16u); 28 | 29 | return v; 30 | } 31 | 32 | // http://www.jcgt.org/published/0009/03/02/ 33 | uvec3 pcg3d(uvec3 v) { 34 | 35 | v = v * 1664525u + 1013904223u; 36 | 37 | v.x += v.y*v.z; 38 | v.y += v.z*v.x; 39 | v.z += v.x*v.y; 40 | 41 | v ^= v >> 16u; 42 | 43 | v.x += v.y*v.z; 44 | v.y += v.z*v.x; 45 | v.z += v.x*v.y; 46 | 47 | return v; 48 | } 49 | 50 | // http://www.jcgt.org/published/0009/03/02/ 51 | uvec3 pcg3d16(uvec3 v) 52 | { 53 | v = v * 12829u + 47989u; 54 | 55 | v.x += v.y*v.z; 56 | v.y += v.z*v.x; 57 | v.z += v.x*v.y; 58 | 59 | v.x += v.y*v.z; 60 | v.y += v.z*v.x; 61 | v.z += v.x*v.y; 62 | 63 | v >>= 16u; 64 | 65 | return v; 66 | } 67 | 68 | // http://www.jcgt.org/published/0009/03/02/ 69 | uvec4 pcg4d(uvec4 v) 70 | { 71 | v = v * 1664525u + 1013904223u; 72 | 73 | v.x += v.y*v.w; 74 | v.y += v.z*v.x; 75 | v.z += v.x*v.y; 76 | v.w += v.y*v.z; 77 | 78 | v ^= v >> 16u; 79 | 80 | v.x += v.y*v.w; 81 | v.y += v.z*v.x; 82 | v.z += v.x*v.y; 83 | v.w += v.y*v.z; 84 | 85 | return v; 86 | } 87 | 88 | uvec3 seed = uvec3(0); 89 | void initSeed(vec2 fragCoord) 90 | { 91 | // FIXME: how to eliminate time glitches? 92 | seed = uvec3(fragCoord, iTime * 1e5); 93 | seed.zy ^= pcg2d(seed.xz); 94 | } 95 | 96 | float rand1() 97 | { 98 | seed = seed.yzx; 99 | seed.x = pcg(seed.x); 100 | return float(seed.x) * (1.0 / float(0xffffffffu)); 101 | } 102 | 103 | vec2 rand2() 104 | { 105 | seed = seed.yzx; 106 | seed.xy = pcg2d(seed.xy); 107 | return vec2(seed.xy) * (1.0 / float(0xffffffffu)); 108 | } 109 | 110 | vec3 rand3() 111 | { 112 | seed = pcg3d(seed); 113 | return vec3(seed) * (1.0 / float(0xffffffffu)); 114 | } 115 | #endif 116 | -------------------------------------------------------------------------------- /barney/geometry/Capsules.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/geometry/Geometry.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | /*! A geometry made of multiple "capsules", where each capsule is 24 | "pill-like" shape obtained by linearly connecting two 25 | spheres. Unlike cylinders both end-points of the capsule have 26 | their own radius that the rest of the shape linearly 27 | interpolates between; capsules also always have "rounded caps" 28 | in the sense that both of the end points form complete 29 | spheres. Capsules can also interpolate a "color" attribute. 30 | 31 | Is defined by three parameters: 32 | 33 | `int2 radii[]` two vertex indices per prim, specifying end point 34 | position and radii for each capsule. 35 | 36 | `float3 vertices[]` position (.xyz) and radius (.w) of each vertex 37 | */ 38 | struct Capsules : public Geometry { 39 | typedef std::shared_ptr SP; 40 | 41 | struct DD : public Geometry::DD { 42 | const vec4f *vertices; 43 | const vec2i *indices; 44 | }; 45 | 46 | Capsules(Context *context, DevGroup::SP devices); 47 | virtual ~Capsules() = default; 48 | 49 | /*! pretty-printer for printf-debugging */ 50 | std::string toString() const override 51 | { return "Capsules{}"; } 52 | 53 | void commit() override; 54 | 55 | // ------------------------------------------------------------------ 56 | /*! @{ parameter set/commit interface */ 57 | bool setData(const std::string &member, const barney_api::Data::SP &value) override; 58 | /*! @} */ 59 | // ------------------------------------------------------------------ 60 | 61 | PODData::SP vertices; 62 | PODData::SP indices; 63 | }; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /barney/geometry/Cones.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/geometry/Geometry.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | /*! cylinders with caps, specified through an array of vertices, and 24 | one array of int2 where each of the two its specified begin and 25 | end vertex of a cylinder. radii can either come from a separate 26 | array (if provided), or, i not, use a common radius specified in 27 | this geometry */ 28 | struct Cones : public Geometry { 29 | typedef std::shared_ptr SP; 30 | 31 | struct DD : public Geometry::DD { 32 | const vec3f *vertices; 33 | const vec2i *indices; 34 | const float *radii; 35 | }; 36 | 37 | Cones(Context *context, DevGroup::SP devices); 38 | virtual ~Cones() = default; 39 | 40 | /*! pretty-printer for printf-debugging */ 41 | std::string toString() const override 42 | { return "Cones{}"; } 43 | 44 | void commit() override; 45 | 46 | // ------------------------------------------------------------------ 47 | /*! @{ parameter set/commit interface */ 48 | bool setData(const std::string &member, const Data::SP &value) override; 49 | /*! @} */ 50 | // ------------------------------------------------------------------ 51 | 52 | PODData::SP vertices; 53 | PODData::SP indices; 54 | PODData::SP radii; 55 | }; 56 | 57 | } // ::BARNEY_NS 58 | -------------------------------------------------------------------------------- /barney/geometry/Cylinders.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/geometry/Geometry.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | /*! cylinders with caps, specified through an array of vertices, and 24 | one array of int2 where each of the two its specified begin and 25 | end vertex of a cylinder. radii can either come from a separate 26 | array (if provided), or, i not, use a common radius specified in 27 | this geometry */ 28 | struct Cylinders : public Geometry { 29 | typedef std::shared_ptr SP; 30 | 31 | struct DD : public Geometry::DD { 32 | const vec3f *vertices; 33 | // const vec3f *colors; 34 | const vec2i *indices; 35 | const float *radii; 36 | // int colorPerVertex; 37 | }; 38 | 39 | Cylinders(Context *context, DevGroup::SP devices); 40 | virtual ~Cylinders() = default; 41 | 42 | /*! pretty-printer for printf-debugging */ 43 | std::string toString() const override 44 | { return "Cylinders{}"; } 45 | 46 | void commit() override; 47 | 48 | // ------------------------------------------------------------------ 49 | /*! @{ parameter set/commit interface */ 50 | bool set1i(const std::string &member, const int &value) override; 51 | bool set1f(const std::string &member, const float &value) override; 52 | bool setData(const std::string &member, const barney_api::Data::SP &value) override; 53 | bool setObject(const std::string &member, const Object::SP &value) override; 54 | /*! @} */ 55 | // ------------------------------------------------------------------ 56 | 57 | PODData::SP vertices; 58 | PODData::SP indices; 59 | PODData::SP radii; 60 | }; 61 | 62 | } 63 | -------------------------------------------------------------------------------- /barney/geometry/Spheres.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/geometry/Geometry.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | struct Spheres : public Geometry { 24 | typedef std::shared_ptr SP; 25 | 26 | struct DD : public Geometry::DD { 27 | vec3f *origins; 28 | float *radii; 29 | vec3f *colors; 30 | float defaultRadius; 31 | // const vec4f *vertexAttribute[5]; 32 | }; 33 | 34 | Spheres(Context *context, DevGroup::SP devices); 35 | 36 | /*! pretty-printer for printf-debugging */ 37 | std::string toString() const override 38 | { return "Spheres{}"; } 39 | 40 | void commit() override; 41 | 42 | // ------------------------------------------------------------------ 43 | /*! @{ parameter set/commit interface */ 44 | bool set1f(const std::string &member, const float &value) override; 45 | bool setData(const std::string &member, const barney_api::Data::SP &value) override; 46 | bool setObject(const std::string &member, const Object::SP &value) override; 47 | /*! @} */ 48 | // ------------------------------------------------------------------ 49 | 50 | PODData::SP origins = 0; 51 | PODData::SP colors = 0; 52 | PODData::SP radii = 0; 53 | float defaultRadius = .1f; 54 | }; 55 | 56 | } 57 | 58 | -------------------------------------------------------------------------------- /barney/geometry/Triangles.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/geometry/Geometry.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | struct ModelSlot; 24 | 25 | 26 | // ================================================================== 27 | /*! Scalar field made of 3D structured data, constting of Nx*Ny*Nz 28 | scalars. 29 | 30 | Supported settable fields: 31 | 32 | - "vertices" (BNData) 33 | - "indices" (BNData) 34 | - "normals" (BNData) 35 | - "texcoords" (BNData) 36 | */ 37 | struct Triangles : public Geometry { 38 | typedef std::shared_ptr SP; 39 | 40 | struct DD : public Geometry::DD { 41 | const vec3i *indices; 42 | const vec3f *vertices; 43 | const vec3f *normals; 44 | const vec2f *texcoords; 45 | // const vec4f *vertexAttribute[5]; 46 | }; 47 | 48 | Triangles(Context *context, DevGroup::SP devices); 49 | virtual ~Triangles(); 50 | 51 | /*! pretty-printer for printf-debugging */ 52 | std::string toString() const override 53 | { return "Triangles{}"; } 54 | 55 | // ------------------------------------------------------------------ 56 | /*! @{ parameter set/commit interface */ 57 | void commit() override; 58 | bool setData(const std::string &member, 59 | const barney_api::Data::SP &value) override; 60 | /*! @} */ 61 | // ------------------------------------------------------------------ 62 | 63 | PODData::SP vertices; 64 | PODData::SP indices; 65 | PODData::SP normals; 66 | // TODO: do we still need this in times of ANARI? 67 | PODData::SP texcoords; 68 | }; 69 | 70 | } 71 | -------------------------------------------------------------------------------- /barney/include/barney_mpi.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney.h" 20 | #include 21 | 22 | BARNEY_API 23 | BNContext bnMPIContextCreate(MPI_Comm comm, 24 | /*! how many data slots this context is to 25 | offer, and which part(s) of the 26 | distributed model data these slot(s) 27 | will hold */ 28 | const int *dataRanksOnThisContext=0, 29 | int numDataRanksOnThisContext=1, 30 | /*! which gpu(s) to use for this 31 | process. default is to distribute 32 | node's GPUs equally over all ranks on 33 | that given node */ 34 | const int *gpuIDs=nullptr, 35 | int numGPUs=-1 36 | ); 37 | 38 | BARNEY_API 39 | void bnMPIQueryHardware(BNHardwareInfo *hardware, MPI_Comm comm); 40 | 41 | -------------------------------------------------------------------------------- /barney/kernels/traceRays.dev.cu: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "barney/render/OptixGlobals.h" 18 | #include "barney/Context.h" 19 | #include "barney/GlobalModel.h" 20 | #include "barney/ModelSlot.h" 21 | #include "barney/render/SamplerRegistry.h" 22 | #include "barney/render/MaterialRegistry.h" 23 | #include "rtcore/TraceInterface.h" 24 | 25 | RTC_DECLARE_GLOBALS(BARNEY_NS::render::OptixGlobals); 26 | 27 | namespace BARNEY_NS { 28 | namespace render { 29 | 30 | struct TraceRays { 31 | #if RTC_DEVICE_CODE 32 | inline __rtc_device static 33 | void run(rtc::TraceInterface &ti); 34 | #endif 35 | }; 36 | 37 | #if RTC_DEVICE_CODE 38 | inline __rtc_device 39 | void TraceRays::run(rtc::TraceInterface &ti) 40 | { 41 | const int rayID 42 | = ti.getLaunchIndex().x 43 | + ti.getLaunchDims().x 44 | * ti.getLaunchIndex().y; 45 | 46 | auto &lp = OptixGlobals::get(ti); 47 | 48 | if (rayID >= lp.numRays) 49 | return; 50 | 51 | Ray &ray = lp.rays[rayID]; 52 | 53 | vec3f dir = ray.dir; 54 | if (dir.x == 0.f) dir.x = 1e-6f; 55 | if (dir.y == 0.f) dir.y = 1e-6f; 56 | if (dir.z == 0.f) dir.z = 1e-6f; 57 | 58 | ti.traceRay(lp.accel, 59 | ray.org, 60 | dir, 61 | 0.f, 62 | ray.tMax, 63 | /* PRD */ 64 | (void *)&ray); 65 | } 66 | #endif 67 | 68 | } 69 | 70 | RTC_EXPORT_TRACE2D(traceRays,render::TraceRays); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /barney/light/DirLight.cu: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "DirLight.h" 18 | #include "barney/common/math.h" 19 | 20 | namespace BARNEY_NS { 21 | 22 | DirLight::DD DirLight::getDD(const affine3f &instanceXfm) const 23 | { 24 | DD dd; 25 | dd.direction = normalize(xfmVector(instanceXfm,direction)); 26 | dd.color = color; 27 | dd.radiance 28 | = isnan(irradiance) 29 | ? radiance 30 | : irradiance; 31 | return dd; 32 | } 33 | 34 | bool DirLight::set1f(const std::string &member, const float &value) 35 | { 36 | if (Light::set1f(member,value)) 37 | return true; 38 | 39 | if (member == "irradiance") { 40 | irradiance = value; 41 | return true; 42 | } 43 | if (member == "radiance") { 44 | radiance = value; 45 | return true; 46 | } 47 | return false; 48 | } 49 | 50 | bool DirLight::set3f(const std::string &member, const vec3f &value) 51 | { 52 | if (Light::set3f(member,value)) 53 | return true; 54 | 55 | if (member == "direction") { 56 | direction = value; 57 | return true; 58 | } 59 | if (member == "radiance") { 60 | /* if - this is _not_ ANARI spec */ 61 | std::cout << "#barney: WARNING - using float3 values for light (ir)radiance is deprecated" << std::endl; 62 | radiance = reduce_max(value); 63 | color = value/radiance;; 64 | return true; 65 | } 66 | if (member == "irradiance") { 67 | /* if - this is _not_ ANARI spec */ 68 | std::cout << "#barney: WARNING - using float3 values for light (ir)radiance is deprecated" << std::endl; 69 | irradiance = reduce_max(value); 70 | color = value/irradiance; 71 | return true; 72 | } 73 | return false; 74 | } 75 | 76 | } 77 | 78 | -------------------------------------------------------------------------------- /barney/light/DirLight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/light/Light.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | struct DirLight : public Light { 24 | struct DD { 25 | vec3f direction; 26 | float radiance; 27 | vec3f color; 28 | }; 29 | 30 | typedef std::shared_ptr SP; 31 | DirLight(Context *context, 32 | const DevGroup::SP &devices) 33 | : Light(context,devices) 34 | {} 35 | 36 | DD getDD(const affine3f &instanceXfm) const; 37 | 38 | std::string toString() const override { return "DirLight"; } 39 | 40 | // ------------------------------------------------------------------ 41 | /*! @{ parameter set/commit interface */ 42 | bool set1f(const std::string &member, const float &value) override; 43 | bool set3f(const std::string &member, const vec3f &value) override; 44 | /*! @} */ 45 | // ------------------------------------------------------------------ 46 | 47 | /*! SPEC: main emission direction of the directional light */ 48 | vec3f direction{0.f, 0.f, -1.f}; 49 | 50 | /*! SPEC: the amount of light arriving at a surface point, 51 | assuming the light is oriented towards to the surface, in 52 | W/m2 */ 53 | float irradiance = NAN; 54 | /*! the amount of light emitted in a direction, in W/sr/m2; 55 | irradiance takes precedence if also specified */ 56 | float radiance = 1.f; 57 | }; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /barney/light/Light.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "barney/light/Light.h" 18 | #include "barney/ModelSlot.h" 19 | #include "barney/Context.h" 20 | 21 | #include "barney/light/QuadLight.h" 22 | #include "barney/light/DirLight.h" 23 | #include "barney/light/EnvMap.h" 24 | 25 | namespace BARNEY_NS { 26 | 27 | Light::Light(Context *context, 28 | const DevGroup::SP &devices) 29 | : barney_api::Light(context), 30 | devices(devices) 31 | {} 32 | 33 | Light::SP Light::create(Context *context, 34 | const DevGroup::SP &devices, 35 | const std::string &type) 36 | { 37 | if (type == "directional") 38 | return std::make_shared(context,devices); 39 | if (type == "quad") 40 | return std::make_shared(context,devices); 41 | if (type == "envmap") 42 | return std::make_shared(context,devices); 43 | 44 | context->warn_unsupported_object("Light",type); 45 | return {}; 46 | } 47 | 48 | // ================================================================== 49 | bool Light::set3f(const std::string &member, const vec3f &value) 50 | { 51 | if (member == "color") { 52 | color = value; 53 | return true; 54 | } 55 | return false; 56 | } 57 | 58 | // ================================================================== 59 | 60 | // ================================================================== 61 | 62 | } 63 | -------------------------------------------------------------------------------- /barney/light/Light.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/Object.h" 20 | #include "barney/common/Data.h" 21 | #include "barney/common/Texture.h" 22 | 23 | namespace BARNEY_NS { 24 | 25 | struct ModelSlot; 26 | 27 | struct Light : public barney_api::Light { 28 | typedef std::shared_ptr SP; 29 | 30 | struct DD { 31 | vec3f color; 32 | }; 33 | 34 | /*! what we return, during rendering, when we sample a light 35 | source */ 36 | struct Sample { 37 | /* direction _to_ light */ 38 | vec3f direction; 39 | /*! radiance coming _from_ dir */ 40 | vec3f radiance; 41 | /*! distance to this light sample */ 42 | float distance; 43 | /*! pdf of sample that was chosen */ 44 | float pdf = 0.f; 45 | }; 46 | 47 | 48 | Light(Context *context, const DevGroup::SP &devices); 49 | 50 | std::string toString() const override { return "Light<>"; } 51 | 52 | // ------------------------------------------------------------------ 53 | /*! @{ parameter set/commit interface */ 54 | // bool set1f(const std::string &member, const float &value) override; 55 | bool set3f(const std::string &member, const vec3f &value) override; 56 | /*! @} */ 57 | // ------------------------------------------------------------------ 58 | 59 | static Light::SP create(Context *context, 60 | const DevGroup::SP &devices, 61 | const std::string &name); 62 | 63 | vec3f color = vec3f(1.f); 64 | DevGroup::SP const devices; 65 | }; 66 | 67 | }; 68 | -------------------------------------------------------------------------------- /barney/light/PointLight.cu: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "PointLight.h" 18 | 19 | namespace BARNEY_NS { 20 | 21 | PointLight::DD PointLight::getDD(const affine3f &instanceXfm) const 22 | { 23 | DD dd; 24 | dd.position = xfmVector(instanceXfm,position); 25 | dd.power = power; 26 | dd.intensity = intensity; 27 | dd.color = color; 28 | return dd; 29 | } 30 | 31 | bool PointLight::set1f(const std::string &member, const float &value) 32 | { 33 | if (Light::set1f(member,value)) 34 | return true; 35 | if (member == "power") { 36 | power = value; 37 | return true; 38 | } 39 | if (member == "intensity") { 40 | intensity = value; 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | bool PointLight::set3f(const std::string &member, const vec3f &value) 47 | { 48 | if (Light::set3f(member,value)) 49 | return true; 50 | if (member == "position") { 51 | position = value; 52 | return true; 53 | } 54 | return false; 55 | } 56 | 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /barney/light/PointLight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/light/Light.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | struct PointLight : public Light { 24 | struct DD : public Light::DD { 25 | vec3f position; 26 | float intensity; 27 | float power; 28 | }; 29 | 30 | typedef std::shared_ptr SP; 31 | PointLight(Context *context, 32 | const DevGroup::SP &devices) 33 | : Light(context,devices) 34 | {} 35 | 36 | DD getDD(const affine3f &instanceXfm) const; 37 | 38 | std::string toString() const override { return "PointLight"; } 39 | 40 | // ------------------------------------------------------------------ 41 | /*! @{ parameter set/commit interface */ 42 | bool set1f(const std::string &member, const float &value) override; 43 | bool set3f(const std::string &member, const vec3f &value) override; 44 | /*! @} */ 45 | // ------------------------------------------------------------------ 46 | 47 | vec3f position = vec3f(0.f,0.f,0.f); 48 | float power = 1.f; 49 | float intensity = NAN; 50 | }; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /barney/light/QuadLight.cu: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "QuadLight.h" 18 | 19 | namespace BARNEY_NS { 20 | 21 | QuadLight::DD QuadLight::getDD(const affine3f &instanceXfm) const 22 | { 23 | DD dd; 24 | dd.corner = xfmPoint(instanceXfm,staged.corner); 25 | dd.edge0 = xfmVector(instanceXfm,staged.edge0); 26 | dd.edge1 = xfmVector(instanceXfm,staged.edge1); 27 | dd.emission = staged.emission; 28 | dd.area = length(cross(dd.edge0,dd.edge1)); 29 | return dd; 30 | } 31 | 32 | bool QuadLight::set3f(const std::string &member, const vec3f &value) 33 | { 34 | if (member == "corner") { 35 | staged.corner = value; 36 | return true; 37 | } 38 | if (member == "edge0") { 39 | staged.edge0 = value; 40 | return true; 41 | } 42 | if (member == "edge1") { 43 | staged.edge1 = value; 44 | return true; 45 | } 46 | if (member == "emission") { 47 | staged.emission = value; 48 | return true; 49 | } 50 | return false; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /barney/light/QuadLight.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/light/Light.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | struct QuadLight : public Light { 24 | struct DD { 25 | vec3f corner{0.f,0.f,0.f}; 26 | vec3f edge0{1.f,0.f,0.f}; 27 | vec3f edge1{0.f,1.f,0.f}; 28 | vec3f emission{1.f,1.f,1.f}; 29 | /*! normal of this lights source; this could obviously be derived 30 | from cross(edge0,edge1), but is handle to have in a 31 | renderer */ 32 | vec3f normal; 33 | /*! area of this lights source; this could obviously be derived 34 | from cross(edge0,edge1), but is handle to have in a 35 | renderer */ 36 | float area; 37 | }; 38 | 39 | typedef std::shared_ptr SP; 40 | QuadLight(Context *context, 41 | const DevGroup::SP &devices) 42 | : Light(context,devices) 43 | {} 44 | 45 | DD getDD(const affine3f &instanceXfm) const; 46 | 47 | std::string toString() const override { return "QuadLight"; } 48 | 49 | // ------------------------------------------------------------------ 50 | /*! @{ parameter set/commit interface */ 51 | bool set3f(const std::string &member, const vec3f &value) override; 52 | /*! @} */ 53 | // ------------------------------------------------------------------ 54 | 55 | DD staged; 56 | }; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /barney/render/GeometryAttributes.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "barney/render/GeometryAttributes.h" 18 | 19 | namespace BARNEY_NS { 20 | namespace render { 21 | 22 | GeometryAttributes::DD GeometryAttributes::getDD(Device *device) 23 | { 24 | GeometryAttributes::DD attributes; 25 | auto set = [&](GeometryAttribute::DD &out, 26 | const GeometryAttribute &in, 27 | const std::string &dbgName) 28 | { 29 | if (in.perVertex) { 30 | out.scope = GeometryAttribute::PER_VERTEX; 31 | out.fromArray.type = in.perVertex->type; 32 | out.fromArray.ptr 33 | = in.perVertex->getDD(device); 34 | out.fromArray.size = (int)in.perVertex->count; 35 | } else if (in.perPrim) { 36 | out.scope = GeometryAttribute::PER_PRIM; 37 | out.fromArray.type = in.perPrim->type; 38 | out.fromArray.ptr 39 | = in.perPrim->getDD(device); 40 | out.fromArray.size = (int)in.perPrim->count; 41 | } else if (isnan(in.constant[0])) { 42 | out.scope = GeometryAttribute::INVALID; 43 | } else { 44 | out.scope = GeometryAttribute::CONSTANT; 45 | (vec4f&)out.value = in.constant; 46 | } 47 | }; 48 | 49 | for (int i=0;iattribute[i]; 52 | set(out,in,"attr"+std::to_string(i)); 53 | } 54 | set(attributes.colorAttribute, 55 | this->colorAttribute,"color"); 56 | return attributes; 57 | } 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /barney/render/HitIDs.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/common/math.h" 20 | 21 | namespace BARNEY_NS { 22 | 23 | /*! HitIDs are used for a special "ID pass" that computes the 24 | closest intersection along a (primary) ray, WITHOUT any opacity 25 | or transparency taken into effect. As such it requires its own 26 | depth value */ 27 | struct HitIDs { 28 | float depth = BARNEY_INF; 29 | int primID = -1; 30 | int instID = -1; 31 | int objID = -1; 32 | }; 33 | 34 | } // ::BARNEY_NS 35 | -------------------------------------------------------------------------------- /barney/render/MaterialInputs.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/render/device/HitAttributes.h" 20 | 21 | namespace BARNEY_NS { 22 | namespace render { 23 | namespace device { 24 | 25 | xxxx 26 | 27 | struct MaterialInput { 28 | typedef enum { VALUE, ATTRIBUTE, SAMPLER, UNDEFINED } Type; 29 | 30 | inline __rtc_device 31 | float4 eval(const HitAttributes &hitData) const; 32 | 33 | Type type; 34 | union { 35 | float4 value; 36 | HitAttributes::Which attribute; 37 | int samplerID; 38 | }; 39 | }; 40 | 41 | inline __rtc_device 42 | float4 MaterialInput::eval(const HitAttributes &hitData, 43 | Sampler::DD *samplers) const 44 | { 45 | if (type == VALUE) 46 | return value; 47 | if (type == ATTRIBUTE) 48 | return hitData.get(attribute); 49 | if (type == SAMPLER) { 50 | if (samplerID < 0) return make_float4(0.f,0.f,0.f,1.f); 51 | return samplers[samplerID].eval(hitData); 52 | } 53 | printf("un-handled material input type\n"); 54 | return make_float4(0.f,0.f,0.f,1.f); 55 | } 56 | 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /barney/render/MaterialRegistry.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/DeviceGroup.h" 20 | // #include "barney/material/Globals.h" 21 | // #include "barney/render/DeviceMaterial.h" 22 | #include "barney/render/Sampler.h" 23 | 24 | namespace BARNEY_NS { 25 | namespace render { 26 | 27 | struct DeviceMaterial; 28 | 29 | struct MaterialRegistry { 30 | typedef std::shared_ptr SP; 31 | 32 | MaterialRegistry(const DevGroup::SP &devices); 33 | virtual ~MaterialRegistry(); 34 | 35 | int allocate(); 36 | void release(int nowReusableID); 37 | void grow(); 38 | 39 | void setMaterial(int materialID, 40 | const DeviceMaterial &dd, 41 | Device *device); 42 | // const DeviceMaterial *getPointer(int owlDeviceID) const; 43 | 44 | int numReserved = 0; 45 | int nextFree = 0; 46 | 47 | std::stack reusableIDs; 48 | // OWLBuffer buffer = 0; 49 | 50 | DeviceMaterial *getDD(Device *device) 51 | { return (DeviceMaterial *)getPLD(device)->buffer->getDD(); } 52 | 53 | struct PLD { 54 | rtc::Buffer *buffer = 0; 55 | // Device *device; 56 | }; 57 | PLD *getPLD(Device *device); 58 | std::vector perLogical; 59 | 60 | DevGroup::SP const devices; 61 | }; 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /barney/render/OptixGlobals.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/material/DeviceMaterial.h" 20 | #include "barney/render/Sampler.h" 21 | #include "barney/render/HitAttributes.h" 22 | // #if RTC_DEVICE_CODE 23 | #if BARNEY_DEVICE_PROGRAM 24 | # include "rtcore/TraceInterface.h" 25 | #endif 26 | #include "barney/render/World.h" 27 | #include "barney/render/HitIDs.h" 28 | 29 | namespace BARNEY_NS { 30 | namespace render { 31 | 32 | /*! defines all constant global launch parameter data. The struct 33 | type itself is also defined on the host (so its contents can 34 | be marshalled there, but the 'get()' method can only be 35 | available in device programs */ 36 | struct OptixGlobals { 37 | #if BARNEY_DEVICE_PROGRAM 38 | // #if RTC_DEVICE_CODE 39 | static inline __rtc_device 40 | const OptixGlobals &get(const rtc::TraceInterface &dev); 41 | #endif 42 | 43 | /*! the current ray queue for the traceRays() kernel */ 44 | Ray *rays; 45 | /*! info for primid/geomid/instid info; may be null if not required */ 46 | HitIDs *hitIDs; 47 | 48 | /*! number of ryas in the queue */ 49 | int numRays; 50 | 51 | /*! this device's world to trace rays into */ 52 | rtc::AccelHandle accel; 53 | World::DD world; 54 | }; 55 | } 56 | } 57 | 58 | namespace BARNEY_NS { 59 | namespace render { 60 | 61 | // #if RTC_DEVICE_CODE 62 | #if BARNEY_DEVICE_PROGRAM 63 | inline __rtc_device 64 | const OptixGlobals &OptixGlobals::get(const rtc::TraceInterface &ti) 65 | { 66 | return *(OptixGlobals*)ti.getLPData(); 67 | } 68 | #endif 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /barney/render/SamplerRegistry.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "barney/DeviceGroup.h" 20 | #include "barney/render/Sampler.h" 21 | 22 | namespace BARNEY_NS { 23 | struct ModelSlot; 24 | 25 | namespace render { 26 | 27 | struct SamplerRegistry { 28 | typedef std::shared_ptr SP; 29 | 30 | SamplerRegistry(const DevGroup::SP &devices); 31 | virtual ~SamplerRegistry(); 32 | 33 | int allocate(); 34 | void release(int nowReusableID); 35 | void grow(); 36 | 37 | void setDD(int samplerID, const Sampler::DD &, Device *device); 38 | 39 | Sampler::DD *getDD(Device *device) 40 | { return (Sampler::DD *)getPLD(device)->memory; } 41 | 42 | int numReserved = 0; 43 | int nextFree = 0; 44 | std::stack reusableIDs; 45 | 46 | struct PLD { 47 | Sampler::DD *memory = 0; 48 | }; 49 | PLD *getPLD(Device *); 50 | std::vector perLogical; 51 | 52 | DevGroup::SP const devices; 53 | }; 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /barney/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # THIS SCRIPT ASSUMES VARIOUS PRE-BUILT APPLICATIONS AND LIBRARIES 4 | # THAT USE BARNEY; IF YOU DON'T HAVE THOSE (OR NOT IN THE PROPER 5 | # DIRECTORIES) THIS SCRIPT WON'T DO YOU MUCH GOOD. USE AT YOUR 6 | # OWN RISK 7 | 8 | out=/tmp/barney-test 9 | hs=$HOME/Projects/hayStack/bin/hsOffline 10 | mini=$HOME/mini/ 11 | 12 | python=/usr/bin/python3 13 | pynari=$HOME/Projects/pynari 14 | 15 | mkdir $out 16 | 17 | 18 | make -j 8 -C ~/Projects/hayStack/bin/ 19 | make -j 8 -C ~/Projects/barney/bin/ install 20 | make -j 8 -C ~/Projects/pynari/bin 21 | 22 | # landscape, path view 23 | $hs $mini/ls.mini -os 2460 1080 -spp 16 -o $out/ls-path.png --camera -2976.901123 309.4327087 -3735.08252 1474.776611 1074.60376 4633.866699 0 1 0 -fovy 70 24 | 25 | # landscape, top 26 | $hs $mini/ls.mini -os 2460 1080 -spp 16 -o $out/ls-top.png --camera -1993.13 3033.55 -2069.94 -375.562 -599.161 1070.11 0 1 0 -fovy 70 27 | 28 | # magnetic 29 | $hs -os 1600 1200 -o $out/magnetic.png -spp 16 raw:///home/wald/models/structured/magnetic-512-volume.raw:format=float:dims=512,512,512 -xf ~/models/structured/magnetic-512-volume.xf --camera 78.808 713.978 453.142 263.274 319.72 176.829 0 0 1 -fovy 60 30 | 31 | # jets 32 | $hs -os 1024 1024 -o $out/jets.png -spp 16 ~/models/umesh/jets.umesh -xf ~/models/umesh/jets.xf --camera 94.0945 39.217 -0.826244 44.6431 58.8093 54.9847 1 0 0 -fovy 60 33 | $hs -os 1024 1024 -o $out/anari-jets.png -spp 16 ~/models/umesh/jets.umesh -xf ~/models/umesh/jets.xf --camera 94.0945 39.217 -0.826244 44.6431 58.8093 54.9847 1 0 0 -fovy 60 -anari 34 | 35 | 36 | # ================================================================== 37 | # different env-lighting tests on suzy model 38 | # ================================================================== 39 | cam="--camera -0.528471 0.478023 2.93096 0 -0.00871944 0.00860333 0 1 0 -fovy 60" 40 | for f in quarry-cloudy symm-garden empty-room; do 41 | $hs -o $out/suzy-$f".png" $mini/suzy-$f".mini" $cam -spp 16 -os 1024 1024 42 | done 43 | 44 | 45 | 46 | # ================================================================== 47 | # pynari tests 48 | # ================================================================== 49 | 50 | PYTHONPATH=$pynari/bin ANARI_LIBRARY=barney $python $pynari/sample01.py -o $out/pynari01.png 51 | PYTHONPATH=$pynari/bin ANARI_LIBRARY=barney $python $pynari/sample02.py -o $out/pynari02.png 52 | PYTHONPATH=$pynari/bin ANARI_LIBRARY=barney $python $pynari/sample03.py -o $out/pynari03.png 53 | PYTHONPATH=$pynari/bin ANARI_LIBRARY=barney $python $pynari/sample04.py -o $out/pynari04.png 54 | 55 | 56 | -------------------------------------------------------------------------------- /barney/umesh/mc/UMeshMC.dev.cu: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2024 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | /*! \file UMeshMC.dev.cu implements a macro-cell accelerated 18 | unstructured mesh data type. 19 | 20 | This particular voluem type: 21 | 22 | - uses cubql to accelerate point-in-element queries (for the 23 | scalar field evaluation) 24 | 25 | - uses macro cells and DDA traversal for domain traversal 26 | */ 27 | 28 | #include "barney/umesh/mc/UMeshCUBQLSampler.h" 29 | #include "barney/volume/DDA.h" 30 | #include "rtcore/TraceInterface.h" 31 | 32 | RTC_DECLARE_GLOBALS(BARNEY_NS::render::OptixGlobals); 33 | 34 | namespace BARNEY_NS { 35 | 36 | struct UMeshMC_Programs { 37 | 38 | static inline __rtc_device 39 | void bounds(const rtc::TraceInterface &ti, 40 | const void *geomData, 41 | owl::common::box3f &bounds, 42 | const int32_t primID) 43 | { 44 | #if RTC_DEVICE_CODE 45 | MCVolumeAccel::boundsProg(ti,geomData,bounds,primID); 46 | #endif 47 | } 48 | 49 | static inline __rtc_device 50 | void intersect(rtc::TraceInterface &ti) 51 | { 52 | #if RTC_DEVICE_CODE 53 | MCVolumeAccel::isProg(ti); 54 | #endif 55 | } 56 | 57 | static inline __rtc_device 58 | void closestHit(rtc::TraceInterface &ti) 59 | { /* nothing to do */ } 60 | 61 | static inline __rtc_device 62 | void anyHit(rtc::TraceInterface &ti) 63 | { /* nothing to do */ } 64 | }; 65 | 66 | using UMeshMC = MCVolumeAccel; 67 | 68 | RTC_EXPORT_USER_GEOM(UMeshMC,UMeshMC::DD,UMeshMC_Programs,false,false); 69 | } 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /barney/volume/ScalarField.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "barney/volume/Volume.h" 18 | #include "barney/volume/ScalarField.h" 19 | #include "barney/ModelSlot.h" 20 | #include "barney/Context.h" 21 | #include "barney/volume/StructuredData.h" 22 | #include "barney/umesh/common/UMeshField.h" 23 | #include "barney/amr/BlockStructuredField.h" 24 | 25 | namespace BARNEY_NS { 26 | 27 | void ScalarField::buildMCs(MCGrid ¯oCells) 28 | { 29 | throw std::runtime_error 30 | ("this calar field type does not know how to build macro-cells"); 31 | } 32 | 33 | ScalarField::ScalarField(Context *context, 34 | const DevGroup::SP &devices, 35 | const box3f &domain) 36 | : barney_api::ScalarField(context), 37 | devices(devices), 38 | domain(domain) 39 | {} 40 | 41 | ScalarField::SP ScalarField::create(Context *context, 42 | const DevGroup::SP &devices, 43 | const std::string &type) 44 | { 45 | if (type == "structured") 46 | return std::make_shared(context,devices); 47 | if (type == "unstructured") 48 | return std::make_shared(context,devices); 49 | if (type == "BlockStructuredAMR") 50 | return std::make_shared(context,devices); 51 | 52 | context->warn_unsupported_object("ScalarField",type); 53 | return {}; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /barney/volume/StructuredData.dev.cu: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "barney/volume/StructuredData.h" 18 | #include "barney/volume/MCAccelerator.h" 19 | #include "rtcore/TraceInterface.h" 20 | 21 | RTC_DECLARE_GLOBALS(BARNEY_NS::render::OptixGlobals); 22 | 23 | namespace BARNEY_NS { 24 | 25 | struct MCAccel_Structured_Programs { 26 | static inline __rtc_device 27 | void bounds(const rtc::TraceInterface &ti, 28 | const void *geomData, 29 | owl::common::box3f &bounds, 30 | const int32_t primID) 31 | { 32 | #if RTC_DEVICE_CODE 33 | MCVolumeAccel 34 | ::boundsProg(ti,geomData,bounds,primID); 35 | #endif 36 | } 37 | 38 | static inline __rtc_device 39 | void intersect(rtc::TraceInterface &ti) 40 | { 41 | #if RTC_DEVICE_CODE 42 | MCVolumeAccel 43 | ::isProg(ti); 44 | #endif 45 | } 46 | 47 | static inline __rtc_device 48 | void closestHit(rtc::TraceInterface &ti) 49 | { /* nothing to do */ } 50 | 51 | static inline __rtc_device 52 | void anyHit(rtc::TraceInterface &ti) 53 | { /* nothing to do */ } 54 | }; 55 | 56 | 57 | RTC_EXPORT_USER_GEOM(StructuredMC, 58 | typename MCVolumeAccel::DD, 59 | MCAccel_Structured_Programs,false,false); 60 | } 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /doc/ANARI.md: -------------------------------------------------------------------------------- 1 | # Barney ANARI API Layer: Supported Entities and Parameters 2 | 3 | Barney can be driven using two different APIs: ANARI, or Barney 4 | Native. While barney native is not ANARI compliant (and may or may not 5 | offer features not exposed through ANARI), the ANARI API layer 6 | basically follows the ANARI API Spec (see 7 | https://registry.khronos.org/ANARI/specs/1.0/ANARI-1.0.html). 8 | 9 | 10 | 11 | ## Non-Subtyped Objects 12 | 13 | ### `Frame` (`anariNewFrame()`) 14 | 15 | - `int1 enableDenoising` : If set to 0, denoising will be skipped even 16 | if support for denoising is enabled during build, and offered by the 17 | chosen rtc backend. Any other value will turn denoising on 18 | (conditional upon the chosen backend offering it in the first place) 19 | 20 | ## Lights (`bnLightCreate()`) 21 | 22 | ### Environment Map/HDRI Light (`hdri`) 23 | 24 | - `float scale = 1.f` : Scale factor applied to the value read from 25 | the `radiance[]` array. 26 | - `float3 direction = (1,0,0)` : Direction that the env map should be 27 | oriented towards. This effectively 'rotates' the env-map around the 28 | `up` vector until direction points to the vertical center line of 29 | the env-map. If orthogonal to up direction will point to exactly the 30 | center pixel. 31 | - `float3 up = (0,0,1)`: Specifies the logical (world-space) up vector 32 | for the specified environment map. Will point to the (top) pole of 33 | the sphere of directions. 34 | - `float3 radiance [][]`: 2D Array of radiance values. The 35 | `radiance[0][0]` value will appear in the *lower left* of the map. 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/BarneyNative.md: -------------------------------------------------------------------------------- 1 | # Barney Native API: Supported Entities and Parameters 2 | 3 | Barney can be driven using two different APIs: ANARI, or Barney 4 | Native. Both of those work primarily by creating certain 'actors' 5 | (like Geometries, Volumes, Lights, Frame Buffers, etc) that the user 6 | can 'parameterize' using certain `bnSetXyz()` calls to set their 7 | internal state (e.g., setting the radiance and direction of a 8 | directional light source). 9 | 10 | 11 | 12 | ## Non-Subtyped Objects 13 | 14 | ### `FrameBuffer` (`bnFrameBufferCreate()`) 15 | 16 | - `int1 enableDenoising` : If set to 0, denoising will be skipped even 17 | if support for denoising is enabled during build, and offered by the 18 | chosen rtc backend. Any other value will turn denoising on 19 | (conditional upon the chosen backend offering it in the first place) 20 | 21 | ## Lights (`bnLightCreate()`) 22 | 23 | ### Environment Map Light (`envmap`) 24 | 25 | - `float scale = 1.f` : Scale factor applied to the value read from 26 | the `radiance[]` array. 27 | - `float3 direction = (1,0,0)` : Direction that the env map should be 28 | oriented towards. This effectively 'rotates' the env-map around the 29 | `up` vector until direction points to the vertical center line of 30 | the env-map. If orthogonal to up direction will point to exactly the 31 | center pixel. 32 | - `float3 up = (0,0,1)`: Specifies the logical (world-space) up vector 33 | for the specified environment map. Will point to the (top) pole of 34 | the sphere of directions. 35 | - `Texture texture`: A (2D) Texture Object that specifies the texture 36 | that is wrapped around the environment map. Texel(0,0) is will appear 37 | in the *lower left* of the map. 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /jpg/dns-isosurface-2b-triangles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/dns-isosurface-2b-triangles.jpg -------------------------------------------------------------------------------- /jpg/engine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/engine.jpg -------------------------------------------------------------------------------- /jpg/jets.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/jets.jpg -------------------------------------------------------------------------------- /jpg/ls-collage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/ls-collage.jpg -------------------------------------------------------------------------------- /jpg/ls-pond.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/ls-pond.jpg -------------------------------------------------------------------------------- /jpg/ls.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/ls.jpg -------------------------------------------------------------------------------- /jpg/make_collages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | convert -resize x500! ls.jpg -resize x500! ls-pond.jpg -resize x500! +append ls-collage.jpg 3 | 4 | 5 | convert -resize x500 engine.jpg -resize x500 rotstrat-fuzzy.jpg -resize x500 rotstrat-dense.jpg -resize x500 +append structured-collage.jpg 6 | -------------------------------------------------------------------------------- /jpg/rotstrat-dense.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/rotstrat-dense.jpg -------------------------------------------------------------------------------- /jpg/rotstrat-fuzzy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/rotstrat-fuzzy.jpg -------------------------------------------------------------------------------- /jpg/structured-collage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/jpg/structured-collage.jpg -------------------------------------------------------------------------------- /rtcore/AppInterface.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | /*! \file rtcore/AppInterface.h Defines how the app/host side of 18 | barney can talk to rtcore; e.g., to create new groups, geometries, 19 | etc */ 20 | 21 | #pragma once 22 | 23 | #if BARNEY_RTC_CUDA 24 | # include "cuda/AppInterface.h" 25 | namespace rtc { using namespace rtc::cuda; } 26 | #endif 27 | 28 | #if BARNEY_RTC_OPTIX 29 | # include "optix/AppInterface.h" 30 | namespace rtc { using namespace rtc::optix; } 31 | #endif 32 | 33 | #if BARNEY_RTC_EMBREE 34 | # include "embree/AppInterface.h" 35 | namespace rtc { using namespace rtc::embree; } 36 | #endif 37 | -------------------------------------------------------------------------------- /rtcore/ComputeInterface.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | /* kernelInterface - how device-side compute kernels (e.g., shadeRays, 18 | but not programs like intersect or anyhit) can talk to rtcore */ 19 | 20 | #pragma once 21 | 22 | #if BARNEY_RTC_CUDA 23 | # include "cuda/ComputeInterface.h" 24 | namespace rtc { using namespace rtc::cuda; } 25 | #endif 26 | 27 | #if BARNEY_RTC_OPTIX 28 | # include "optix/ComputeInterface.h" 29 | namespace rtc { using namespace rtc::optix; } 30 | #endif 31 | 32 | #if BARNEY_RTC_EMBREE 33 | # include "embree/ComputeInterface.h" 34 | namespace rtc { using namespace rtc::embree; } 35 | #endif 36 | -------------------------------------------------------------------------------- /rtcore/TraceInterface.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | /*! \file rtcore/TraceInterface.h \brief Defines the interface with 18 | which pipeline/device programs (closest hit, anythit, etc) can 19 | talk to to the ray tracing pipeline (eg, to ask for primitive ID, 20 | call ignoreIntersction(), etc */ 21 | 22 | #pragma once 23 | 24 | #if BARNEY_RTC_OPTIX 25 | # include "rtcore/optix/TraceInterface.h" 26 | #endif 27 | 28 | #if BARNEY_RTC_EMBREE 29 | # include "rtcore/embree/TraceInterface.h" 30 | #endif 31 | 32 | #if BARNEY_RTC_CUDA 33 | # include "rtcore/cuda/TraceInterface.h" 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /rtcore/common/rtcore-common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "barney/barneyConfig.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "barney/barney.h" 12 | 13 | # ifdef __CUDA_ARCH__ 14 | # define RTC_DEVICE_CODE 1 15 | # endif 16 | 17 | #include "owl/common/math/AffineSpace.h" 18 | #include "owl/common/math/random.h" 19 | 20 | namespace rtc { 21 | 22 | using namespace owl::common; 23 | 24 | using range1f = interval; 25 | 26 | typedef enum { 27 | UCHAR, 28 | USHORT, 29 | 30 | INT, 31 | INT2, 32 | INT3, 33 | INT4, 34 | 35 | LONG, 36 | LONG2, 37 | LONG3, 38 | LONG4, 39 | 40 | FLOAT, 41 | FLOAT2, 42 | FLOAT3, 43 | FLOAT4, 44 | 45 | UCHAR4, 46 | NUM_DATA_TYPES 47 | } DataType; 48 | 49 | typedef enum { 50 | WRAP,CLAMP,BORDER,MIRROR, 51 | } AddressMode; 52 | 53 | typedef enum { 54 | FILTER_MODE_POINT,FILTER_MODE_LINEAR, 55 | } FilterMode; 56 | 57 | typedef enum { 58 | COLOR_SPACE_LINEAR, COLOR_SPACE_SRGB, 59 | } ColorSpace; 60 | 61 | struct TextureDesc { 62 | FilterMode filterMode = FILTER_MODE_LINEAR; 63 | AddressMode addressMode[3] = { CLAMP, CLAMP, CLAMP }; 64 | const vec4f borderColor = {0.f,0.f,0.f,0.f}; 65 | bool normalizedCoords = true; 66 | ColorSpace colorSpace = COLOR_SPACE_LINEAR; 67 | }; 68 | 69 | typedef struct _TextureObject *TextureObject; 70 | typedef struct _AccelHandle *AccelHandle; 71 | } 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /rtcore/cuda/AppInterface.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/cuda/Device.h" 20 | #include "rtcore/cuda/Buffer.h" 21 | #include "rtcore/cudaCommon/ComputeKernel.h" 22 | #include "rtcore/cuda/TraceKernel.h" 23 | // for setPrimCount etc 24 | #include "rtcore/cuda/Geom.h" 25 | // for buildAccel 26 | #include "rtcore/cuda/Group.h" 27 | // for createTexture 28 | #include "rtcore/cudaCommon/TextureData.h" 29 | // for getDD 30 | #include "rtcore/cudaCommon/Texture.h" 31 | 32 | namespace rtc { 33 | namespace cuda { 34 | 35 | using rtc::cuda_common::enablePeerAccess; 36 | 37 | using rtc::cuda_common::ComputeKernel1D; 38 | using rtc::cuda_common::ComputeKernel2D; 39 | using rtc::cuda_common::ComputeKernel3D; 40 | 41 | using rtc::cuda_common::Texture; 42 | using rtc::cuda_common::TextureData; 43 | } 44 | } 45 | 46 | #define RTC_IMPORT_USER_GEOM(moduleName,typeName,DD,has_ah,has_ch) \ 47 | extern ::rtc::cuda::GeomType *createGeomType_##typeName(::rtc::Device *); 48 | 49 | #define RTC_IMPORT_TRIANGLES_GEOM(moduleName,typeName,DD,has_ah,has_ch) \ 50 | extern rtc::cuda::GeomType *createGeomType_##typeName(rtc::Device *); 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /rtcore/cuda/Buffer.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/cuda/Device.h" 18 | #include "rtcore/cuda/Buffer.h" 19 | #include "rtcore/cudaCommon/Device.h" 20 | 21 | namespace rtc { 22 | namespace cuda { 23 | 24 | Buffer::Buffer(Device *device, 25 | size_t numBytes, 26 | const void *initValues) 27 | : device(device) 28 | { 29 | if (numBytes == 0) return; 30 | 31 | SetActiveGPU forDuration(device); 32 | BARNEY_CUDA_CALL(Malloc((void**)&d_data,numBytes)); 33 | if (initValues) 34 | BARNEY_CUDA_CALL(Memcpy(d_data,initValues,numBytes,cudaMemcpyDefault)); 35 | } 36 | 37 | Buffer::~Buffer() 38 | { 39 | if (!d_data) return; 40 | BARNEY_CUDA_CALL_NOTHROW(Free(d_data)); 41 | } 42 | 43 | void Buffer::upload(const void *data, size_t numBytes, size_t offset) 44 | { 45 | if (!d_data) return; 46 | SetActiveGPU forDuration(device); 47 | BARNEY_CUDA_CALL(Memcpy(((char *)d_data)+offset,data,numBytes,cudaMemcpyDefault)); 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rtcore/cuda/Buffer.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/cuda/Device.h" 20 | 21 | namespace rtc { 22 | namespace cuda { 23 | 24 | struct Device; 25 | 26 | struct Buffer { 27 | Buffer(Device *device, 28 | size_t numBytes, 29 | const void *initValues); 30 | virtual ~Buffer(); 31 | 32 | void *getDD() const { return d_data; } 33 | void upload(const void *data, size_t numBytes, size_t offset=0); 34 | void *d_data = 0; 35 | Device *const device; 36 | }; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rtcore/cuda/ComputeInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rtcore/cudaCommon/ComputeInterface.h" 4 | 5 | namespace rtc { 6 | namespace cuda { 7 | #if RTC_DEVICE_CODE 8 | using cuda_common::ComputeInterface; 9 | 10 | using cuda_common::tex1D; 11 | using cuda_common::tex2D; 12 | using cuda_common::tex3D; 13 | 14 | using cuda_common::fatomicMin; 15 | using cuda_common::fatomicMax; 16 | #endif 17 | } 18 | } 19 | 20 | # define __rtc_global __global__ 21 | # define __rtc_launch(myRTC,kernel,nb,bs,...) \ 22 | { rtc::cuda::SetActiveGPU forDuration(myRTC); kernel<<stream>>>(rtc::cuda::ComputeInterface(), __VA_ARGS__); } 23 | 24 | -------------------------------------------------------------------------------- /rtcore/cuda/Geom.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/cuda/Device.h" 18 | #include "rtcore/cuda/Geom.h" 19 | #include "rtcore/cuda/GeomType.h" 20 | 21 | namespace rtc { 22 | namespace cuda { 23 | 24 | Geom::Geom(GeomType *gt) 25 | : gt(gt), 26 | data(gt->sizeOfDD) 27 | {} 28 | 29 | Geom::~Geom() 30 | {} 31 | 32 | void Geom::setDD(const void *dd) 33 | { 34 | memcpy(data.data(),dd,data.size()); 35 | } 36 | 37 | TrianglesGeom::TrianglesGeom(GeomType *gt) 38 | : Geom(gt) 39 | {} 40 | 41 | void TrianglesGeom::setVertices(Buffer *vertices, 42 | int numVertices) 43 | { 44 | this->vertices = vertices; 45 | this->numVertices = numVertices; 46 | } 47 | 48 | void TrianglesGeom::setIndices(Buffer *indices, 49 | int numIndices) 50 | { 51 | this->indices = indices; 52 | this->numIndices = numIndices; 53 | } 54 | 55 | 56 | UserGeom::UserGeom(GeomType *gt) 57 | : Geom(gt) 58 | {} 59 | 60 | void UserGeom::setPrimCount(int primCount) 61 | { 62 | this->primCount = primCount; 63 | } 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /rtcore/cuda/GeomType.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/cuda/Device.h" 18 | #include "rtcore/cuda/GeomType.h" 19 | #include "rtcore/cuda/Geom.h" 20 | 21 | namespace rtc { 22 | namespace cuda { 23 | 24 | GeomType::GeomType(Device *device, 25 | size_t sizeOfDD) 26 | : device(device), sizeOfDD(sizeOfDD) 27 | {} 28 | 29 | UserGeomType::UserGeomType(Device *device, 30 | size_t sizeOfDD, 31 | BoundsKernel bounds, 32 | // BoundsProg bounds, 33 | IntersectProg intersect, 34 | AHProg ah, 35 | CHProg ch) 36 | : GeomType(device,sizeOfDD), 37 | bounds(bounds), 38 | intersect(intersect), 39 | ah(ah), 40 | ch(ch) 41 | {} 42 | 43 | TrianglesGeomType::TrianglesGeomType(Device *device, 44 | size_t sizeOfDD, 45 | AHProg ah, 46 | CHProg ch) 47 | : GeomType(device,sizeOfDD), 48 | ah(ah), 49 | ch(ch) 50 | {} 51 | 52 | Geom *UserGeomType::createGeom() 53 | { 54 | return new UserGeom(this); 55 | } 56 | 57 | Geom *TrianglesGeomType::createGeom() 58 | { 59 | return new TrianglesGeom(this); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /rtcore/cuda/TraceKernel.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/cuda/Device.h" 18 | #include "rtcore/cuda/TraceKernel.h" 19 | 20 | namespace rtc { 21 | namespace cuda { 22 | 23 | TraceKernel2D::TraceKernel2D(Device *device, 24 | size_t sizeOfLP, 25 | TraceLaunchFct traceLaunchFct) 26 | : device(device), 27 | sizeOfLP(sizeOfLP), 28 | traceLaunchFct(traceLaunchFct) 29 | { 30 | BARNEY_CUDA_CALL(Malloc((void **)&d_lpData,sizeOfLP)); 31 | } 32 | 33 | TraceKernel2D::~TraceKernel2D() 34 | { 35 | BARNEY_CUDA_CALL_NOTHROW(Free(d_lpData)); 36 | } 37 | 38 | 39 | void TraceKernel2D::launch(vec2i launchDims, 40 | const void *kernelData) 41 | { 42 | SetActiveGPU forDuration(device); 43 | BARNEY_CUDA_CALL(MemcpyAsync(d_lpData,kernelData, 44 | sizeOfLP,cudaMemcpyDefault,device->stream)); 45 | traceLaunchFct(device,launchDims,d_lpData); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /rtcore/cuda/TraceKernel.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/cudaCommon/Device.h" 20 | 21 | namespace rtc { 22 | namespace cuda { 23 | 24 | struct Device; 25 | 26 | typedef void (*TraceLaunchFct)(Device *device, vec2i dims, const void *lpData); 27 | 28 | struct TraceKernel2D { 29 | TraceKernel2D(Device *device, 30 | size_t sizeOfLP, 31 | TraceLaunchFct traceLaunchFct); 32 | ~TraceKernel2D(); 33 | void launch(vec2i launchDims, 34 | const void *kernelData); 35 | 36 | Device *const device; 37 | TraceLaunchFct const traceLaunchFct; 38 | size_t const sizeOfLP; 39 | void *d_lpData = 0; 40 | }; 41 | 42 | } 43 | } 44 | 45 | #define RTC_IMPORT_TRACE2D(fileNameBase,name,sizeOfLP) \ 46 | void rtc_cuda_launch_##name(rtc::Device *device, \ 47 | vec2i dims, \ 48 | const void *lpData); \ 49 | \ 50 | ::rtc::TraceKernel2D *createTrace_##name(rtc::Device *device) \ 51 | { \ 52 | return new ::rtc::cuda::TraceKernel2D \ 53 | (device,sizeOfLP,rtc_cuda_launch_##name); \ 54 | } \ 55 | 56 | -------------------------------------------------------------------------------- /rtcore/cudaCommon/ComputeKernel.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | /*! \file rtcore/cudaCommon/ComputeKerne.h Defines basic abstraction 18 | for 1D, 2D, and 3D compute kernels, and the IMPORT macros to 19 | import such kernels on host code */ 20 | 21 | #pragma once 22 | 23 | #include "rtcore/cudaCommon/cuda-common.h" 24 | 25 | namespace rtc { 26 | namespace cuda_common { 27 | 28 | struct ComputeKernel1D { 29 | virtual ~ComputeKernel1D() = default; 30 | virtual void launch(unsigned int nb, unsigned int bs, 31 | const void *pKernelData) = 0; 32 | }; 33 | 34 | struct ComputeKernel2D { 35 | virtual ~ComputeKernel2D() = default; 36 | virtual void launch(vec2ui nb, vec2ui bs, 37 | const void *pKernelData) = 0; 38 | }; 39 | 40 | struct ComputeKernel3D { 41 | virtual ~ComputeKernel3D() = default; 42 | virtual void launch(vec3ui nb, vec3ui bs, 43 | const void *pKernelData) = 0; 44 | }; 45 | 46 | } 47 | } 48 | 49 | #define RTC_IMPORT_COMPUTE1D(name) \ 50 | rtc::ComputeKernel1D *createCompute_##name(rtc::Device *dev); 51 | #define RTC_IMPORT_COMPUTE2D(name) \ 52 | rtc::ComputeKernel2D *createCompute_##name(rtc::Device *dev); 53 | #define RTC_IMPORT_COMPUTE3D(name) \ 54 | rtc::ComputeKernel3D *createCompute_##name(rtc::Device *dev); 55 | 56 | 57 | -------------------------------------------------------------------------------- /rtcore/cudaCommon/Texture.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/cudaCommon/cuda-common.h" 20 | 21 | namespace rtc { 22 | namespace cuda_common { 23 | 24 | struct Texture 25 | { 26 | Texture(TextureData *data, 27 | const TextureDesc &desc); 28 | virtual ~Texture(); 29 | 30 | TextureObject getDD() const 31 | { return (const TextureObject&)textureObject; } 32 | 33 | Device *const device; 34 | TextureData *const data; 35 | cudaTextureObject_t textureObject; 36 | }; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rtcore/cudaCommon/TextureData.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/cudaCommon/cuda-common.h" 20 | 21 | namespace rtc { 22 | namespace cuda_common { 23 | 24 | struct Device; 25 | struct Texture; 26 | 27 | struct TextureData// : public rtc::TextureData 28 | { 29 | TextureData(Device *device, 30 | vec3i dims, 31 | rtc::DataType format, 32 | const void *texels); 33 | virtual ~TextureData(); 34 | 35 | Texture * 36 | createTexture(const rtc::TextureDesc &desc); 37 | 38 | cudaArray_t array; 39 | cudaTextureReadMode readMode; 40 | const vec3i dims; 41 | const DataType format; 42 | Device *const device; 43 | }; 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /rtcore/cudaCommon/cuda-common.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/common/rtcore-common.h" 20 | #include 21 | #ifdef __CUDACC__ 22 | # include 23 | # include 24 | #endif 25 | #include "cuda-helper.h" 26 | 27 | #define __rtc_device __device__ 28 | #define __rtc_both __device__ __host__ 29 | 30 | #define RTC_HAVE_CUDA 1 31 | 32 | namespace rtc { 33 | namespace cuda_common { 34 | 35 | using namespace owl::common; 36 | 37 | // ------------------------------------------------------------------ 38 | // cuda vector types - import those into namesapce so we can 39 | // always disambiguate by writing rtc::float4 no matter what 40 | // backend we use 41 | // ------------------------------------------------------------------ 42 | using ::float2; 43 | using ::float3; 44 | using ::float4; 45 | using ::int2; 46 | using ::int3; 47 | using ::int4; 48 | 49 | inline __both__ vec3f load(const float3 &v) 50 | { return vec3f(v.x,v.y,v.z); } 51 | inline __both__ vec4f load(const float4 &vv) 52 | { float4 v = vv; return vec4f(v.x,v.y,v.z,v.w); } 53 | 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /rtcore/cudaCommon/cuda-helper.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2019-2020 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "cuda-helper.h" 18 | 19 | #ifdef _WIN32 20 | 21 | // // Custom usleep function for Windows 22 | // void usleep(__int64 usec) 23 | // { 24 | // // Convert microseconds to milliseconds (1 millisecond = 1000 microseconds) 25 | // // Minimum sleep time is 1 millisecond 26 | // __int64 msec = (usec / 1000 > 0) ? (usec / 1000) : 1; 27 | 28 | // // Use the Sleep function from Windows API 29 | // Sleep(static_cast(msec)); 30 | // } 31 | 32 | // // Custom sleep function for Windows, emulating Unix sleep 33 | // void sleep(unsigned int seconds) 34 | // { 35 | // // Convert seconds to milliseconds and call Sleep 36 | // Sleep(seconds * 1000); 37 | // } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /rtcore/embree/AppInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rtcore/embree/Device.h" 4 | #include "rtcore/embree/Buffer.h" 5 | #include "rtcore/embree/Group.h" 6 | #include "rtcore/embree/ComputeKernel.h" 7 | #include "rtcore/embree/Denoiser.h" 8 | 9 | namespace rtc { 10 | namespace embree { 11 | 12 | inline bool enablePeerAccess(const std::vector &IDs) 13 | { /* ignore / no-op on embree backend */; return true; } 14 | 15 | } 16 | } 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /rtcore/embree/Buffer.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/embree/Buffer.h" 18 | 19 | namespace rtc { 20 | namespace embree { 21 | 22 | Buffer::Buffer(Device *device, 23 | size_t numBytes, 24 | const void *initMem) 25 | { 26 | mem = numBytes?malloc(numBytes):nullptr; 27 | if (initMem) 28 | memcpy(mem,initMem,numBytes); 29 | } 30 | 31 | Buffer::~Buffer() 32 | { 33 | if (mem) free(mem); 34 | } 35 | 36 | void *Buffer::getDD() const 37 | { 38 | return mem; 39 | } 40 | 41 | void Buffer::upload(const void *hostPtr, 42 | size_t numBytes, 43 | size_t ofs) 44 | { 45 | memcpy(((uint8_t*)mem) + ofs,hostPtr,numBytes); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /rtcore/embree/Buffer.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/embree/Device.h" 20 | 21 | namespace rtc { 22 | namespace embree { 23 | 24 | struct Buffer 25 | { 26 | Buffer(Device *device,size_t numBytes,const void *initMem); 27 | virtual ~Buffer(); 28 | 29 | void upload(const void *hostPtr, 30 | size_t numBytes, 31 | size_t ofs = 0); 32 | 33 | void *getDD() const; 34 | void *mem = 0; 35 | }; 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /rtcore/embree/Denoiser.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/embree/Device.h" 20 | 21 | #if BARNEY_OIDN_CPU 22 | # include 23 | #endif 24 | 25 | namespace rtc { 26 | namespace embree { 27 | 28 | struct Denoiser { 29 | Denoiser(Device *device) : rtc(device) {} 30 | virtual ~Denoiser() = default; 31 | virtual void resize(vec2i dims) = 0; 32 | virtual void run(float blendFactor) = 0; 33 | 34 | vec4f *out_rgba = 0; 35 | vec4f *in_rgba = 0; 36 | vec3f *in_normal = 0; 37 | 38 | Device *const rtc; 39 | }; 40 | 41 | #if BARNEY_OIDN_CPU 42 | /*! oidn-based CPU denoiser */ 43 | struct DenoiserOIDN : public Denoiser 44 | { 45 | DenoiserOIDN(Device *device); 46 | virtual ~DenoiserOIDN(); 47 | 48 | void resize(vec2i size) override; 49 | void run(float blendFactor) override; 50 | 51 | private: 52 | void freeMem(); 53 | 54 | vec2i numPixels { 0,0 }; 55 | 56 | OIDNDevice oidnDevice = 0; 57 | OIDNFilter filter = 0; 58 | }; 59 | #endif 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /rtcore/embree/EmbreeBackend.cpp: -------------------------------------------------------------------------------- 1 | #include "rtcore/embree/Device.h" 2 | // #include "rtcore/embree/EmbreeBackend.h" 3 | 4 | namespace barney { 5 | namespace embree { 6 | struct TextureData; 7 | struct Device; 8 | 9 | // EmbreeBackend::EmbreeBackend() 10 | // { 11 | // numPhysicalDevices = 1; 12 | // } 13 | 14 | // EmbreeBackend::~EmbreeBackend() 15 | // {} 16 | 17 | // rtc::Device *EmbreeBackend::createDevice(int gpuID) 18 | // { 19 | // return new embree::Device(gpuID); 20 | // } 21 | 22 | } 23 | namespace rtc { 24 | 25 | // extern "C" 26 | // Backend *createBackend_embree() 27 | // { 28 | // return new barney::embree::EmbreeBackend; 29 | // } 30 | 31 | } 32 | } 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /rtcore/embree/EmbreeBackend.h: -------------------------------------------------------------------------------- 1 | // // ======================================================================== // 2 | // // Copyright 2023-2025 Ingo Wald // 3 | // // // 4 | // // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // // you may not use this file except in compliance with the License. // 6 | // // You may obtain a copy of the License at // 7 | // // // 8 | // // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // // 10 | // // Unless required by applicable law or agreed to in writing, software // 11 | // // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // // See the License for the specific language governing permissions and // 14 | // // limitations under the License. // 15 | // // ======================================================================== // 16 | 17 | // #pragma once 18 | 19 | // #include "rtcore/common/Backend.h" 20 | 21 | // namespace barney { 22 | // namespace embree { 23 | // struct EmbreeBackend; 24 | 25 | // struct EmbreeBackend : public rtc::Backend { 26 | // EmbreeBackend(); 27 | // virtual ~EmbreeBackend(); 28 | // // void setActiveGPU(int physicalID) override; 29 | // // int getActiveGPU() override; 30 | // rtc::Device *createDevice(int gpuID) override; 31 | // }; 32 | 33 | // } 34 | // } 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /rtcore/embree/Geom.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/embree/Geom.h" 18 | 19 | namespace rtc { 20 | namespace embree { 21 | 22 | Geom::Geom(GeomType *type) 23 | : type(type), 24 | programData(type->sizeOfProgramData) 25 | {} 26 | 27 | void Geom::setDD(const void *dd) 28 | { 29 | memcpy(programData.data(),dd,programData.size()); 30 | 31 | uint8_t *ptr = (uint8_t*)programData.data(); 32 | ptr += programData.size(); 33 | } 34 | 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /rtcore/embree/Geom.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/embree/GeomType.h" 20 | #include "rtcore/embree/Buffer.h" 21 | 22 | namespace rtc { 23 | namespace embree { 24 | 25 | struct Geom 26 | { 27 | Geom(GeomType *type); 28 | virtual ~Geom() = default; 29 | void setDD(const void *dd); 30 | 31 | /*! only for user geoms */ 32 | virtual void setPrimCount(int primCount) = 0; 33 | /*! can only get called on triangle type geoms */ 34 | virtual void setVertices(Buffer *vertices, int numVertices) = 0; 35 | virtual void setIndices(Buffer *indices, int numIndices) = 0; 36 | 37 | std::vector programData; 38 | GeomType *const type; 39 | }; 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rtcore/embree/Texture.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/embree/Device.h" 20 | 21 | namespace rtc { 22 | namespace embree { 23 | 24 | struct TextureSampler; 25 | struct Texture; 26 | struct TextureData; 27 | 28 | /*! abstract interface for a texture sampler; derived classes will 29 | inmplement this based on data provided */ 30 | struct TextureSampler { 31 | TextureSampler(TextureData *data, 32 | const rtc::TextureDesc &desc) 33 | : data(data), desc(desc) 34 | {} 35 | 36 | virtual vec4f tex1D(float x) = 0; 37 | virtual vec4f tex2D(vec2f tc) = 0; 38 | virtual vec4f tex3D(vec3f tc) = 0; 39 | 40 | TextureData *const data; 41 | rtc::TextureDesc const desc; 42 | }; 43 | 44 | struct TextureData 45 | { 46 | TextureData(Device *device, 47 | vec3i dims, 48 | rtc::DataType format, 49 | const void *texels); 50 | Texture *createTexture(const rtc::TextureDesc &desc); 51 | 52 | size_t sizeOfScalar; 53 | size_t numScalarsPerTexel; 54 | const vec3i dims; 55 | const DataType format; 56 | std::vector data; 57 | Device *const device; 58 | }; 59 | 60 | 61 | struct Texture 62 | { 63 | Texture(TextureData *const data, 64 | const rtc::TextureDesc &desc); 65 | rtc::TextureObject getDD() const; 66 | 67 | TextureSampler *sampler = 0; 68 | }; 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /rtcore/embree/Triangles.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/embree/Triangles.h" 18 | 19 | namespace rtc { 20 | namespace embree { 21 | 22 | TrianglesGeom::TrianglesGeom(TrianglesGeomType *type) 23 | : Geom(type) 24 | {} 25 | 26 | /*! only for user geoms */ 27 | void TrianglesGeom::setPrimCount(int primCount) 28 | { 29 | throw std::runtime_error("setPrimCount only makes sense for user geoms"); 30 | } 31 | 32 | /*! can only get called on triangle type geoms */ 33 | void TrianglesGeom::setVertices(Buffer *vertices, 34 | int numVertices) 35 | { 36 | this->vertices = (vec3f*)((Buffer *)vertices)->mem; 37 | this->numVertices = numVertices; 38 | } 39 | 40 | void TrianglesGeom::setIndices(Buffer *indices, int numIndices) 41 | { 42 | this->indices = (vec3i*)((Buffer *)indices)->mem; 43 | this->numIndices = numIndices; 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /rtcore/embree/Triangles.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/embree/Buffer.h" 20 | #include "rtcore/embree/GeomType.h" 21 | #include "rtcore/embree/Geom.h" 22 | 23 | namespace rtc { 24 | namespace embree { 25 | 26 | struct TrianglesGeomType; 27 | 28 | struct TrianglesGeom : public Geom 29 | { 30 | TrianglesGeom(TrianglesGeomType *type); 31 | 32 | /*! only for user geoms */ 33 | void setPrimCount(int primCount) override; 34 | /*! can only get called on triangle type geoms */ 35 | void setVertices(Buffer *vertices, int numVertices) override; 36 | void setIndices(Buffer *indices, int numIndices) override; 37 | 38 | int numVertices = 0; 39 | int numIndices = 0; 40 | vec3f *vertices = 0; 41 | vec3i *indices = 0; 42 | }; 43 | 44 | } 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /rtcore/embree/UserGeom.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/embree/UserGeom.h" 18 | 19 | namespace rtc { 20 | namespace embree { 21 | 22 | UserGeom::UserGeom(UserGeomType *type) 23 | : Geom(type) 24 | {} 25 | 26 | /*! only for user geoms */ 27 | void UserGeom::setPrimCount(int primCount) 28 | { 29 | this->primCount = primCount; 30 | } 31 | 32 | /*! can only get called on triangle type geoms */ 33 | void UserGeom::setVertices(Buffer *vertices, 34 | int numVertices) 35 | {/*ignore*/} 36 | void UserGeom::setIndices(Buffer *indices, int numIndices) 37 | {/*ignore*/} 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /rtcore/embree/UserGeom.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/embree/Buffer.h" 20 | #include "rtcore/embree/Geom.h" 21 | 22 | namespace rtc { 23 | namespace embree { 24 | 25 | struct UserGeom : public Geom 26 | { 27 | UserGeom(UserGeomType *type); 28 | 29 | /*! only for user geoms */ 30 | void setPrimCount(int primCount) override; 31 | /*! can only get called on triangle type geoms */ 32 | void setVertices(Buffer *vertices, int numVertices) override; 33 | void setIndices(Buffer *indices, int numIndices) override; 34 | 35 | int primCount = 0; 36 | }; 37 | 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /rtcore/embree/embree-common.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/common/rtcore-common.h" 20 | #include "embree4/rtcore.h" 21 | 22 | #define __rtc_device /* ignore - for embree device we use all cpu */ 23 | #define __rtc_both /* ignore - for embree device we use all cpu */ 24 | 25 | namespace rtc { 26 | namespace embree { 27 | 28 | using namespace embree_for_barney; 29 | using namespace owl::common; 30 | 31 | // ------------------------------------------------------------------ 32 | // cuda vector types - we may NOT use the cuda vector types EVEN 33 | // IF CUDA IS AVAILABLE, because the cuda vector types have 34 | // alignemnt, and these here do not - meaning that if some files 35 | // were to get compiled by nvcc and others by gcc/msvc we get 36 | // nasty differences is interpreting the same types in differnt ways 37 | // ------------------------------------------------------------------ 38 | struct float3 { float x; float y; float z; }; 39 | struct float4 { float x; float y; float z; float w; }; 40 | 41 | inline vec3f load(const ::rtc::embree::float3 &v) { return (const vec3f&)v; } 42 | inline vec4f load(const ::rtc::embree::float4 &v) { return (const vec4f&)v; } 43 | 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /rtcore/optix/AppInterface.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/optix/Device.h" 20 | #include "rtcore/optix/Buffer.h" 21 | #include "rtcore/cudaCommon/ComputeKernel.h" 22 | // for setPrimCount etc 23 | #include "rtcore/optix/Geom.h" 24 | // for buildAccel 25 | #include "rtcore/optix/Group.h" 26 | // for createTexture 27 | #include "rtcore/cudaCommon/TextureData.h" 28 | // for getDD 29 | #include "rtcore/cudaCommon/Texture.h" 30 | #include "rtcore/optix/Denoiser.h" 31 | 32 | namespace rtc { 33 | namespace optix { 34 | 35 | using rtc::cuda_common::enablePeerAccess; 36 | 37 | using rtc::cuda_common::ComputeKernel1D; 38 | using rtc::cuda_common::ComputeKernel2D; 39 | using rtc::cuda_common::ComputeKernel3D; 40 | 41 | using rtc::cuda_common::Texture; 42 | using rtc::cuda_common::TextureData; 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /rtcore/optix/Buffer.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/optix/Buffer.h" 18 | #include "rtcore/optix/Device.h" 19 | 20 | namespace rtc { 21 | namespace optix { 22 | 23 | Buffer::Buffer(optix::Device *device, 24 | size_t size, 25 | const void *initData) 26 | : device(device) 27 | { 28 | // owl = owlManagedMemoryBufferCreate(device->owl,OWL_BYTE,size,initData); 29 | owl = owlDeviceBufferCreate(device->owl,OWL_BYTE,size,initData); 30 | } 31 | 32 | void *Buffer::getDD() const 33 | { return (void*)owlBufferGetPointer(owl,0); } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rtcore/optix/Buffer.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/optix/Device.h" 20 | #include 21 | 22 | namespace rtc { 23 | namespace optix { 24 | struct Device; 25 | 26 | struct Buffer { 27 | Buffer(optix::Device *device, 28 | size_t size, 29 | const void *initData); 30 | void *getDD() const; 31 | 32 | void upload(const void *hostPtr, 33 | size_t numBytes, 34 | size_t ofs = 0); 35 | void uploadAsync(const void *hostPtr, 36 | size_t numBytes, 37 | size_t ofs = 0); 38 | 39 | optix::Device *const device; 40 | OWLBuffer owl; 41 | }; 42 | 43 | inline void Buffer::uploadAsync(const void *hostPtr, 44 | size_t numBytes, 45 | size_t ofs) 46 | { 47 | device->copyAsync(((uint8_t*)getDD())+ofs,hostPtr,numBytes); 48 | } 49 | inline void Buffer::upload(const void *hostPtr, 50 | size_t numBytes, 51 | size_t ofs) 52 | { 53 | device->copyAsync(((uint8_t*)getDD())+ofs,hostPtr,numBytes); 54 | device->sync(); 55 | } 56 | 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /rtcore/optix/ComputeInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rtcore/cudaCommon/ComputeInterface.h" 4 | 5 | namespace rtc { 6 | namespace optix { 7 | #ifdef __CUDACC__ 8 | using cuda_common::ComputeInterface; 9 | 10 | using cuda_common::tex1D; 11 | using cuda_common::tex2D; 12 | using cuda_common::tex3D; 13 | 14 | using cuda_common::fatomicMin; 15 | using cuda_common::fatomicMax; 16 | #endif 17 | } 18 | } 19 | 20 | # define __rtc_global __global__ 21 | # define __rtc_launch(myRTC,kernel,nb,bs,...) \ 22 | { rtc::optix::SetActiveGPU forDuration(myRTC); kernel<<stream>>>(rtc::optix::ComputeInterface(), __VA_ARGS__); } 23 | -------------------------------------------------------------------------------- /rtcore/optix/Denoiser.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/optix/Device.h" 20 | 21 | namespace rtc { 22 | namespace optix { 23 | 24 | /*! abstract interface to a denoiser. implementation(s) depend of 25 | which optix version and/or oidn are available */ 26 | struct Denoiser { 27 | Denoiser(Device* device) : device(device) {} 28 | virtual ~Denoiser() = default; 29 | virtual void resize(vec2i dims) = 0; 30 | virtual void run(float blendFactor) = 0; 31 | vec4f *out_rgba = 0; 32 | vec4f *in_rgba = 0; 33 | vec3f *in_normal = 0; 34 | Device* const device; 35 | }; 36 | 37 | #if OPTIX_VERSION >= 80000 38 | /*! denoising using optix 8 built-in denoiser. only available for 39 | optix 8 or newer */ 40 | struct Optix8Denoiser : public Denoiser { 41 | Optix8Denoiser(Device *device); 42 | virtual ~Optix8Denoiser(); 43 | void resize(vec2i dims) override; 44 | void run(float blendFactor) override; 45 | 46 | vec2i numPixels; 47 | OptixDenoiser denoiser = {}; 48 | OptixDenoiserOptions denoiserOptions; 49 | void *denoiserScratch = 0; 50 | void *denoiserState = 0; 51 | OptixDenoiserSizes denoiserSizes; 52 | }; 53 | #endif 54 | 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /rtcore/optix/Group.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "rtcore/optix/Group.h" 18 | #include "rtcore/optix/Device.h" 19 | 20 | namespace rtc { 21 | namespace optix { 22 | 23 | Group::Group(optix::Device *device, OWLGroup owl) 24 | : device(device), 25 | owl(owl) 26 | {} 27 | 28 | rtc::AccelHandle Group::getDD() const 29 | { 30 | OptixTraversableHandle handle 31 | = owlGroupGetTraversable(owl,0); 32 | return (const rtc::AccelHandle &)handle; 33 | } 34 | 35 | void Group::buildAccel() 36 | { 37 | owlGroupBuildAccel(owl); 38 | } 39 | 40 | void Group::refitAccel() 41 | { 42 | owlGroupRefitAccel(owl); 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /rtcore/optix/Group.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2023-2025 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "rtcore/optix/Device.h" 20 | #include 21 | 22 | namespace rtc { 23 | namespace optix { 24 | struct Device; 25 | 26 | struct Group { 27 | Group(optix::Device *device, OWLGroup owlGroup); 28 | virtual ~Group() { owlGroupRelease(owl); } 29 | 30 | rtc::AccelHandle getDD() const; 31 | void buildAccel(); 32 | void refitAccel(); 33 | 34 | OWLGroup const owl; 35 | optix::Device *const device; 36 | }; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/collage-triangles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/collage-triangles.jpg -------------------------------------------------------------------------------- /samples/collage-usergeom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/collage-usergeom.jpg -------------------------------------------------------------------------------- /samples/collage-volumes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/collage-volumes.jpg -------------------------------------------------------------------------------- /samples/make-collages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #sample-testorb.jpg 5 | #sample-headlight.png 6 | #sample-landscape.png 7 | convert \ 8 | sample-landscape.png -geometry x256\ 9 | sample-headlight.png -geometry x256\ 10 | sample-testorb.jpg -geometry x256\ 11 | +append collage-triangles.jpg 12 | 13 | #sample-capsules.png 14 | #sample-curves.jpg 15 | convert \ 16 | sample-capsules.png -geometry x256\ 17 | sample-pynari1.jpg -geometry x256\ 18 | +append row1.jpg 19 | 20 | convert \ 21 | sample-cylinders.jpg -geometry x256\ 22 | sample-cones.jpg -geometry x256\ 23 | sample-spheres.png -geometry x256\ 24 | sample-curves.jpg -geometry x256\ 25 | +append row2.jpg 26 | 27 | convert row1.jpg -geometry 1024x row2.jpg -geometry 1024x -append collage-usergeom.jpg 28 | 29 | #sample-kingsnake.png 30 | #sample-chest.png 31 | #sample-umesh1.png 32 | convert \ 33 | sample-chest.png -geometry x256\ 34 | sample-kingsnake.png -geometry x256\ 35 | sample-umesh.png -geometry x256\ 36 | +append collage-volumes.jpg 37 | -------------------------------------------------------------------------------- /samples/sample-capsules.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-capsules.png -------------------------------------------------------------------------------- /samples/sample-chest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-chest.png -------------------------------------------------------------------------------- /samples/sample-cones.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-cones.jpg -------------------------------------------------------------------------------- /samples/sample-curves.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-curves.jpg -------------------------------------------------------------------------------- /samples/sample-cylinders.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-cylinders.jpg -------------------------------------------------------------------------------- /samples/sample-headlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-headlight.png -------------------------------------------------------------------------------- /samples/sample-kingsnake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-kingsnake.png -------------------------------------------------------------------------------- /samples/sample-landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-landscape.png -------------------------------------------------------------------------------- /samples/sample-pynari1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-pynari1.jpg -------------------------------------------------------------------------------- /samples/sample-spheres.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-spheres.png -------------------------------------------------------------------------------- /samples/sample-testorb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-testorb.jpg -------------------------------------------------------------------------------- /samples/sample-umesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-umesh.png -------------------------------------------------------------------------------- /samples/sample-umesh1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ingowald/barney/907279ac1703b076a804c8fe41f8fd1ad77f58e7/samples/sample-umesh1.png -------------------------------------------------------------------------------- /win-build-all-variants.bat: -------------------------------------------------------------------------------- 1 | mkdir builddir-win-optix-only 2 | mkdir builddir-win-embree-only 3 | mkdir builddir-win-both 4 | 5 | cmake -S . -DOptiX_INSTALL_DIR=c:/users/ingow/Projects/optix/ -DCMAKE_INSTALL_PREFIX=c:/users/ingow/opt -DBARNEY_MPI=OFF -DBARNEY_BACKEND_EMBREE=OFF -B builddir-win-optix-only 6 | cmake -S . -DCMAKE_INSTALL_PREFIX=c:/users/ingow/opt -DBARNEY_MPI=OFF -DBARNEY_BACKEND_EMBREE=ON -DBARNEY_DISABLE_CUDA=ON -B builddir-win-embree-only 7 | cmake -S . -DOptiX_INSTALL_DIR=c:/users/ingow/Projects/optix/ -DCMAKE_INSTALL_PREFIX=c:/users/ingow/opt -DBARNEY_MPI=OFF -DBARNEY_BACKEND_EMBREE=ON -B builddir-win-both 8 | 9 | cmake --build builddir-win-optix-only --config Release 10 | cmake --build builddir-win-optix-only --config Debug 11 | 12 | cmake --build builddir-win-embree-only --config Release 13 | cmake --build builddir-win-embree-only --config Debug 14 | 15 | cmake --build builddir-win-both --config Release 16 | cmake --build builddir-win-both --config Debug 17 | --------------------------------------------------------------------------------