Git Product home page Git Product logo

interopunitycuda's Introduction

Interoperability between Unity Engine and CUDA

This repository shows a demonstration of interoperability between Unity Engine and CUDA. More specifically it proposes to create and render graphics objects (eg. texture) in Unity and editing them directly through CUDA kernel. This permit to bypass compute shader and to benefits of the full capacity of CUDA.

Plugins

The Plugin folder contains the c++ library used for interoperability. They can be regenerated with CMake. Assuming you are at the root of interopUnityCUDA, here are the commands to execute:

cd .\Plugin 
mkdir build
cmake -B build

Then to compile it :

cmake --build build --config Release
cmake --build build --config Debug

Moreover, to use the library in you unity project, you need to copy the content of the folder Debug and Release to your unity project.

The C++ projet consists of three library :

1. Utilities

This library include a singleton logger to simplify debugging between Unity and Native Plugin. Moreover it contains Unity native plugin API used by the other library.

2. PluginInteropUnityCUDA

This library contains the class that handle interoperability between Unity, Graphics API and CUDA. Moreover, it has function to register and call new Action.

An Action is a base class from which we can inherits to override functions. These functions will be called on render thread which is a necessary condition to make interoperability works.

3. SampleBasic

This library contains two basics examples of actions :

  • ActionSampleTexture : it register a Unity texture into CUDA and write some color into it.
  • ActionSampleTextureArray : it register a Unity texture array into CUDA and write some color into each texture slice.
  • ActionSampleVertexBuffer : it register a Unity vertex buffer of float4 into CUDA and change their values.

InteropUnityCUDA the Unity project

The folder InteropUnityCUDA contains the Unity project with the script to handle actions and call them in render thread. Furthermore, there is a script to display in Unity the log informations of the different plugin that use logger of Utilities (see. above).

The project has only one scene that demonstrate the three simple actions describe above.

Create your own action

See the dedicated documentation here.

Platform availability

It has been tested only on Unity 2021.1 and CUDA 12.2. At the moment it only work with OpenGL and DirectX11 graphics API. The plugin has been made for windows, but it can be compile with Linux too. For DirectX11 texture only works with Texture2D type not with RenderTexture (see. #2).

Meta

This repository has been developed within the scopes of the thesis of David Algis in collaboration with XLIM and Studio Nyx.

interopunitycuda's People

Contributors

davidalgis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

interopunitycuda's Issues

Unify the way texture array are handled for DX11 and OpenGL

When you create a Texture2DArray in Unity, there are two different behavior depending on graphics API :

  • OpenGL : it can be registered as a 3D texture (target is set to GL_TEXTURE_3D) and therefore we can use only one surface object in which we write with surf3DWrite see eg. 39039e5
  • DX11 : it can only be registered as a 2D texture (with arraySize greater than 1) and therefore we have to use multiple surfaces objects in which we write with surf2DWrite see 84220a4.

The philosophy of this plugin is to make user agnostic of the graphics API. That's why we need to find a way to make the user wrote into the texture array with only one method that will work with each API.

Add a unit test

We need to add a unit test that test if the plugin works for all supported graphics API

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.