Implémentation du raytracing pour Global Memory/Shared Memory/Constant Memory
[GPU.git] / WCudaMSE / BilatTools_Cuda / src / core / cudatools / header / device / IndiceTools_GPU.h
1 #ifndef INDICES_TOOLS_GPU_H_
2 #define INDICES_TOOLS_GPU_H_
3
4 #include "both_define.h"
5 #include "cudaType_CPU.h"
6
7 /*----------------------------------------------------------------------*\
8 |* Declaration *|
9 \*---------------------------------------------------------------------*/
10
11 /*--------------------------------------*\
12 |* Public *|
13 \*-------------------------------------*/
14
15 namespace gpu
16 {
17 class IndiceTools
18 {
19
20 /*--------------------------------------*\
21 |* Constructor *|
22 \*--------------------------------------*/
23
24 public:
25
26 /*--------------------------------------*\
27 |* Methodes *|
28 \*--------------------------------------*/
29
30 public:
31
32 /**
33 * s[0,W*H[ --> i[0,H[ j[0,W[
34 * w = largeur
35 * h = hauteur
36 */
37 __BOTH__
38 static void toIJ( int s, int w, int* ptrI, int* ptrJ)
39 {
40 *ptrI = s / w;
41 *ptrJ = s - w * (*ptrI);
42 }
43
44 /**
45 * s[0,W*H[ --> x[0,W[ y[0,H[
46 */
47 __BOTH__
48 static float2 toPixelFloat(int s, int w)
49 {
50 const int y = s / w;
51 const int x = s - w * y;
52 const float2 pixel = { (float)x, (float)y };
53 return pixel;
54 }
55
56 /**
57 * i[0,H[ j[0,W[ --> s[0,W*H[
58 * w = largeur
59 * h = hauteur
60 */
61 __BOTH__
62 static int toS(int w, int i, int j)
63 {
64 return (i * w) + j;
65 }
66
67 /*-------------------------------------*\
68 |* Attributs *|
69 \*-------------------------------------*/
70
71 private:
72
73 };
74 }
75
76 #endif
77
78 /*----------------------------------------------------------------------*\
79 |* End *|
80 \*---------------------------------------------------------------------*/