1- #include < device_launch_parameters.h>
2- #include < vector_functions.h>
3- #include " math_constants.h"
4- #include " log.h"
1+ #include " sample_kernels.cuh"
52
6- __global__ void writeTex (cudaSurfaceObject_t surf, int width, int height, float time) {
3+ __global__ void writeTex (cudaSurfaceObject_t surf, int width, int height,
4+ float time)
5+ {
76 const unsigned int x = blockIdx .x * blockDim .x + threadIdx .x ;
87 const unsigned int y = blockIdx .y * blockDim .y + threadIdx .y ;
98
10- if (x < width && y < height) {
9+ if (x < width && y < height)
10+ {
1111
12- float4 t =
13- make_float4 (0 , abs (cos (time)),
14- 0 , 1 .0f );
12+ float4 t = make_float4 (0 , abs (cos (time)), 0 , 1 .0f );
1513
1614 surf2Dwrite (t, surf, sizeof (float4 ) * x, y);
1715 }
1816}
1917
20- __global__ void writeTexArray (cudaSurfaceObject_t surf, int width, int height, int depth,
21- float time)
18+ __global__ void writeTexArray (cudaSurfaceObject_t surf, int width, int height,
19+ int depth, float time)
2220{
2321 const unsigned int x = blockIdx .x * blockDim .x + threadIdx .x ;
2422 const unsigned int y = blockIdx .y * blockDim .y + threadIdx .y ;
@@ -27,46 +25,45 @@ __global__ void writeTexArray(cudaSurfaceObject_t surf, int width, int height, i
2725 if (x < width && y < height)
2826 {
2927
30- float4 t =
31- make_float4 (z%2 , abs (cos (time)),
32- 0 , 1 .0f );
28+ float4 t = make_float4 (z % 2 , abs (cos (time)), 0 , 1 .0f );
3329
3430 surf3Dwrite (t, surf, sizeof (float4 ) * x, y, z);
3531 }
3632}
3733
38-
39-
40- __global__ void writeVertexBuffer (float4 * pos, int size, float time)
34+ __global__ void writeVertexBuffer (float4 *pos, int size, float time)
4135{
4236 unsigned int x = blockIdx .x * blockDim .x + threadIdx .x ;
43-
37+
4438 // write output vertex
4539 if (x < size)
4640 {
47- pos[x] = make_float4 ( cos (2 * CUDART_PI_F *time/x), sin (2 * CUDART_PI_F *time/x), 0 .0f ,1 .0f );
41+ pos[x] = make_float4 (cos (2 * CUDART_PI_F * time / x),
42+ sin (2 * CUDART_PI_F * time / x), 0 .0f , 1 .0f );
4843 }
4944}
5045
51-
52- void kernelCallerWriteTexture (const dim3 dimGrid, const dim3 dimBlock, cudaSurfaceObject_t inputSurfaceObj, const float time, const int width, const int height)
46+ void kernelCallerWriteTexture (const dim3 dimGrid, const dim3 dimBlock,
47+ cudaSurfaceObject_t inputSurfaceObj,
48+ const float time, const int width,
49+ const int height)
5350{
54- writeTex << <dimGrid, dimBlock >> > (inputSurfaceObj, width, height, time);
55-
51+ writeTex<<<dimGrid, dimBlock>>> (inputSurfaceObj, width, height, time);
5652}
5753
58-
5954void kernelCallerWriteTextureArray (const dim3 dimGrid, const dim3 dimBlock,
60- cudaSurfaceObject_t inputSurfaceObj,
61- const float time, const int width,
62- const int height, const int depth)
55+ cudaSurfaceObject_t inputSurfaceObj,
56+ const float time, const int width,
57+ const int height, const int depth)
6358{
64- // writeTexArray<<<dimGrid, dimBlock>>>(inputSurfaceObj, width, height,depth, time);
59+ // writeTexArray<<<dimGrid, dimBlock>>>(inputSurfaceObj, width,
60+ // height,depth, time);
6561 writeTex<<<dimGrid, dimBlock>>> (inputSurfaceObj, width, height, time);
6662}
6763
68-
69- void kernelCallerWriteBuffer (const dim3 dimGrid, const dim3 dimBlock, float4 * vertexPtr,const int size, const float time)
64+ void kernelCallerWriteBuffer (const dim3 dimGrid, const dim3 dimBlock,
65+ float4 *vertexPtr, const int size,
66+ const float time)
7067{
71- writeVertexBuffer << <dimGrid, dimBlock >> > (vertexPtr, size, time);
68+ writeVertexBuffer<< <dimGrid, dimBlock>>> (vertexPtr, size, time);
7269}
0 commit comments