Skip to content

Commit 84b6de3

Browse files
author
david.algis
committed
♻️ reformat files
1 parent 77925a1 commit 84b6de3

File tree

1 file changed

+94
-84
lines changed
  • Plugin/PluginInteropUnityCUDA/include/Texture

1 file changed

+94
-84
lines changed

Plugin/PluginInteropUnityCUDA/include/Texture/texture.h

Lines changed: 94 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,90 +3,100 @@
33
#include "cuda_include.h"
44
#include "log.h"
55

6-
76
class UNITY_INTERFACE_EXPORT Texture
87
{
9-
public:
10-
/// <summary>
11-
/// Constructor of texture
12-
/// </summary>
13-
/// <param name="textureHandle">A pointer of texture with float4 that has been generated with Unity (see function
14-
/// GetNativeTexturePtr https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html) </param>
15-
/// <param name="textureWidth">the width of the texture</param>
16-
/// <param name="textureHeight">the height of the texture</param>
17-
/// <param name="textureDepth">the depth of the texture</param>
18-
Texture(void* textureHandle, int textureWidth, int textureHeight, int textureDepth);
19-
20-
21-
/// <summary>
22-
/// Register the texture in CUDA, this has to be override because it depends on the graphics api
23-
/// </summary>
24-
virtual void registerTextureInCUDA() = 0;
25-
26-
/// <summary>
27-
/// Unregister the texture in CUDA, this has to be override because it depends on the graphics api
28-
/// </summary>
29-
virtual void unRegisterTextureInCUDA() = 0;
30-
31-
/// <summary>
32-
/// Map a cuda array to the graphics resources and wrap it into a surface object of cuda
33-
/// </summary>
34-
/// <param name="indexInArray"> Array index for array textures or cubemap face index as
35-
/// defined by cudaGraphicsCubeFace for cubemap textures for the subresource to access </param>
36-
/// <returns>a cuda surface object on device memory and which can be edited in cuda</returns>
37-
cudaSurfaceObject_t mapTextureToSurfaceObject(int indexInArray = 0);
38-
39-
/// <summary>
40-
/// Unmap the cuda array from graphics resources and destroy surface object
41-
/// This function will wait for all previous GPU activity to complete
42-
/// </summary>
43-
/// <param name="inputSurfObj">the surface object that has been created with <c>mapTextureToSurfaceObject</c> function</param>
44-
void unMapTextureToSurfaceObject(cudaSurfaceObject_t& inputSurfObj);
45-
46-
/// <summary>
47-
/// Get the default dimension block (8,8,1)
48-
/// </summary>
49-
dim3 getDimBlock() const;
50-
51-
/// <summary>
52-
/// Get the default dimension grid ((sizeBuffer + 7)/8,((sizeBuffer + 7)/8,1)
53-
/// </summary>
54-
dim3 getDimGrid() const;
55-
56-
/// <summary>
57-
/// Get the width of the texture
58-
/// </summary>
59-
int getWidth() const;
60-
61-
/// <summary>
62-
/// Get the height of the texture
63-
/// </summary>
64-
int getHeight() const;
65-
66-
/// <summary>
67-
/// Get the depth of the texture
68-
/// </summary>
69-
int getDepth() const;
70-
71-
/// <summary>
72-
/// Get the native texture pointer
73-
/// </summary>
74-
void* getNativeTexturePtr() const;
75-
76-
protected:
77-
// Pointer to the texture created in Unity
78-
void* _textureHandle;
79-
// width of the texture
80-
int _textureWidth;
81-
// height of the texture
82-
int _textureHeight;
83-
// depth of the texture <2 <=> to Texture2D; >1 <=> Texture2DArray
84-
int _textureDepth;
85-
// Resource that can be used to retrieve the surface object for CUDA
86-
cudaGraphicsResource* _pGraphicsResource;
87-
88-
private:
89-
90-
dim3 _dimBlock;
91-
dim3 _dimGrid;
8+
public:
9+
/// <summary>
10+
/// Constructor of texture
11+
/// </summary>
12+
/// <param name="textureHandle">A pointer of texture with float4 that has
13+
/// been generated with Unity (see function GetNativeTexturePtr
14+
/// https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html)
15+
/// </param> <param name="textureWidth">the width of the texture</param>
16+
/// <param name="textureHeight">the height of the texture</param>
17+
/// <param name="textureDepth">the depth of the texture</param>
18+
Texture(void *textureHandle, int textureWidth, int textureHeight,
19+
int textureDepth);
20+
21+
/// <summary>
22+
/// Register the texture in CUDA, this has to be override because it depends
23+
/// on the graphics api
24+
/// </summary>
25+
virtual void registerTextureInCUDA() = 0;
26+
27+
/// <summary>
28+
/// Unregister the texture in CUDA, this has to be override because it
29+
/// depends on the graphics api
30+
/// </summary>
31+
virtual void unRegisterTextureInCUDA() = 0;
32+
33+
/// <summary>
34+
/// Map a cuda array to the graphics resources and wrap it into a surface
35+
/// object of cuda
36+
/// </summary>
37+
/// <param name="indexInArray"> Array index for array textures or cubemap
38+
/// face index as defined by cudaGraphicsCubeFace for cubemap textures for
39+
/// the subresource to access </param> <returns>a cuda surface object on
40+
/// device memory and which can be edited in cuda</returns>
41+
cudaSurfaceObject_t mapTextureToSurfaceObject(int indexInArray = 0);
42+
43+
44+
/// <summary>
45+
/// Unmap the cuda array from graphics resources and destroy surface object
46+
/// This function will wait for all previous GPU activity to complete
47+
/// </summary>
48+
/// <param name="inputSurfObj">the surface object that has been created with
49+
/// <c>mapTextureToSurfaceObject</c> function</param>
50+
void unMapTextureToSurfaceObject(cudaSurfaceObject_t &inputSurfObj);
51+
52+
cudaTextureObject_t mapTextureToTextureObject(int indexInArray = 0);
53+
54+
void unMapTextureToTextureObject(cudaTextureObject_t &texObj);
55+
56+
/// <summary>
57+
/// Get the default dimension block (8,8,1)
58+
/// </summary>
59+
dim3 getDimBlock() const;
60+
61+
/// <summary>
62+
/// Get the default dimension grid ((sizeBuffer + 7)/8,((sizeBuffer +
63+
/// 7)/8,1)
64+
/// </summary>
65+
dim3 getDimGrid() const;
66+
67+
/// <summary>
68+
/// Get the width of the texture
69+
/// </summary>
70+
int getWidth() const;
71+
72+
/// <summary>
73+
/// Get the height of the texture
74+
/// </summary>
75+
int getHeight() const;
76+
77+
/// <summary>
78+
/// Get the depth of the texture
79+
/// </summary>
80+
int getDepth() const;
81+
82+
/// <summary>
83+
/// Get the native texture pointer
84+
/// </summary>
85+
void *getNativeTexturePtr() const;
86+
87+
protected:
88+
// Pointer to the texture created in Unity
89+
void *_textureHandle;
90+
// width of the texture
91+
int _textureWidth;
92+
// height of the texture
93+
int _textureHeight;
94+
// depth of the texture <2 <=> to Texture2D; >1 <=> Texture2DArray
95+
int _textureDepth;
96+
// Resource that can be used to retrieve the surface object for CUDA
97+
cudaGraphicsResource *_pGraphicsResource;
98+
99+
private:
100+
dim3 _dimBlock;
101+
dim3 _dimGrid;
92102
};

0 commit comments

Comments
 (0)