OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / samples / 2_Graphics / volumeFiltering / volume.h
1 /*
2 * Copyright 1993-2013 NVIDIA Corporation.  All rights reserved.
3 *
4 * Please refer to the NVIDIA end user license agreement (EULA) associated
5 * with this source code for terms and conditions that govern your use of
6 * this software. Any use, reproduction, disclosure, or distribution of
7 * this software and related documentation outside the terms of the EULA
8 * is strictly prohibited.
9 *
10 */
11
12 #ifndef _VOLUME_H_
13 #define _VOLUME_H_
14
15 #include <cuda_runtime.h>
16
17 typedef unsigned char VolumeType;
18
19 extern "C" {
20
21     struct Volume
22     {
23         cudaArray            *content;
24         cudaExtent            size;
25         cudaChannelFormatDesc channelDesc;
26     };
27
28     void Volume_init(Volume *vol, cudaExtent size, void *data, int allowStore);
29     void Volume_deinit(Volume *vol);
30
31 };
32
33 //////////////////////////////////////////////////////////////////////////
34
35 #ifdef __CUDACC__
36
37 /* Helper class to do popular integer storage to float conversions if required */
38
39 template< typename T >
40 struct VolumeTypeInfo
41 {};
42
43 template< >
44 struct VolumeTypeInfo<unsigned char>
45 {
46     static const cudaTextureReadMode readMode = cudaReadModeNormalizedFloat;
47     static __inline__ __device__ unsigned char convert(float sampled)
48     {
49         return (unsigned char)(saturate(sampled) * 255.0);
50     }
51 };
52
53 template< >
54 struct VolumeTypeInfo<unsigned short>
55 {
56     static const cudaTextureReadMode readMode = cudaReadModeNormalizedFloat;
57     static __inline__ __device__ unsigned short convert(float sampled)
58     {
59         return (unsigned short)(saturate(sampled) * 65535.0);
60     }
61 };
62
63 template< >
64 struct VolumeTypeInfo<float>
65 {
66     static const cudaTextureReadMode readMode = cudaReadModeElementType;
67     static __inline__ __device__ float convert(float sampled)
68     {
69         return sampled;
70     }
71 };
72
73 #endif
74
75 #endif
76