embree-linux-x64 4.3.1

dotnet add package embree-linux-x64 --version 4.3.1
NuGet\Install-Package embree-linux-x64 -Version 4.3.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="embree-linux-x64" Version="4.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add embree-linux-x64 --version 4.3.1
#r "nuget: embree-linux-x64, 4.3.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install embree-linux-x64 as a Cake Addin
#addin nuget:?package=embree-linux-x64&version=4.3.1

// Install embree-linux-x64 as a Cake Tool
#tool nuget:?package=embree-linux-x64&version=4.3.1

EmbreeSharp

EmbreeSharp is an unofficial C# low-level binding for embree

Provide a tiny safe wrapper in C#

Target framework is net8.0

This project is still under development. API are not stable.

Use

Now target embree version is v4.3.1

Install this package from nuget.

Install the native library package for your platform from nuget. Or, compile embree by yourself and put native library into runtimes/${rid}/native

OS x64
win embree-win-x64
linux embree-linux-x64
osx embree-osx-x64

If you are using version 4.3.0. osx-x64 should first install tbb in system.

Directory structure

  • EmbreeSharp: source code, tiny safe wrapper also in this dir
    • Native: low-level bindings
  • EmbreeSharp.Test: some tests
  • Samples: some simple examples
  • Script: some scripts to package the official native libraries

Details

About native library

The official only provides binary files for win-x64, linux-x64 and osx-x64. If you want to run on other platforms, you should compile embree by yourself.

Because native libraries uploaded to nuget are separate, everyone can upload their compiled native libraries for others to use.

If you upload your compiled library, you can tell me the package name. I will display it in readme.

The Script folder contains some help scripts to package the official compiled native libraries into the nuget package.

About load native library in C#

Loading native dynamic library of embree is complicated. Because official release depends on TBB. P/Invoke cannot find its path automatically. There is no way to set library search path (as far as I know). So I use System.Runtime.InteropServices.NativeLibrary.SetDllImportResolver to custom loading logic.

Limitation

Cannot use all APIs related to SYCL.

TODO

I will provide more safe functions for C# wrapper. But limited by language difference, It is almost impossible to have both performance and safety.

If you have any idea, welcome issues and pull requests

Shared Buffer

The memory for shared buffer is managed by user.

Accouding to the API reference: rtcSetSharedGeometryBuffer

The buffer data must remain valid for as long as the buffer may be used, and the user is responsible for freeing the buffer data when no longer required.

This is a lifecycle problem.

I think reference count or reference tracing is the way to solve it. Because memory should know if there is a buffer in use. This can avoid dangling pointer. If the memory is not used. We can free memory proactively and safely.

Or, determined by GC. Yes, we can let buffer reference memory. When all buffers are released. Memory will only be freed when all buffers are released. But I think this is a backup option.

Geometry User Data

Same problem with shared buffer.

SetGeometry[Intersect/Occluded/Bounds]Function

Just provide safe API

BVH Build

TBC...

MXCSR control and status register

link

This is x86-64 instruction. C# API does not provide them.

Make a native library and use P/Invoke?

Hmm...maybe we can use OS api. Write binary code to memory and call OS api to set memory as executable such as VirtualProtectEx on win32.

License

The copyright of Embree belongs to the Embree development team

This project is under MIT

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.3.1 201 2/19/2024
4.3.0 314 11/26/2023
4.3.0-fix 127 11/27/2023