@@ -22,6 +22,13 @@ Texture_D3D11::~Texture_D3D11()
22
22
23
23
int Texture_D3D11::registerTextureInCUDA ()
24
24
{
25
+ if (_textureHandle == nullptr )
26
+ {
27
+ Log::log ().debugLogError (
28
+ " The texture ptr is null, please create it in Unity and then send "
29
+ " it with GetNativePtr function." );
30
+ return -1 ;
31
+ }
25
32
// texture2D and texture2D array are ID3D11Texture2D in Unity for DX11
26
33
_texUnityDX11 = (ID3D11Texture2D *)_textureHandle;
27
34
@@ -39,23 +46,21 @@ int Texture_D3D11::registerTextureInCUDA()
39
46
format == DXGI_FORMAT_R32G32_TYPELESS ||
40
47
format == DXGI_FORMAT_R8_TYPELESS)
41
48
{
42
- Log::log ().debugLogError (
43
- " Texture of type " + std::to_string (format) +
44
- " cannot be registered in CUDA. " +
45
- " It may comes from the fact that you can \' t used RenderTexture for "
46
- " DX11 but only Texture2D." );
49
+ Log::log ().debugLogError (" Texture of type " + std::to_string (format) +
50
+ " cannot be registered in CUDA. " +
51
+ " It may comes from the fact that you can \' t "
52
+ " used RenderTexture for "
53
+ " DX11 but only Texture2D." );
47
54
return -1 ;
48
55
}
49
56
50
-
51
57
// register the texture to cuda : it initialize the _pGraphicsResource
52
58
CUDA_CHECK_RETURN (cudaGraphicsD3D11RegisterResource (
53
59
&_graphicsResource, _texUnityDX11, cudaGraphicsRegisterFlagsNone));
54
60
55
61
return SUCCESS_INTEROP_CODE;
56
62
}
57
63
58
-
59
64
int Texture_D3D11::unregisterTextureInCUDA ()
60
65
{
61
66
CUDA_CHECK_RETURN (cudaGraphicsUnregisterResource (_graphicsResource));
@@ -64,13 +69,14 @@ int Texture_D3D11::unregisterTextureInCUDA()
64
69
65
70
int Texture_D3D11::generateMips ()
66
71
{
67
- // we generate the shader resource in case the user want to use them (eg. for mips generation)
68
- GRUMBLE (_renderAPI->createShaderResource (_texUnityDX11, &_shaderResources), " Could not create shader resources. Cancel mips genereation" );
72
+ // we generate the shader resource in case the user want to use them (eg.
73
+ // for mips generation)
74
+ GRUMBLE (_renderAPI->createShaderResource (_texUnityDX11, &_shaderResources),
75
+ " Could not create shader resources. Cancel mips genereation" );
69
76
_renderAPI->getCurrentContext ()->GenerateMips (_shaderResources);
70
77
return SUCCESS_INTEROP_CODE;
71
78
}
72
79
73
-
74
80
int Texture_D3D11::copyUnityTextureToAPITexture ()
75
81
{
76
82
_renderAPI->copyTextures2D (_texBufferInterop, _texUnityDX11);
0 commit comments