Skip to content

Commit 890b615

Browse files
committed
♻️ Add log for wrong format in DX11
1 parent 95f2f22 commit 890b615

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Plugin/PluginInteropUnityCUDA/src/Texture/texture_D3D11.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ void Texture_D3D11::registerTextureInCUDA()
2525
// texture2D and texture2D array are ID3D11Texture2D in Unity for DX11
2626
ID3D11Texture2D *texUnityDX11 = (ID3D11Texture2D *)_textureHandle;
2727

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+
2851
// register the texture to cuda : it initialize the _pGraphicsResource
2952
CUDA_CHECK(cudaGraphicsD3D11RegisterResource(
3053
&_graphicsResource, texUnityDX11, cudaGraphicsRegisterFlagsNone));

0 commit comments

Comments
 (0)