You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unity with DX11 texture can't be registered in CUDA #2
The texture that has been created in Unity with DX11 API, will have the type DXGI_FORMAT_R32G32B32A32_TYPELESS in native plugin. Therefore, they can't be used like that to be registered in CUDA with cudaGraphicsD3D11RegisterResource, because it doesn't accept this format.
Hi @deibich,
Nice to see that my work is being useful to someone.
Thanks for the tips to change RenderTexture to Texture2D, after I saw the issue tracker, I had completely given up to make it work without a copy.
This morning I push a first version that work for texture 2D with this copy, but as I except it cause a big overhead. Thanks to you, I push another version that work for texture 2D without a copy and the performances are better ! Now I will tackle the problem of the texture 2D array.
To solve this issue I have to create another texture and copy the content of the texture created in Unity into it. This will cause an overhead...
Does the "action_sample_texture_array" work with this workaround?
On OpenGL, I could registered directly the texture array into a cuda surface object, that was then written with surf3DWrite. Therefore, no copy was needed. I hope to find a similar solution for dx11. Do not hesitate if you have any questions.
One drawback of using Texture2D instead of RenderTexture is that a Texture2D cannot be written in a compute shader. You get the following error if you try :
Attempting to bind texture as UAV but the texture wasn't created with the UAV usage flag set!
I think I will let the 2 options (with and without copy), just in case.
Activity
davidAlgis commentedon Mar 7, 2023
The texture that has been created in Unity with DX11 API, will have the type
DXGI_FORMAT_R32G32B32A32_TYPELESSin native plugin. Therefore, they can't be used like that to be registered in CUDA withcudaGraphicsD3D11RegisterResource, because it doesn't accept this format.davidAlgis commentedon Mar 7, 2023
I use this code to see that :
davidAlgis commentedon Mar 7, 2023
This issue was already reported here : see issue tracker
davidAlgis commentedon Mar 7, 2023
To solve this issue I have to create another texture and copy the content of the texture created in Unity into it. This will cause an overhead...
[-]Unity with DX11 texture can't be register in CUDA[/-][+]Unity with DX11 texture can't be registered in CUDA[/+]deibich commentedon Mar 8, 2023
Hello @davidAlgis,
we also plan to use Unity with Cuda and got some code working. During my research I stumbled over your project which looks very promising.
Because we focus on windows + directx I started to implement d3d11.
https://github.com/deibich/InteropUnityCUDA/commits/d3d11
As you can see I used Texture2D and Texture2DArray instead of RenderTexture to get rid of the problem with format ..._TYPLESS.
Does the "action_sample_texture_array" work with this workaround?
♻️🚧 Split Render API source files in header+source files.
✨🚧 Support DX11 on textures without copy (see #2 (comment))
davidAlgis commentedon Mar 9, 2023
Hi @deibich,
Nice to see that my work is being useful to someone.
Thanks for the tips to change
RenderTexturetoTexture2D, after I saw the issue tracker, I had completely given up to make it work without a copy.This morning I push a first version that work for texture 2D with this copy, but as I except it cause a big overhead. Thanks to you, I push another version that work for texture 2D without a copy and the performances are better ! Now I will tackle the problem of the texture 2D array.
On OpenGL, I could registered directly the texture array into a cuda surface object, that was then written with
surf3DWrite. Therefore, no copy was needed. I hope to find a similar solution for dx11. Do not hesitate if you have any questions.✨🚧 Support DX11 on textures by adding a copy (see #2 (comment))
✨🚧 Support DX11 on textures without copy (see #2 (comment))
davidAlgis commentedon Mar 9, 2023
One drawback of using
Texture2Dinstead ofRenderTextureis that aTexture2Dcannot be written in a compute shader. You get the following error if you try :I think I will let the 2 options (with and without copy), just in case.
♻️🚧 Split Render API source files in header+source files.
✨🚧 Support DX11 on textures by adding a copy (see #2 (comment))
✨🚧 Support DX11 on textures without copy (see #2 (comment))
♻️🚧 Split Render API source files in header+source files.
✨🚧 Support DX11 on textures by adding a copy (see #2 (comment))
✨🚧 Support DX11 on textures without copy (see #2 (comment))