1
1
#pragma once
2
2
#include " texture.h"
3
3
4
-
5
-
6
- Texture::Texture (void * textureHandle, int textureWidth, int textureHeight, int textureDepth)
4
+ Texture::Texture (void *textureHandle, int textureWidth, int textureHeight,
5
+ int textureDepth)
7
6
{
8
7
_textureHandle = textureHandle;
9
8
_textureWidth = textureWidth;
10
9
_textureHeight = textureHeight;
11
10
_textureDepth = textureDepth;
12
11
// set a default size of grid and block to avoid calculating it each time
13
12
// TODO : update this for texture depth
14
- _dimBlock = { 8 , 8 , 1 };
13
+ _dimBlock = {8 , 8 , 1 };
15
14
_dimGrid = calculateDimGrid (_dimBlock,
16
15
{(unsigned int )textureWidth,
17
16
(unsigned int )textureHeight,
18
17
(unsigned int )textureDepth},
19
- false );
18
+ false );
20
19
_pGraphicsResource = nullptr ;
21
20
}
22
21
@@ -30,10 +29,11 @@ cudaSurfaceObject_t Texture::mapTextureToSurfaceObject(int indexInArray)
30
29
{
31
30
// map the resource to cuda
32
31
CUDA_CHECK (cudaGraphicsMapResources (1 , &_pGraphicsResource));
33
- // cuda array on which the resources will be sended
34
- cudaArray* arrayPtr;
35
- // https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1g0dd6b5f024dfdcff5c28a08ef9958031
36
- CUDA_CHECK (cudaGraphicsSubResourceGetMappedArray (&arrayPtr, _pGraphicsResource, indexInArray, 0 ));
32
+ // cuda array on which the resources will be sended
33
+ cudaArray *arrayPtr;
34
+ // https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1g0dd6b5f024dfdcff5c28a08ef9958031
35
+ CUDA_CHECK (cudaGraphicsSubResourceGetMappedArray (
36
+ &arrayPtr, _pGraphicsResource, indexInArray, 0 ));
37
37
38
38
// Wrap the cudaArray in a surface object
39
39
cudaResourceDesc resDesc;
@@ -46,7 +46,6 @@ cudaSurfaceObject_t Texture::mapTextureToSurfaceObject(int indexInArray)
46
46
return inputSurfObj;
47
47
}
48
48
49
-
50
49
cudaTextureObject_t Texture::mapTextureToTextureObject (int indexInArray)
51
50
{
52
51
// map the resource to cuda
@@ -77,9 +76,7 @@ cudaTextureObject_t Texture::mapTextureToTextureObject(int indexInArray)
77
76
return texObj;
78
77
}
79
78
80
-
81
-
82
- void Texture::unMapTextureToSurfaceObject (cudaSurfaceObject_t& inputSurfObj)
79
+ void Texture::unMapTextureToSurfaceObject (cudaSurfaceObject_t &inputSurfObj)
83
80
{
84
81
CUDA_CHECK (cudaGraphicsUnmapResources (1 , &_pGraphicsResource));
85
82
CUDA_CHECK (cudaDestroySurfaceObject (inputSurfObj));
@@ -118,11 +115,7 @@ int Texture::getDepth() const
118
115
return _textureDepth;
119
116
}
120
117
121
- void * Texture::getNativeTexturePtr () const
118
+ void * Texture::getNativeTexturePtr () const
122
119
{
123
120
return _textureHandle;
124
121
}
125
-
126
-
127
-
128
-
0 commit comments