Skip to content

Commit e34e5df

Browse files
committed
♻️ Reformat texture.cpp
1 parent eda2bd9 commit e34e5df

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

Plugin/PluginInteropUnityCUDA/src/Texture/texture.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
#pragma once
22
#include "texture.h"
33

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)
76
{
87
_textureHandle = textureHandle;
98
_textureWidth = textureWidth;
109
_textureHeight = textureHeight;
1110
_textureDepth = textureDepth;
1211
// set a default size of grid and block to avoid calculating it each time
1312
// TODO : update this for texture depth
14-
_dimBlock = { 8, 8, 1 };
13+
_dimBlock = {8, 8, 1};
1514
_dimGrid = calculateDimGrid(_dimBlock,
1615
{(unsigned int)textureWidth,
1716
(unsigned int)textureHeight,
1817
(unsigned int)textureDepth},
19-
false);
18+
false);
2019
_pGraphicsResource = nullptr;
2120
}
2221

@@ -30,10 +29,11 @@ cudaSurfaceObject_t Texture::mapTextureToSurfaceObject(int indexInArray)
3029
{
3130
// map the resource to cuda
3231
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));
3737

3838
// Wrap the cudaArray in a surface object
3939
cudaResourceDesc resDesc;
@@ -46,7 +46,6 @@ cudaSurfaceObject_t Texture::mapTextureToSurfaceObject(int indexInArray)
4646
return inputSurfObj;
4747
}
4848

49-
5049
cudaTextureObject_t Texture::mapTextureToTextureObject(int indexInArray)
5150
{
5251
// map the resource to cuda
@@ -77,9 +76,7 @@ cudaTextureObject_t Texture::mapTextureToTextureObject(int indexInArray)
7776
return texObj;
7877
}
7978

80-
81-
82-
void Texture::unMapTextureToSurfaceObject(cudaSurfaceObject_t& inputSurfObj)
79+
void Texture::unMapTextureToSurfaceObject(cudaSurfaceObject_t &inputSurfObj)
8380
{
8481
CUDA_CHECK(cudaGraphicsUnmapResources(1, &_pGraphicsResource));
8582
CUDA_CHECK(cudaDestroySurfaceObject(inputSurfObj));
@@ -118,11 +115,7 @@ int Texture::getDepth() const
118115
return _textureDepth;
119116
}
120117

121-
void* Texture::getNativeTexturePtr() const
118+
void *Texture::getNativeTexturePtr() const
122119
{
123120
return _textureHandle;
124121
}
125-
126-
127-
128-

0 commit comments

Comments
 (0)