@@ -16,7 +16,7 @@ Texture_D3D11::Texture_D3D11(void *textureHandle, int textureWidth,
16
16
17
17
Texture_D3D11::~Texture_D3D11 ()
18
18
{
19
- _texBufferInterop->Release ();
19
+ // _texBufferInterop->Release();
20
20
CUDA_CHECK (cudaGetLastError ());
21
21
};
22
22
@@ -28,33 +28,31 @@ Texture_D3D11::~Texture_D3D11()
28
28
void Texture_D3D11::registerTextureInCUDA ()
29
29
{
30
30
31
- // This method initialize the buffer textures that will be registered in
32
- // CUDA This method will use m_device attributes in RenderAPI_D3D11, make
33
- // sure it has been well initialized.
34
- int retCodeCreate = _renderAPI->createTexture2D (
35
- _textureWidth, _textureHeight, _textureDepth, &_texBufferInterop);
36
- // we initialize
37
- if (retCodeCreate < 0 )
31
+ // we cast it here, to make it only once.
32
+ if (_textureDepth < 1 )
38
33
{
39
- Log::log ().debugLogError (" Could not initialize texture on DX11 for "
40
- " copy. Interoperability has failed." );
34
+ auto texUnityDX11 = (ID3D11Texture2D *)_textureHandle;
35
+ CUDA_CHECK (cudaGraphicsD3D11RegisterResource (
36
+ &_pGraphicsResource, texUnityDX11, cudaGraphicsRegisterFlagsNone));
37
+ CUDA_CHECK (cudaGetLastError ());
41
38
}
42
-
43
-
44
- // we cast it here, to make it only once.
45
- _texUnityDX11 = (ID3D11Texture2D *)_textureHandle;
46
- // assert(_texBufferInterop);
39
+ else
40
+ {
41
+ auto texUnityDX11 = (ID3D11Texture3D *)_textureHandle;
42
+ CUDA_CHECK (cudaGraphicsD3D11RegisterResource (
43
+ &_pGraphicsResource, texUnityDX11, cudaGraphicsRegisterFlagsNone));
44
+ CUDA_CHECK (cudaGetLastError ());
45
+ }
46
+ // assert(texUnityDX11);
47
47
// D3D11_TEXTURE2D_DESC texDesc;
48
- // _texBufferInterop ->GetDesc(&texDesc);
48
+ // texUnityDX11 ->GetDesc(&texDesc);
49
49
50
50
// DXGI_FORMAT format = texDesc.Format;
51
51
// Log::log().debugLog(std::to_string(format));
52
52
53
53
// CUDA_CHECK(cudaGetLastError());
54
54
// register the texture to cuda : it initialize the _pGraphicsResource
55
- CUDA_CHECK (cudaGraphicsD3D11RegisterResource (
56
- &_pGraphicsResource, _texBufferInterop, cudaGraphicsRegisterFlagsNone));
57
- CUDA_CHECK (cudaGetLastError ());
55
+
58
56
}
59
57
60
58
void Texture_D3D11::unRegisterTextureInCUDA ()
0 commit comments