@@ -25,6 +25,29 @@ void Texture_D3D11::registerTextureInCUDA()
25
25
// texture2D and texture2D array are ID3D11Texture2D in Unity for DX11
26
26
ID3D11Texture2D *texUnityDX11 = (ID3D11Texture2D *)_textureHandle;
27
27
28
+ D3D11_TEXTURE2D_DESC texDesc;
29
+ texUnityDX11->GetDesc (&texDesc);
30
+
31
+ DXGI_FORMAT format = texDesc.Format ;
32
+
33
+ // We check if the format is correct see
34
+ // https://github.com/davidAlgis/InteropUnityCUDA/issues/2
35
+ if (format == DXGI_FORMAT_R8G8B8A8_TYPELESS ||
36
+ format == DXGI_FORMAT_R32G32B32_TYPELESS ||
37
+ format == DXGI_FORMAT_R32G32B32A32_TYPELESS ||
38
+ format == DXGI_FORMAT_R16G16B16A16_TYPELESS ||
39
+ format == DXGI_FORMAT_R32G8X24_TYPELESS ||
40
+ format == DXGI_FORMAT_R32G32_TYPELESS ||
41
+ format == DXGI_FORMAT_R8_TYPELESS)
42
+ {
43
+ Log::log ().debugLogError (
44
+ " Texture of type " + std::to_string (format) +
45
+ " cannot be registered in CUDA." +
46
+ " It may comes from the fact that you can\' t used RenderTexture for "
47
+ " DX11 but only Texture2D." );
48
+ return ;
49
+ }
50
+
28
51
// register the texture to cuda : it initialize the _pGraphicsResource
29
52
CUDA_CHECK (cudaGraphicsD3D11RegisterResource (
30
53
&_graphicsResource, texUnityDX11, cudaGraphicsRegisterFlagsNone));
0 commit comments