├── .gitignore ├── ImageWorkbench.cu ├── ImageWorkbench.h.cu ├── Makefile ├── Output_GTX460.txt ├── Output_Geforce210.txt ├── README ├── asymmPSF_15x15.txt ├── asymmPSF_17x17.txt ├── asymmPSF_25x25.txt ├── common ├── Makefile ├── Makefile_paramgl ├── Makefile_rendercheckgl ├── common.mk ├── inc │ ├── GL │ │ ├── freeglut.h │ │ ├── freeglut_ext.h │ │ ├── freeglut_std.h │ │ ├── glew.h │ │ ├── glext.h │ │ ├── glut.h │ │ ├── glxew.h │ │ ├── glxext.h │ │ └── wglew.h │ ├── bank_checker.h │ ├── cmd_arg_reader.h │ ├── cuda_drvapi_dynlink.c │ ├── cuda_drvapi_dynlink.h │ ├── cuda_drvapi_dynlink_cuda.h │ ├── cuda_drvapi_dynlink_d3d.h │ ├── cuda_drvapi_dynlink_gl.h │ ├── cudpp │ │ └── cudpp.h │ ├── cutil.h │ ├── cutil_gl_error.h │ ├── cutil_gl_inline.h │ ├── cutil_inline.h │ ├── cutil_inline_bankchecker.h │ ├── cutil_inline_drvapi.h │ ├── cutil_inline_runtime.h │ ├── cutil_math.h │ ├── dynlink │ │ ├── channel_descriptor_dynlink.h │ │ ├── common_functions_dynlink.h │ │ ├── cuda_drvapi_dynlink.h │ │ ├── cuda_drvapi_dynlink_cuda.h │ │ ├── cuda_drvapi_dynlink_d3d.h │ │ ├── cuda_drvapi_dynlink_gl.h │ │ ├── cuda_runtime_api_dynlink.h │ │ ├── cuda_runtime_dynlink.h │ │ ├── cuda_texture_types_dynlink.h │ │ ├── device_functions_dynlink.h │ │ ├── math_functions_dbl_ptx3_dynlink.h │ │ ├── math_functions_dynlink.h │ │ └── texture_fetch_functions_dynlink.h │ ├── dynlink_d3d10.h │ ├── dynlink_d3d11.h │ ├── error_checker.h │ ├── exception.h │ ├── multithreading.h │ ├── nvGLWidgets.h │ ├── nvGlutWidgets.h │ ├── nvMath.h │ ├── nvMatrix.h │ ├── nvQuaternion.h │ ├── nvShaderUtils.h │ ├── nvVector.h │ ├── nvWidgets.h │ ├── param.h │ ├── paramgl.h │ ├── rendercheck_d3d10.h │ ├── rendercheck_d3d11.h │ ├── rendercheck_d3d9.h │ ├── rendercheck_gl.h │ ├── stopwatch.h │ ├── stopwatch_base.h │ ├── stopwatch_base.inl │ └── stopwatch_linux.h ├── lib │ └── linux │ │ ├── libGLEW.a │ │ └── libGLEW_x86_64.a ├── shared │ ├── Makefile │ ├── common.mk │ ├── inc │ │ ├── GL │ │ │ ├── freeglut.h │ │ │ ├── freeglut_ext.h │ │ │ ├── freeglut_std.h │ │ │ ├── gl.h │ │ │ ├── glew.h │ │ │ ├── glext.h │ │ │ ├── glu.h │ │ │ ├── glut.h │ │ │ ├── glxew.h │ │ │ ├── glxext.h │ │ │ └── wglew.h │ │ ├── cmd_arg_reader.h │ │ ├── cudpp │ │ │ └── cudpp.h │ │ ├── cuvid │ │ │ ├── cuviddec.h │ │ │ └── nvcuvid.h │ │ ├── dynlink │ │ │ ├── channel_descriptor_dynlink.h │ │ │ ├── common_functions_dynlink.h │ │ │ ├── cuda_drvapi_dynlink.h │ │ │ ├── cuda_runtime_api_dynlink.h │ │ │ ├── cuda_runtime_dynlink.h │ │ │ ├── cuda_texture_types_dynlink.h │ │ │ ├── device_functions_dynlink.h │ │ │ ├── math_functions_dbl_ptx3_dynlink.h │ │ │ ├── math_functions_dynlink.h │ │ │ └── texture_fetch_functions_dynlink.h │ │ ├── exception.h │ │ ├── multithreading.h │ │ ├── nvGLWidgets.h │ │ ├── nvGlutWidgets.h │ │ ├── nvMath.h │ │ ├── nvMatrix.h │ │ ├── nvQuaternion.h │ │ ├── nvShaderUtils.h │ │ ├── nvVector.h │ │ ├── nvWidgets.h │ │ ├── rendercheckGL.h │ │ ├── shrUtils.h │ │ ├── stopwatch.h │ │ ├── stopwatch_base.h │ │ ├── stopwatch_base.inl │ │ └── stopwatch_linux.h │ ├── lib │ │ ├── libshrutil_x86_64.a │ │ └── linux │ │ │ ├── libGLEW.a │ │ │ └── libGLEW_x86_64.a │ └── src │ │ ├── cmd_arg_reader.cpp │ │ ├── multithreading.cpp │ │ ├── rendercheckGL.cpp │ │ ├── shrUtils.cpp │ │ ├── stopwatch.cpp │ │ └── stopwatch_linux.cpp └── src │ ├── bank_checker.cpp │ ├── cmd_arg_reader.cpp │ ├── cuda_runtime_dynlink.cpp │ ├── cutil.cpp │ ├── multithreading.cpp │ ├── param.cpp │ ├── paramgl.cpp │ ├── rendercheck_d3d10.cpp │ ├── rendercheck_d3d11.cpp │ ├── rendercheck_d3d9.cpp │ ├── rendercheck_gl.cpp │ ├── stopwatch.cpp │ └── stopwatch_linux.cpp ├── cudaConvUtilities.cu ├── cudaConvUtilities.h.cu ├── cudaConvolution.cu ├── cudaConvolution.h.cu ├── cudaImageDevice.h.cu ├── cudaImageHost.h ├── cudaMorphology.cu ├── cudaMorphology.h.cu ├── cudaTroubleshoot.txt.cpp ├── cudaUtilities.cu ├── cudaUtilities.h.cu ├── dispGpuSoln.m ├── lib ├── libcutil_x86_64.a ├── libcutil_x86_64D.a ├── libshrutil_x86_64.a └── libshrutil_x86_64D.a ├── marie.txt ├── salt256.txt ├── salt4096.txt ├── salt512.txt └── unitTests.cu /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | bin/* 3 | common/obj/* 4 | common/shared/obj/* 5 | obj/* 6 | 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 3 | # Copyright 1993-2006 NVIDIA Corporation. All rights reserved. 4 | # 5 | # NOTICE TO USER: 6 | # 7 | # This source code is subject to NVIDIA ownership rights under U.S. and 8 | # international Copyright laws. 9 | # 10 | # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 11 | # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 12 | # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 13 | # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 14 | # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 15 | # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 16 | # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 17 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 18 | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 19 | # OR PERFORMANCE OF THIS SOURCE CODE. 20 | # 21 | # U.S. Government End Users. This source code is a "commercial item" as 22 | # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 23 | # "commercial computer software" and "commercial computer software 24 | # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 25 | # and is provided to the U.S. Government only as a commercial end item. 26 | # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 27 | # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 28 | # source code with only those rights set forth herein. 29 | # 30 | ################################################################################ 31 | # 32 | # Build script for project 33 | # 34 | ################################################################################ 35 | 36 | # Add source files here 37 | EXECUTABLE := convolution 38 | # CUDA source files (compiled with cudacc) 39 | CUFILES := unitTests.cu cudaConvUtilities.cu cudaConvolution.cu cudaMorphology.cu ImageWorkbench.cu 40 | # CUDA dependency files 41 | CU_DEPS := cudaImageHost.h cudaImageDevice.h.cu cudaConvUtilities.h.cu cudaConvolution.h.cu cudaMorphology.h.cu ImageWorkbench.h.cu 42 | # C/C++ source files (compiled with gcc / c++) 43 | CCPFILES := 44 | 45 | 46 | ################################################################################ 47 | # Rules and targets 48 | 49 | include common/common.mk 50 | -------------------------------------------------------------------------------- /asymmPSF_15x15.txt: -------------------------------------------------------------------------------- 1 | 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 2 | 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 3 | 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 4 | 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 5 | 1 1 1 0 0 0 0 0 0 0 1 0 0 0 1 6 | 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 8 | 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 9 | 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 10 | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 11 | 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 12 | 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 13 | 1 0 1 0 0 0 0 0 0 0 1 1 0 1 0 14 | 0 1 0 1 0 0 0 0 0 1 1 0 1 0 1 15 | 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 16 | -------------------------------------------------------------------------------- /asymmPSF_17x17.txt: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 | 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 3 | 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 4 | 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 1 5 | 1 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 6 | 1 1 1 1 0 0 0 0 0 0 0 1 0 0 0 1 1 7 | 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 8 | 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 9 | 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 10 | 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 11 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 12 | 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 13 | 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 14 | 1 1 0 1 0 0 0 0 0 0 0 1 1 0 1 0 1 15 | 1 0 1 0 1 0 0 0 0 0 1 1 0 1 0 1 1 16 | 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 17 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 | -------------------------------------------------------------------------------- /asymmPSF_25x25.txt: -------------------------------------------------------------------------------- 1 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 | 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 | 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 | 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13 | 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 14 | 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 15 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 16 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 17 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 18 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 19 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 20 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 21 | 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 22 | 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 23 | 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 24 | 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 25 | 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 26 | -------------------------------------------------------------------------------- /common/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 4 | # 5 | # NOTICE TO USER: 6 | # 7 | # This source code is subject to NVIDIA ownership rights under U.S. and 8 | # international Copyright laws. 9 | # 10 | # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 11 | # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 12 | # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 13 | # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 14 | # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 15 | # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 16 | # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 17 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 18 | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 19 | # OR PERFORMANCE OF THIS SOURCE CODE. 20 | # 21 | # U.S. Government End Users. This source code is a "commercial item" as 22 | # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 23 | # "commercial computer software" and "commercial computer software 24 | # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 25 | # and is provided to the U.S. Government only as a commercial end item. 26 | # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 27 | # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 28 | # source code with only those rights set forth herein. 29 | # 30 | ############################################################################### 31 | # 32 | # CUda UTility library build script 33 | # 34 | ############################################################################### 35 | 36 | ############################################################################### 37 | # SOURCE VARS 38 | CCFILES := src/bank_checker.cpp \ 39 | src/cmd_arg_reader.cpp \ 40 | src/cutil.cpp \ 41 | src/stopwatch.cpp \ 42 | src/stopwatch_linux.cpp \ 43 | src/multithreading.cpp 44 | 45 | SRCDIR := src/ 46 | 47 | ROOTDIR := . 48 | 49 | STATIC_LIB := libcutil.a 50 | 51 | include common.mk 52 | 53 | -------------------------------------------------------------------------------- /common/Makefile_paramgl: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 4 | # 5 | # NOTICE TO USER: 6 | # 7 | # This source code is subject to NVIDIA ownership rights under U.S. and 8 | # international Copyright laws. 9 | # 10 | # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 11 | # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 12 | # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 13 | # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 14 | # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 15 | # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 16 | # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 17 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 18 | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 19 | # OR PERFORMANCE OF THIS SOURCE CODE. 20 | # 21 | # U.S. Government End Users. This source code is a "commercial item" as 22 | # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 23 | # "commercial computer software" and "commercial computer software 24 | # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 25 | # and is provided to the U.S. Government only as a commercial end item. 26 | # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 27 | # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 28 | # source code with only those rights set forth herein. 29 | # 30 | ############################################################################### 31 | # 32 | # CUda UTility library build script 33 | # 34 | ############################################################################### 35 | 36 | ############################################################################### 37 | # SOURCE VARS 38 | CCFILES := src/paramgl.cpp \ 39 | src/param.cpp \ 40 | 41 | SRCDIR := src/ 42 | 43 | ROOTDIR := . 44 | 45 | STATIC_LIB := libparamgl.a 46 | 47 | include common.mk 48 | 49 | -------------------------------------------------------------------------------- /common/Makefile_rendercheckgl: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 4 | # 5 | # NOTICE TO USER: 6 | # 7 | # This source code is subject to NVIDIA ownership rights under U.S. and 8 | # international Copyright laws. 9 | # 10 | # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 11 | # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 12 | # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 13 | # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 14 | # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 15 | # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 16 | # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 17 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 18 | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 19 | # OR PERFORMANCE OF THIS SOURCE CODE. 20 | # 21 | # U.S. Government End Users. This source code is a "commercial item" as 22 | # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 23 | # "commercial computer software" and "commercial computer software 24 | # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 25 | # and is provided to the U.S. Government only as a commercial end item. 26 | # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 27 | # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 28 | # source code with only those rights set forth herein. 29 | # 30 | ############################################################################### 31 | # 32 | # CUda UTility library build script 33 | # 34 | ############################################################################### 35 | 36 | ############################################################################### 37 | # SOURCE VARS 38 | CCFILES := src/rendercheck_gl.cpp 39 | 40 | SRCDIR := src/ 41 | 42 | ROOTDIR := . 43 | 44 | STATIC_LIB := librendercheckgl.a 45 | 46 | include common.mk 47 | 48 | -------------------------------------------------------------------------------- /common/inc/GL/freeglut.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_H__ 2 | #define __FREEGLUT_H__ 3 | 4 | /* 5 | * freeglut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | #include "freeglut_ext.h" 19 | 20 | /*** END OF FILE ***/ 21 | 22 | #endif /* __FREEGLUT_H__ */ 23 | -------------------------------------------------------------------------------- /common/inc/GL/freeglut_ext.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_EXT_H__ 2 | #define __FREEGLUT_EXT_H__ 3 | 4 | /* 5 | * freeglut_ext.h 6 | * 7 | * The non-GLUT-compatible extensions to the freeglut library include file 8 | * 9 | * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. 10 | * Written by Pawel W. Olszta, 11 | * Creation date: Thu Dec 2 1999 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a 14 | * copy of this software and associated documentation files (the "Software"), 15 | * to deal in the Software without restriction, including without limitation 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | * and/or sell copies of the Software, and to permit persons to whom the 18 | * Software is furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included 21 | * in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 27 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | */ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* 36 | * GLUT API Extension macro definitions -- behaviour when the user clicks on an "x" to close a window 37 | */ 38 | #define GLUT_ACTION_EXIT 0 39 | #define GLUT_ACTION_GLUTMAINLOOP_RETURNS 1 40 | #define GLUT_ACTION_CONTINUE_EXECUTION 2 41 | 42 | /* 43 | * Create a new rendering context when the user opens a new window? 44 | */ 45 | #define GLUT_CREATE_NEW_CONTEXT 0 46 | #define GLUT_USE_CURRENT_CONTEXT 1 47 | 48 | /* 49 | * GLUT API Extension macro definitions -- the glutGet parameters 50 | */ 51 | #define GLUT_ACTION_ON_WINDOW_CLOSE 0x01F9 52 | 53 | #define GLUT_WINDOW_BORDER_WIDTH 0x01FA 54 | #define GLUT_WINDOW_HEADER_HEIGHT 0x01FB 55 | 56 | #define GLUT_VERSION 0x01FC 57 | 58 | #define GLUT_RENDERING_CONTEXT 0x01FD 59 | 60 | /* 61 | * Process loop function, see freeglut_main.c 62 | */ 63 | FGAPI void FGAPIENTRY glutMainLoopEvent( void ); 64 | FGAPI void FGAPIENTRY glutLeaveMainLoop( void ); 65 | 66 | /* 67 | * Window-specific callback functions, see freeglut_callbacks.c 68 | */ 69 | FGAPI void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) ); 70 | FGAPI void FGAPIENTRY glutCloseFunc( void (* callback)( void ) ); 71 | FGAPI void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) ); 72 | /* A. Donev: Also a destruction callback for menus */ 73 | FGAPI void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) ); 74 | 75 | /* 76 | * State setting and retrieval functions, see freeglut_state.c 77 | */ 78 | FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value ) ; 79 | /* A.Donev: User-data manipulation */ 80 | FGAPI void* FGAPIENTRY glutGetWindowData( void ); 81 | FGAPI void FGAPIENTRY glutSetWindowData(void* data); 82 | FGAPI void* FGAPIENTRY glutGetMenuData( void ); 83 | FGAPI void FGAPIENTRY glutSetMenuData(void* data); 84 | 85 | /* 86 | * Font stuff, see freeglut_font.c 87 | */ 88 | FGAPI int FGAPIENTRY glutBitmapHeight( void* font ); 89 | FGAPI GLfloat FGAPIENTRY glutStrokeHeight( void* font ); 90 | FGAPI void FGAPIENTRY glutBitmapString( void* font, const unsigned char *string ); 91 | FGAPI void FGAPIENTRY glutStrokeString( void* font, const unsigned char *string ); 92 | 93 | /* 94 | * Geometry functions, see freeglut_geometry.c 95 | */ 96 | FGAPI void FGAPIENTRY glutWireRhombicDodecahedron( void ); 97 | FGAPI void FGAPIENTRY glutSolidRhombicDodecahedron( void ); 98 | FGAPI void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ; 99 | FGAPI void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ; 100 | FGAPI void FGAPIENTRY glutWireCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks); 101 | FGAPI void FGAPIENTRY glutSolidCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks); 102 | 103 | /* 104 | * Extension functions, see freeglut_ext.c 105 | */ 106 | FGAPI void * FGAPIENTRY glutGetProcAddress( const char *procName ); 107 | 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | /*** END OF FILE ***/ 114 | 115 | #endif /* __FREEGLUT_EXT_H__ */ 116 | -------------------------------------------------------------------------------- /common/inc/cuda_drvapi_dynlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | 13 | #ifndef __cuda_drvapi_dynlink_h__ 14 | #define __cuda_drvapi_dynlink_h__ 15 | 16 | #include "cuda_drvapi_dynlink_cuda.h" 17 | 18 | #if defined(CUDA_INIT_D3D9)||defined(CUDA_INIT_D3D10)||defined(CUDA_INIT_D3D11) 19 | #include "cuda_drvapi_dynlink_d3d.h" 20 | #endif 21 | 22 | #ifdef CUDA_INIT_OPENGL 23 | #include "cuda_drvapi_dynlink_gl.h" 24 | #endif 25 | 26 | #endif //__cuda_drvapi_dynlink_h__ 27 | -------------------------------------------------------------------------------- /common/inc/cuda_drvapi_dynlink_d3d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 __cuda_drvapi_dynlink_d3d_h__ 13 | #define __cuda_drvapi_dynlink_d3d_h__ 14 | 15 | #if defined(_WIN32) 16 | #pragma warning(disable: 4312) 17 | 18 | #if defined (CUDA_INIT_D3D9) || defined(CUDA_INIT_D3D10) || defined(CUDA_INIT_D3D11) 19 | #include 20 | #include 21 | #endif 22 | 23 | #ifdef CUDA_INIT_D3D9 24 | #include 25 | #pragma warning( disable : 4996 ) // disable deprecated warning 26 | #include 27 | #pragma warning( default : 4996 ) 28 | 29 | /** 30 | * CUDA 2.x compatibility - Flags to register a D3D9 graphics resource 31 | */ 32 | typedef enum CUd3d9register_flags_enum { 33 | CU_D3D9_REGISTER_FLAGS_NONE = 0x00, 34 | CU_D3D9_REGISTER_FLAGS_ARRAY = 0x01, 35 | } CUd3d9register_flags; 36 | 37 | /** 38 | * CUDA 2.x compatibility - Flags for D3D9 mapping and unmapping interop resources 39 | */ 40 | typedef enum CUd3d9map_flags_enum { 41 | CU_D3D9_MAPRESOURCE_FLAGS_NONE = 0x00, 42 | CU_D3D9_MAPRESOURCE_FLAGS_READONLY = 0x01, 43 | CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD = 0x02, 44 | } CUd3d9map_flags; 45 | 46 | // D3D9/CUDA interop (CUDA 1.x compatible API). These functions are deprecated, please use the ones below 47 | typedef CUresult CUDAAPI tcuD3D9Begin( IDirect3DDevice9 *pDevice ); 48 | typedef CUresult CUDAAPI tcuD3D9End( void ); 49 | typedef CUresult CUDAAPI tcuD3D9RegisterVertexBuffer( IDirect3DVertexBuffer9 *pVB ); 50 | typedef CUresult CUDAAPI tcuD3D9MapVertexBuffer( CUdeviceptr *pDevPtr, unsigned int *pSize, IDirect3DVertexBuffer9 *pVB ); 51 | typedef CUresult CUDAAPI tcuD3D9UnmapVertexBuffer( IDirect3DVertexBuffer9 *pVB ); 52 | typedef CUresult CUDAAPI tcuD3D9UnregisterVertexBuffer( IDirect3DVertexBuffer9 *pVB ); 53 | 54 | // D3D9/CUDA interop (CUDA 2.x compatible) 55 | typedef CUresult CUDAAPI tcuD3D9GetDirect3DDevice( IDirect3DDevice9 **ppD3DDevice ); 56 | typedef CUresult CUDAAPI tcuD3D9RegisterResource( IDirect3DResource9 *pResource, unsigned int Flags ); 57 | typedef CUresult CUDAAPI tcuD3D9UnregisterResource( IDirect3DResource9 *pResource ); 58 | 59 | typedef CUresult CUDAAPI tcuD3D9MapResources( unsigned int count, IDirect3DResource9 **ppResource ); 60 | typedef CUresult CUDAAPI tcuD3D9UnmapResources( unsigned int count, IDirect3DResource9 **ppResource ); 61 | typedef CUresult CUDAAPI tcuD3D9ResourceSetMapFlags( IDirect3DResource9 *pResource, unsigned int Flags ); 62 | 63 | typedef CUresult CUDAAPI tcuD3D9ResourceGetSurfaceDimensions( unsigned int *pWidth, unsigned int *pHeight, unsigned int *pDepth, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 64 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedArray( CUarray *pArray, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 65 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedPointer( CUdeviceptr *pDevPtr, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 66 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedSize( unsigned int *pSize, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 67 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedPitch( unsigned int *pPitch, unsigned int *pPitchSlice, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 68 | 69 | // D3D9/CUDA interop (CUDA 2.0+) 70 | typedef CUresult CUDAAPI tcuD3D9GetDevice( CUdevice *pCudaDevice, const char *pszAdapterName); 71 | typedef CUresult CUDAAPI tcuD3D9CtxCreate( CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, IDirect3DDevice9 *pD3DDevice ); 72 | typedef CUresult CUDAAPI tcuGraphicsD3D9RegisterResource( CUgraphicsResource *pCudaResource, IDirect3DResource9 *pD3DResource, unsigned int Flags ); 73 | #endif 74 | 75 | #ifdef CUDA_INIT_D3D10 76 | #include 77 | #include 78 | #include 79 | #include 80 | 81 | #pragma warning( disable : 4996 ) // disable deprecated warning 82 | #include 83 | #pragma warning( default : 4996 ) 84 | 85 | // D3D11/CUDA interop (CUDA 3.0) 86 | typedef CUresult CUDAAPI tcuD3D10GetDevice( CUdevice *pCudaDevice, IDXGIAdapter *pAdapter ); 87 | typedef CUresult CUDAAPI tcuD3D10CtxCreate( CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D10Device *pD3DDevice ); 88 | typedef CUresult CUDAAPI tcuGraphicsD3D10RegisterResource( CUgraphicsResource *pCudaResource, ID3D10Resource *pD3DResource, unsigned int Flags ); 89 | #endif // CUDA_INIT_D3D10 90 | 91 | #ifdef CUDA_INIT_D3D11 92 | #include 93 | #include 94 | #include 95 | 96 | #pragma warning( disable : 4996 ) // disable deprecated warning 97 | #include 98 | #pragma warning( default : 4996 ) 99 | 100 | // D3D11/CUDA interop (CUDA 3.0) 101 | typedef CUresult CUDAAPI tcuD3D11GetDevice( CUdevice *pCudaDevice, IDXGIAdapter *pAdapter ); 102 | typedef CUresult CUDAAPI tcuD3D11CtxCreate( CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D11Device *pD3DDevice ); 103 | typedef CUresult CUDAAPI tcuGraphicsD3D11RegisterResource( CUgraphicsResource *pCudaResource, ID3D11Resource *pD3DResource, unsigned int Flags ); 104 | #endif // CUDA_INIT_D3D11 105 | 106 | #endif // WIN32 107 | 108 | #endif // __cuda_drvapi_dynlink_cuda_d3d_h__ 109 | -------------------------------------------------------------------------------- /common/inc/cuda_drvapi_dynlink_gl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 __cuda_drvapi_dynlink_cuda_gl_h__ 13 | #define __cuda_drvapi_dynlink_cuda_gl_h__ 14 | 15 | #ifdef CUDA_INIT_OPENGL 16 | 17 | #ifdef _WIN32 18 | # define WINDOWS_LEAN_AND_MEAN 19 | # define NOMINMAX 20 | # include 21 | #endif 22 | 23 | // includes, system 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // includes, GL 30 | #include 31 | 32 | #if defined (__APPLE__) || defined(MACOSX) 33 | #include 34 | #else 35 | #include 36 | #endif 37 | 38 | /************************************ 39 | ** 40 | ** OpenGL Graphics/Interop 41 | ** 42 | ***********************************/ 43 | 44 | // OpenGL/CUDA interop (CUDA 2.0+) 45 | typedef CUresult CUDAAPI tcuGLCtxCreate( CUcontext *pCtx, unsigned int Flags, CUdevice device ); 46 | typedef CUresult CUDAAPI tcuGraphicsGLRegisterBuffer( CUgraphicsResource *pCudaResource, GLuint buffer, unsigned int Flags ); 47 | typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage( CUgraphicsResource *pCudaResource, GLuint image, GLenum target, unsigned int Flags ); 48 | 49 | #ifdef _WIN32 50 | #include 51 | // WIN32 52 | typedef CUresult CUDAAPI tcuWGLGetDevice( CUdevice *pDevice, HGPUNV hGpu ); 53 | #endif 54 | 55 | #endif // CUDA_INIT_OPENGL 56 | 57 | #endif // __cuda_drvapi_dynlink_cuda_gl_h__ 58 | 59 | -------------------------------------------------------------------------------- /common/inc/cutil_gl_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* 13 | * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 14 | * 15 | * Please refer to the NVIDIA end user license agreement (EULA) associated 16 | * with this source code for terms and conditions that govern your use of 17 | * this software. Any use, reproduction, disclosure, or distribution of 18 | * this software and related documentation outside the terms of the EULA 19 | * is strictly prohibited. 20 | * 21 | */ 22 | 23 | #ifndef CUTIL_GL_ERROR 24 | #define CUTIL_GL_ERROR 25 | 26 | /* CUda UTility Library */ 27 | 28 | // includes, system 29 | #ifdef _WIN32 30 | # define WINDOWS_LEAN_AND_MEAN 31 | # include 32 | # include 33 | # undef min 34 | # undef max 35 | #endif 36 | 37 | // includes, graphics 38 | #if defined (__APPLE__) || defined(MACOSX) 39 | #include 40 | #include 41 | #else 42 | #include 43 | #include 44 | #endif 45 | 46 | //////////////////////////////////////////////////////////////////////////// 47 | //! Check for OpenGL error 48 | //! @return CUTTrue if no GL error has been encountered, otherwise 0 49 | //! @param file __FILE__ macro 50 | //! @param line __LINE__ macro 51 | //! @note The GL error is listed on stderr 52 | //! @note This function should be used via the CHECK_ERROR_GL() macro 53 | //////////////////////////////////////////////////////////////////////////// 54 | CUTBoolean CUTIL_API 55 | cutCheckErrorGL( const char* file, const int line) 56 | { 57 | CUTBoolean ret_val = CUTTrue; 58 | 59 | // check for error 60 | GLenum gl_error = glGetError(); 61 | if (gl_error != GL_NO_ERROR) 62 | { 63 | #ifdef _WIN32 64 | char tmpStr[512]; 65 | // NOTE: "%s(%i) : " allows Visual Studio to directly jump to the file at the right line 66 | // when the user double clicks on the error line in the Output pane. Like any compile error. 67 | sprintf_s(tmpStr, 255, "\n%s(%i) : GL Error : %s\n\n", file, line, gluErrorString(gl_error)); 68 | OutputDebugString(tmpStr); 69 | #endif 70 | fprintf(stderr, "GL Error in file '%s' in line %d :\n", file, line); 71 | fprintf(stderr, "%s\n", gluErrorString(gl_error)); 72 | ret_val = CUTFalse; 73 | } 74 | return ret_val; 75 | } 76 | 77 | #ifdef _DEBUG 78 | 79 | #define CUT_CHECK_ERROR_GL() \ 80 | if( CUTFalse == cutCheckErrorGL( __FILE__, __LINE__)) { \ 81 | exit(EXIT_FAILURE); \ 82 | } 83 | // Use this one to do : if(CUT_GL_HAS_ERROR) 84 | #define CUT_GL_HAS_ERROR (cutCheckErrorGL( __FILE__, __LINE__) ? CUTFalse : CUTTrue ) 85 | #ifdef _WIN32 86 | #define CUT_CHECK_ERROR_GL2()\ 87 | if(CUT_GL_HAS_ERROR)\ 88 | {\ 89 | MessageBox(NULL, "Error in OpenGL. Check VStudio Output...", "Error", MB_OK);\ 90 | exit(EXIT_FAILURE);\ 91 | } 92 | #else // Not _WIN32: 93 | #define CUT_CHECK_ERROR_GL2()\ 94 | if(CUT_GL_HAS_ERROR)\ 95 | {\ 96 | printf("press a key...\n");\ 97 | getc(stdin);\ 98 | exit(EXIT_FAILURE);\ 99 | } 100 | #endif 101 | 102 | #else 103 | 104 | #define CUT_CHECK_ERROR_GL() 105 | #define CUT_CHECK_ERROR_GL2() 106 | #define CUT_GL_HAS_ERROR CUTFalse 107 | 108 | #endif // _DEBUG 109 | 110 | #endif // CUTIL_GL_ERROR 111 | -------------------------------------------------------------------------------- /common/inc/cutil_gl_inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 _CUTIL_GL_INLINE_H_ 13 | #define _CUTIL_GL_INLINE_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | #if __DEVICE_EMULATION__ 27 | inline int cutilGLDeviceInit(int ARGC, char **ARGV) { return 0; } 28 | inline int cutilGLDeviceInitDrv(int cuDevice, int ARGC, char **ARGV) { return 0; } 29 | inline void cutilChooseCudaGLDevice(int ARGC, char **ARGV) { } 30 | #else 31 | inline int cutilGLDeviceInit(int ARGC, char **ARGV) 32 | { 33 | int deviceCount; 34 | cutilSafeCallNoSync(cudaGetDeviceCount(&deviceCount)); 35 | if (deviceCount == 0) { 36 | fprintf(stderr, "CUTIL CUDA error: no devices supporting CUDA.\n"); 37 | exit(-1); 38 | } 39 | int dev = 0; 40 | cutGetCmdLineArgumenti(ARGC, (const char **) ARGV, "device", &dev); 41 | if (dev < 0) 42 | dev = 0; 43 | if (dev > deviceCount-1) { 44 | fprintf(stderr, "cutilDeviceInit (Device=%d) invalid GPU device. %d GPU device(s) detected.\n\n", dev, deviceCount); 45 | return -dev; 46 | } 47 | cudaDeviceProp deviceProp; 48 | cutilSafeCallNoSync(cudaGetDeviceProperties(&deviceProp, dev)); 49 | if (deviceProp.major < 1) { 50 | fprintf(stderr, "cutil error: device does not support CUDA.\n"); 51 | exit(-1); \ 52 | } 53 | if (cutCheckCmdLineFlag(ARGC, (const char **) ARGV, "quiet") == CUTFalse) 54 | fprintf(stderr, "Using device %d: %s\n", dev, deviceProp.name); 55 | cutilSafeCall(cudaGLSetGLDevice(dev)); 56 | return dev; 57 | } 58 | 59 | inline int cutilGLDeviceInitDrv(int cuDevice, int ARGC, char ** ARGV) 60 | { 61 | cuDevice = 0; 62 | int deviceCount = 0; 63 | CUresult err = cuInit(0); 64 | if (CUDA_SUCCESS == err) 65 | cutilDrvSafeCallNoSync(cuDeviceGetCount(&deviceCount)); 66 | if (deviceCount == 0) { 67 | fprintf(stderr, "CUTIL DeviceInitDrv error: no devices supporting CUDA\n"); 68 | exit(-1); 69 | } 70 | 71 | int dev = 0; 72 | cutGetCmdLineArgumenti(ARGC, (const char **) ARGV, "device", &dev); 73 | if (dev < 0) 74 | dev = 0; 75 | if (dev > deviceCount-1) { 76 | fprintf(stderr, "cutilDeviceInit (Device=%d) invalid GPU device. %d GPU device(s) detected.\n\n", dev, deviceCount); 77 | return -dev; 78 | } 79 | cutilDrvSafeCallNoSync(cuDeviceGet(&cuDevice, dev)); 80 | char name[100]; 81 | cuDeviceGetName(name, 100, cuDevice); 82 | if (cutCheckCmdLineFlag(ARGC, (const char **) ARGV, "quiet") == CUTFalse) { 83 | fprintf(stderr, "Using device %d: %s\n", dev, name); 84 | } 85 | return dev; 86 | } 87 | 88 | // This function will pick the best CUDA device available with OpenGL interop 89 | inline int cutilChooseCudaGLDevice(int argc, char **argv) 90 | { 91 | int devID = 0; 92 | // If the command-line has a device number specified, use it 93 | if( cutCheckCmdLineFlag(argc, (const char**)argv, "device") ) { 94 | devID = cutilGLDeviceInit(argc, argv); 95 | if (devID < 0) { 96 | printf("exiting...\n"); 97 | cutilExit(argc, argv); 98 | exit(0); 99 | } 100 | } else { 101 | // Otherwise pick the device with highest Gflops/s 102 | devID = cutGetMaxGflopsDeviceId(); 103 | cudaGLSetGLDevice( devID ); 104 | } 105 | return devID; 106 | } 107 | 108 | #endif 109 | 110 | #endif // _CUTIL_GL_INLINE_H_ 111 | -------------------------------------------------------------------------------- /common/inc/cutil_inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 _CUTIL_INLINE_H_ 13 | #define _CUTIL_INLINE_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | inline void print_NVCC_min_spec(const char *sSDKsample, const char *sNVCCReq, const char *sDriverReq) 24 | { 25 | printf("CUDA %d.%02d Toolkit built this project.\n", CUDART_VERSION/1000, (CUDART_VERSION%100)); 26 | printf(" [ %s ] requirements:\n", sSDKsample); 27 | printf(" -> CUDA %s Toolkit\n" , sNVCCReq); 28 | printf(" -> %s NVIDIA Display Driver.\n", sDriverReq); 29 | } 30 | 31 | #define ALIGN_OFFSET(offset, alignment) offset = (offset + (alignment-1)) & ~((alignment-1)) 32 | 33 | 34 | #endif // _CUTIL_INLINE_H_ 35 | -------------------------------------------------------------------------------- /common/inc/cutil_inline_bankchecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 _CUTIL_INLINE_BANKCHECKER_H_ 13 | #define _CUTIL_INLINE_BANKCHECKER_H_ 14 | 15 | #ifdef _DEBUG 16 | #if __DEVICE_EMULATION__ 17 | #define cutilBankChecker(array, idx) (__cutilBankChecker (threadIdx.x, threadIdx.y, threadIdx.z, \ 18 | blockDim.x, blockDim.y, blockDim.z, \ 19 | #array, idx, __FILE__, __LINE__), \ 20 | array[idx]) 21 | 22 | #else 23 | #define cutilBankChecker(array, idx) array[idx] 24 | #endif 25 | #else 26 | #define cutilBankChecker(array, idx) array[idx] 27 | #endif 28 | 29 | // Interface for bank conflict checker 30 | inline void __cutilBankChecker(unsigned int tidx, unsigned int tidy, unsigned int tidz, 31 | unsigned int bdimx, unsigned int bdimy, unsigned int bdimz, 32 | char *aname, int index, char *file, int line) 33 | { 34 | cutCheckBankAccess( tidx, tidy, tidz, bdimx, bdimy, bdimz, file, line, aname, index); 35 | } 36 | 37 | #endif // _CUTIL_INLINE_BANKCHECKER_H_ 38 | -------------------------------------------------------------------------------- /common/inc/dynlink/common_functions_dynlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | #if !defined(__COMMON_FUNCTIONS_H__) 13 | #define __COMMON_FUNCTIONS_H__ 14 | 15 | /******************************************************************************* 16 | * * 17 | * * 18 | * * 19 | *******************************************************************************/ 20 | 21 | #if defined(__cplusplus) && defined(__CUDACC__) 22 | 23 | #include "host_defines.h" 24 | 25 | #include 26 | #include 27 | 28 | extern "C" 29 | { 30 | 31 | /*DEVICE_BUILTIN*/ 32 | extern __host__ __device__ clock_t clock(void) __THROW; 33 | 34 | /*DEVICE_BUILTIN*/ 35 | extern __host__ __device__ void *memset(void *s, int c, size_t n) __THROW; 36 | 37 | /*DEVICE_BUILTIN*/ 38 | extern __host__ __device__ void *memcpy(void *d, const void *s, size_t n) __THROW; 39 | 40 | } 41 | 42 | #elif !defined(__CUDACC__) 43 | 44 | #include "crt/func_macro.h" 45 | 46 | __device_func__(clock_t __cuda_clock(void)) 47 | { 48 | return clock(); 49 | } 50 | 51 | __device_func__(void *__cuda_memset(void *s, int c, size_t n)) 52 | { 53 | return memset(s, c, n); 54 | } 55 | 56 | __device_func__(void *__cuda_memcpy(void *d, const void *s, size_t n)) 57 | { 58 | return memcpy(d, s, n); 59 | } 60 | 61 | #endif /* __cplusplus && __CUDACC__ */ 62 | 63 | /******************************************************************************* 64 | * * 65 | * * 66 | * * 67 | *******************************************************************************/ 68 | 69 | #include "math_functions_dynlink.h" 70 | 71 | #endif /* !__COMMON_FUNCTIONS_H__ */ 72 | 73 | -------------------------------------------------------------------------------- /common/inc/dynlink/cuda_drvapi_dynlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | 13 | #ifndef __cuda_drvapi_dynlink_h__ 14 | #define __cuda_drvapi_dynlink_h__ 15 | 16 | #include "cuda_drvapi_dynlink_cuda.h" 17 | 18 | #if defined(CUDA_INIT_D3D9)||defined(CUDA_INIT_D3D10)||defined(CUDA_INIT_D3D11) 19 | #include "cuda_drvapi_dynlink_d3d.h" 20 | #endif 21 | 22 | #ifdef CUDA_INIT_OPENGL 23 | #include "cuda_drvapi_dynlink_gl.h" 24 | #endif 25 | 26 | #endif //__cuda_drvapi_dynlink_h__ 27 | -------------------------------------------------------------------------------- /common/inc/dynlink/cuda_drvapi_dynlink_d3d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 __cuda_drvapi_dynlink_d3d_h__ 13 | #define __cuda_drvapi_dynlink_d3d_h__ 14 | 15 | #if defined(_WIN32) 16 | #pragma warning(disable: 4312) 17 | 18 | #if defined (CUDA_INIT_D3D9) || defined(CUDA_INIT_D3D10) || defined(CUDA_INIT_D3D11) 19 | #include 20 | #include 21 | #endif 22 | 23 | #ifdef CUDA_INIT_D3D9 24 | #include 25 | #pragma warning( disable : 4996 ) // disable deprecated warning 26 | #include 27 | #pragma warning( default : 4996 ) 28 | 29 | /** 30 | * CUDA 2.x compatibility - Flags to register a D3D9 graphics resource 31 | */ 32 | typedef enum CUd3d9register_flags_enum { 33 | CU_D3D9_REGISTER_FLAGS_NONE = 0x00, 34 | CU_D3D9_REGISTER_FLAGS_ARRAY = 0x01, 35 | } CUd3d9register_flags; 36 | 37 | /** 38 | * CUDA 2.x compatibility - Flags for D3D9 mapping and unmapping interop resources 39 | */ 40 | typedef enum CUd3d9map_flags_enum { 41 | CU_D3D9_MAPRESOURCE_FLAGS_NONE = 0x00, 42 | CU_D3D9_MAPRESOURCE_FLAGS_READONLY = 0x01, 43 | CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD = 0x02, 44 | } CUd3d9map_flags; 45 | 46 | // D3D9/CUDA interop (CUDA 1.x compatible API). These functions are deprecated, please use the ones below 47 | typedef CUresult CUDAAPI tcuD3D9Begin( IDirect3DDevice9 *pDevice ); 48 | typedef CUresult CUDAAPI tcuD3D9End( void ); 49 | typedef CUresult CUDAAPI tcuD3D9RegisterVertexBuffer( IDirect3DVertexBuffer9 *pVB ); 50 | typedef CUresult CUDAAPI tcuD3D9MapVertexBuffer( CUdeviceptr *pDevPtr, unsigned int *pSize, IDirect3DVertexBuffer9 *pVB ); 51 | typedef CUresult CUDAAPI tcuD3D9UnmapVertexBuffer( IDirect3DVertexBuffer9 *pVB ); 52 | typedef CUresult CUDAAPI tcuD3D9UnregisterVertexBuffer( IDirect3DVertexBuffer9 *pVB ); 53 | 54 | // D3D9/CUDA interop (CUDA 2.x compatible) 55 | typedef CUresult CUDAAPI tcuD3D9GetDirect3DDevice( IDirect3DDevice9 **ppD3DDevice ); 56 | typedef CUresult CUDAAPI tcuD3D9RegisterResource( IDirect3DResource9 *pResource, unsigned int Flags ); 57 | typedef CUresult CUDAAPI tcuD3D9UnregisterResource( IDirect3DResource9 *pResource ); 58 | 59 | typedef CUresult CUDAAPI tcuD3D9MapResources( unsigned int count, IDirect3DResource9 **ppResource ); 60 | typedef CUresult CUDAAPI tcuD3D9UnmapResources( unsigned int count, IDirect3DResource9 **ppResource ); 61 | typedef CUresult CUDAAPI tcuD3D9ResourceSetMapFlags( IDirect3DResource9 *pResource, unsigned int Flags ); 62 | 63 | typedef CUresult CUDAAPI tcuD3D9ResourceGetSurfaceDimensions( unsigned int *pWidth, unsigned int *pHeight, unsigned int *pDepth, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 64 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedArray( CUarray *pArray, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 65 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedPointer( CUdeviceptr *pDevPtr, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 66 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedSize( unsigned int *pSize, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 67 | typedef CUresult CUDAAPI tcuD3D9ResourceGetMappedPitch( unsigned int *pPitch, unsigned int *pPitchSlice, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level ); 68 | 69 | // D3D9/CUDA interop (CUDA 2.0+) 70 | typedef CUresult CUDAAPI tcuD3D9GetDevice( CUdevice *pCudaDevice, const char *pszAdapterName); 71 | typedef CUresult CUDAAPI tcuD3D9CtxCreate( CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, IDirect3DDevice9 *pD3DDevice ); 72 | typedef CUresult CUDAAPI tcuGraphicsD3D9RegisterResource( CUgraphicsResource *pCudaResource, IDirect3DResource9 *pD3DResource, unsigned int Flags ); 73 | #endif 74 | 75 | #ifdef CUDA_INIT_D3D10 76 | #include 77 | #include 78 | #include 79 | #include 80 | 81 | #pragma warning( disable : 4996 ) // disable deprecated warning 82 | #include 83 | #pragma warning( default : 4996 ) 84 | 85 | // D3D11/CUDA interop (CUDA 3.0) 86 | typedef CUresult CUDAAPI tcuD3D10GetDevice( CUdevice *pCudaDevice, IDXGIAdapter *pAdapter ); 87 | typedef CUresult CUDAAPI tcuD3D10CtxCreate( CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D10Device *pD3DDevice ); 88 | typedef CUresult CUDAAPI tcuGraphicsD3D10RegisterResource( CUgraphicsResource *pCudaResource, ID3D10Resource *pD3DResource, unsigned int Flags ); 89 | #endif // CUDA_INIT_D3D10 90 | 91 | #ifdef CUDA_INIT_D3D11 92 | #include 93 | #include 94 | #include 95 | 96 | #pragma warning( disable : 4996 ) // disable deprecated warning 97 | #include 98 | #pragma warning( default : 4996 ) 99 | 100 | // D3D11/CUDA interop (CUDA 3.0) 101 | typedef CUresult CUDAAPI tcuD3D11GetDevice( CUdevice *pCudaDevice, IDXGIAdapter *pAdapter ); 102 | typedef CUresult CUDAAPI tcuD3D11CtxCreate( CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D11Device *pD3DDevice ); 103 | typedef CUresult CUDAAPI tcuGraphicsD3D11RegisterResource( CUgraphicsResource *pCudaResource, ID3D11Resource *pD3DResource, unsigned int Flags ); 104 | #endif // CUDA_INIT_D3D11 105 | 106 | #endif // WIN32 107 | 108 | #endif // __cuda_drvapi_dynlink_cuda_d3d_h__ 109 | -------------------------------------------------------------------------------- /common/inc/dynlink/cuda_drvapi_dynlink_gl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 __cuda_drvapi_dynlink_cuda_gl_h__ 13 | #define __cuda_drvapi_dynlink_cuda_gl_h__ 14 | 15 | #ifdef CUDA_INIT_OPENGL 16 | 17 | #ifdef _WIN32 18 | # define WINDOWS_LEAN_AND_MEAN 19 | # define NOMINMAX 20 | # include 21 | #endif 22 | 23 | // includes, system 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // includes, GL 30 | #include 31 | 32 | #if defined (__APPLE__) || defined(MACOSX) 33 | #include 34 | #else 35 | #include 36 | #endif 37 | 38 | /************************************ 39 | ** 40 | ** OpenGL Graphics/Interop 41 | ** 42 | ***********************************/ 43 | 44 | // OpenGL/CUDA interop (CUDA 2.0+) 45 | typedef CUresult CUDAAPI tcuGLCtxCreate( CUcontext *pCtx, unsigned int Flags, CUdevice device ); 46 | typedef CUresult CUDAAPI tcuGraphicsGLRegisterBuffer( CUgraphicsResource *pCudaResource, GLuint buffer, unsigned int Flags ); 47 | typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage( CUgraphicsResource *pCudaResource, GLuint image, GLenum target, unsigned int Flags ); 48 | 49 | #ifdef _WIN32 50 | #include 51 | // WIN32 52 | typedef CUresult CUDAAPI tcuWGLGetDevice( CUdevice *pDevice, HGPUNV hGpu ); 53 | #endif 54 | 55 | #endif // CUDA_INIT_OPENGL 56 | 57 | #endif // __cuda_drvapi_dynlink_cuda_gl_h__ 58 | 59 | -------------------------------------------------------------------------------- /common/inc/dynlink/cuda_texture_types_dynlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | #if !defined(__CUDA_TEXTURE_TYPES_H__) 13 | #define __CUDA_TEXTURE_TYPES_H__ 14 | 15 | #if defined(__cplusplus) && defined(__CUDACC__) 16 | 17 | /******************************************************************************* 18 | * * 19 | * * 20 | * * 21 | *******************************************************************************/ 22 | 23 | #include "channel_descriptor_dynlink.h" 24 | #include "driver_types.h" 25 | #include "host_defines.h" 26 | #include "texture_types.h" 27 | 28 | /******************************************************************************* 29 | * * 30 | * * 31 | * * 32 | *******************************************************************************/ 33 | 34 | /*TEXTURE_TYPE*/ 35 | template 36 | struct texture : public textureReference 37 | { 38 | __host__ texture(int norm = 0, 39 | enum cudaTextureFilterMode fMode = cudaFilterModePoint, 40 | enum cudaTextureAddressMode aMode = cudaAddressModeClamp) 41 | { 42 | normalized = norm; 43 | filterMode = fMode; 44 | addressMode[0] = aMode; 45 | addressMode[1] = aMode; 46 | addressMode[2] = aMode; 47 | channelDesc = cudaCreateChannelDesc(); 48 | } 49 | 50 | __host__ texture(int norm, 51 | enum cudaTextureFilterMode fMode, 52 | enum cudaTextureAddressMode aMode, 53 | struct cudaChannelFormatDesc desc) 54 | { 55 | normalized = norm; 56 | filterMode = fMode; 57 | addressMode[0] = aMode; 58 | addressMode[1] = aMode; 59 | addressMode[2] = aMode; 60 | channelDesc = desc; 61 | } 62 | }; 63 | 64 | #endif /* __cplusplus && __CUDACC__ */ 65 | 66 | #endif /* !__CUDA_TEXTURE_TYPES_H__ */ 67 | -------------------------------------------------------------------------------- /common/inc/dynlink_d3d11.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | //-------------------------------------------------------------------------------------- 13 | // File: dynlink_d3d11.h 14 | // 15 | // Shortcut macros and functions for using DX objects 16 | // 17 | // Copyright (c) Microsoft Corporation. All rights reserved 18 | //-------------------------------------------------------------------------------------- 19 | 20 | #ifndef _DYNLINK_D3D11_H_ 21 | #define _DYNLINK_D3D11_H_ 22 | 23 | // Standard Windows includes 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include // for InitCommonControls() 30 | #include // for ExtractIcon() 31 | #include // for placement new 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | // CRT's memory leak detection 38 | #if defined(DEBUG) || defined(_DEBUG) 39 | #include 40 | #endif 41 | 42 | // Direct3D9 includes 43 | //#include 44 | //#include 45 | 46 | // Direct3D10 includes 47 | #include 48 | #include 49 | #include 50 | 51 | // XInput includes 52 | #include 53 | 54 | // HRESULT translation for Direct3D10 and other APIs 55 | #include 56 | 57 | // strsafe.h deprecates old unsecure string functions. If you 58 | // really do not want to it to (not recommended), then uncomment the next line 59 | //#define STRSAFE_NO_DEPRECATE 60 | 61 | #ifndef STRSAFE_NO_DEPRECATE 62 | #pragma deprecated("strncpy") 63 | #pragma deprecated("wcsncpy") 64 | #pragma deprecated("_tcsncpy") 65 | #pragma deprecated("wcsncat") 66 | #pragma deprecated("strncat") 67 | #pragma deprecated("_tcsncat") 68 | #endif 69 | 70 | #pragma warning( disable : 4996 ) // disable deprecated warning 71 | #include 72 | #pragma warning( default : 4996 ) 73 | 74 | typedef HRESULT (WINAPI * LPCREATEDXGIFACTORY)(REFIID, void ** ); 75 | typedef HRESULT (WINAPI * LPD3D11CREATEDEVICEANDSWAPCHAIN)(__in_opt IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, __in_ecount_opt( FeatureLevels ) CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, __in_opt CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, __out_opt IDXGISwapChain** ppSwapChain, __out_opt ID3D11Device** ppDevice, __out_opt D3D_FEATURE_LEVEL* pFeatureLevel, __out_opt ID3D11DeviceContext** ppImmediateContext ); 76 | typedef HRESULT (WINAPI * LPD3D11CREATEDEVICE)( IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, UINT32, D3D_FEATURE_LEVEL*, UINT, UINT32, ID3D11Device**, D3D_FEATURE_LEVEL*, ID3D11DeviceContext** ); 77 | typedef void (WINAPI * LPD3DX11COMPILEFROMMEMORY)(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, 78 | LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult); 79 | 80 | static HMODULE s_hModDXGI = NULL; 81 | static LPCREATEDXGIFACTORY sFnPtr_CreateDXGIFactory = NULL; 82 | static HMODULE s_hModD3D11 = NULL; 83 | static HMODULE s_hModD3DX11 = NULL; 84 | static LPD3D11CREATEDEVICE sFnPtr_D3D11CreateDevice = NULL; 85 | static LPD3D11CREATEDEVICEANDSWAPCHAIN sFnPtr_D3D11CreateDeviceAndSwapChain = NULL; 86 | static LPD3DX11COMPILEFROMMEMORY sFnPtr_D3DX11CompileFromMemory = NULL; 87 | 88 | // unload the D3D10 DLLs 89 | static bool dynlinkUnloadD3D11API( void ) 90 | { 91 | if (s_hModDXGI) { 92 | FreeLibrary( s_hModDXGI ); s_hModDXGI = NULL; 93 | } 94 | if (s_hModD3D11) { 95 | FreeLibrary( s_hModD3D11 ); s_hModD3D11 = NULL; 96 | } 97 | if (s_hModD3DX11) { 98 | FreeLibrary( s_hModD3DX11 ); s_hModD3DX11 = NULL; 99 | } 100 | return true; 101 | } 102 | 103 | // Dynamically load the D3D11 DLLs loaded and map the function pointers 104 | static bool dynlinkLoadD3D11API( void ) 105 | { 106 | // If both modules are non-NULL, this function has already been called. Note 107 | // that this doesn't guarantee that all ProcAddresses were found. 108 | if( s_hModD3D11 != NULL && s_hModD3DX11 != NULL && s_hModDXGI != NULL ) 109 | return true; 110 | 111 | #if 1 112 | // This may fail if Direct3D 11 isn't installed 113 | s_hModD3D11 = LoadLibrary( "d3d11.dll" ); 114 | if( s_hModD3D11 != NULL ) 115 | { 116 | sFnPtr_D3D11CreateDevice = ( LPD3D11CREATEDEVICE )GetProcAddress( s_hModD3D11, "D3D11CreateDevice" ); 117 | sFnPtr_D3D11CreateDeviceAndSwapChain = (LPD3D11CREATEDEVICEANDSWAPCHAIN)GetProcAddress( s_hModD3D11, "D3D11CreateDeviceAndSwapChain" ); 118 | } 119 | 120 | s_hModD3DX11 = LoadLibrary( "D3DX11d_42.dll" ); 121 | if( s_hModD3DX11 != NULL ) 122 | { 123 | sFnPtr_D3DX11CompileFromMemory = ( LPD3DX11COMPILEFROMMEMORY ) GetProcAddress( s_hModD3DX11, "D3DX11CompileFromMemory" ); 124 | } 125 | 126 | if( !sFnPtr_CreateDXGIFactory ) 127 | { 128 | s_hModDXGI = LoadLibrary( "dxgi.dll" ); 129 | if( s_hModDXGI ) 130 | { 131 | sFnPtr_CreateDXGIFactory = ( LPCREATEDXGIFACTORY )GetProcAddress( s_hModDXGI, "CreateDXGIFactory1" ); 132 | } 133 | 134 | return ( s_hModDXGI != NULL ) && ( s_hModD3D11 != NULL ); 135 | } 136 | 137 | return ( s_hModD3D11 != NULL ); 138 | #else 139 | sFnPtr_D3D11CreateDevice = ( LPD3D11CREATEDEVICE )D3D11CreateDeviceAndSwapChain; 140 | sFnPtr_D3D11CreateDeviceAndSwapChain = (LPD3D11CREATEDEVICEANDSWAPCHAIN)D3D11CreateDeviceAndSwapChain; 141 | //sFnPtr_D3DX11CreateEffectFromMemory = ( LPD3DX11CREATEEFFECTFROMMEMORY )D3DX11CreateEffectFromMemory; 142 | sFnPtr_D3DX11CompileFromMemory = ( LPD3DX11COMPILEFROMMEMORY )D3DX11CompileFromMemory; 143 | sFnPtr_CreateDXGIFactory = ( LPCREATEDXGIFACTORY )CreateDXGIFactory; 144 | return true; 145 | #endif 146 | return true; 147 | } 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /common/inc/error_checker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* CUda UTility Library */ 13 | 14 | #ifndef _ERRORCHECKER_H_ 15 | #define _ERRORCHECKER_H_ 16 | 17 | // includes, system 18 | #include 19 | #include 20 | 21 | // includes, project 22 | #include 23 | 24 | // typedefs 25 | //typedef unsigned int GLuint; 26 | 27 | //! Class providing the handler / tester functions for errors as static members 28 | class ErrorChecker 29 | { 30 | public: 31 | //! Check if a condition is true. 32 | //! @note In prinicple has the same functionality as assert but allows 33 | //! much better control this version prints an error and terminates 34 | //! the program, no exception is thrown. 35 | inline static void condition( bool val, const char* file, const int line); 36 | }; 37 | 38 | // functions, inlined 39 | 40 | // includes, system 41 | #include 42 | 43 | //////////////////////////////////////////////////////////////////////////////// 44 | //! Check if a condition is true. 45 | //! @note In prinicple has the same functionality as assert but allows much 46 | //! better control this version prints an error and terminates the 47 | //! program, no exception is thrown. 48 | //////////////////////////////////////////////////////////////////////////////// 49 | /* static */ inline void 50 | ErrorChecker::condition( bool val, const char* file, const int line) 51 | { 52 | if ( ! val) 53 | { 54 | std::ostringstream os; 55 | os << "Condition failed: " << file << " in line " << line; 56 | RUNTIME_EXCEPTION( os.str() ); 57 | } 58 | } 59 | 60 | #endif // _ERRORCHECKER_H_ 61 | 62 | -------------------------------------------------------------------------------- /common/inc/exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* CUda UTility Library */ 13 | #ifndef _EXCEPTION_H_ 14 | #define _EXCEPTION_H_ 15 | 16 | // includes, system 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | //! Exception wrapper. 23 | //! @param Std_Exception Exception out of namespace std for easy typing. 24 | template 25 | class Exception : public Std_Exception 26 | { 27 | public: 28 | 29 | //! @brief Static construction interface 30 | //! @return Alwayss throws ( Located_Exception) 31 | //! @param file file in which the Exception occurs 32 | //! @param line line in which the Exception occurs 33 | //! @param detailed details on the code fragment causing the Exception 34 | static void throw_it( const char* file, 35 | const int line, 36 | const char* detailed = "-" ); 37 | 38 | //! Static construction interface 39 | //! @return Alwayss throws ( Located_Exception) 40 | //! @param file file in which the Exception occurs 41 | //! @param line line in which the Exception occurs 42 | //! @param detailed details on the code fragment causing the Exception 43 | static void throw_it( const char* file, 44 | const int line, 45 | const std::string& detailed); 46 | 47 | //! Destructor 48 | virtual ~Exception() throw(); 49 | 50 | private: 51 | 52 | //! Constructor, default (private) 53 | Exception(); 54 | 55 | //! Constructor, standard 56 | //! @param str string returned by what() 57 | Exception( const std::string& str); 58 | 59 | }; 60 | 61 | //////////////////////////////////////////////////////////////////////////////// 62 | //! Exception handler function for arbitrary exceptions 63 | //! @param ex exception to handle 64 | //////////////////////////////////////////////////////////////////////////////// 65 | template 66 | inline void 67 | handleException( const Exception_Typ& ex) 68 | { 69 | std::cerr << ex.what() << std::endl; 70 | 71 | exit( EXIT_FAILURE); 72 | } 73 | 74 | //! Convenience macros 75 | 76 | //! Exception caused by dynamic program behavior, e.g. file does not exist 77 | #define RUNTIME_EXCEPTION( msg) \ 78 | Exception::throw_it( __FILE__, __LINE__, msg) 79 | 80 | //! Logic exception in program, e.g. an assert failed 81 | #define LOGIC_EXCEPTION( msg) \ 82 | Exception::throw_it( __FILE__, __LINE__, msg) 83 | 84 | //! Out of range exception 85 | #define RANGE_EXCEPTION( msg) \ 86 | Exception::throw_it( __FILE__, __LINE__, msg) 87 | 88 | //////////////////////////////////////////////////////////////////////////////// 89 | //! Implementation 90 | 91 | // includes, system 92 | #include 93 | 94 | //////////////////////////////////////////////////////////////////////////////// 95 | //! Static construction interface. 96 | //! @param Exception causing code fragment (file and line) and detailed infos. 97 | //////////////////////////////////////////////////////////////////////////////// 98 | /*static*/ template 99 | void 100 | Exception:: 101 | throw_it( const char* file, const int line, const char* detailed) 102 | { 103 | std::stringstream s; 104 | 105 | // Quiet heavy-weight but exceptions are not for 106 | // performance / release versions 107 | s << "Exception in file '" << file << "' in line " << line << "\n" 108 | << "Detailed description: " << detailed << "\n"; 109 | 110 | throw Exception( s.str()); 111 | } 112 | 113 | //////////////////////////////////////////////////////////////////////////////// 114 | //! Static construction interface. 115 | //! @param Exception causing code fragment (file and line) and detailed infos. 116 | //////////////////////////////////////////////////////////////////////////////// 117 | /*static*/ template 118 | void 119 | Exception:: 120 | throw_it( const char* file, const int line, const std::string& msg) 121 | { 122 | throw_it( file, line, msg.c_str()); 123 | } 124 | 125 | //////////////////////////////////////////////////////////////////////////////// 126 | //! Constructor, default (private). 127 | //////////////////////////////////////////////////////////////////////////////// 128 | template 129 | Exception::Exception() : 130 | Exception("Unknown Exception.\n") 131 | { } 132 | 133 | //////////////////////////////////////////////////////////////////////////////// 134 | //! Constructor, standard (private). 135 | //! String returned by what(). 136 | //////////////////////////////////////////////////////////////////////////////// 137 | template 138 | Exception::Exception( const std::string& s) : 139 | Std_Exception( s) 140 | { } 141 | 142 | //////////////////////////////////////////////////////////////////////////////// 143 | //! Destructor 144 | //////////////////////////////////////////////////////////////////////////////// 145 | template 146 | Exception::~Exception() throw() { } 147 | 148 | // functions, exported 149 | 150 | #endif // #ifndef _EXCEPTION_H_ 151 | 152 | -------------------------------------------------------------------------------- /common/inc/multithreading.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 MULTITHREADING_H 13 | #define MULTITHREADING_H 14 | 15 | 16 | //Simple portable thread library. 17 | 18 | #if _WIN32 19 | //Windows threads. 20 | #include 21 | 22 | typedef HANDLE CUTThread; 23 | typedef unsigned (WINAPI *CUT_THREADROUTINE)(void *); 24 | 25 | #define CUT_THREADPROC unsigned WINAPI 26 | #define CUT_THREADEND return 0 27 | 28 | #else 29 | //POSIX threads. 30 | #include 31 | 32 | typedef pthread_t CUTThread; 33 | typedef void *(*CUT_THREADROUTINE)(void *); 34 | 35 | #define CUT_THREADPROC void 36 | #define CUT_THREADEND 37 | #endif 38 | 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | //Create thread. 45 | CUTThread cutStartThread(CUT_THREADROUTINE, void *data); 46 | 47 | //Wait for thread to finish. 48 | void cutEndThread(CUTThread thread); 49 | 50 | //Destroy thread. 51 | void cutDestroyThread(CUTThread thread); 52 | 53 | //Wait for multiple threads. 54 | void cutWaitForThreads(const CUTThread *threads, int num); 55 | 56 | #ifdef __cplusplus 57 | } //extern "C" 58 | #endif 59 | 60 | #endif //MULTITHREADING_H 61 | -------------------------------------------------------------------------------- /common/inc/nvGlutWidgets.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | // 13 | // nvGlutWidgets 14 | // 15 | // Adaptor classes to integrate the nvWidgets UI library with the GLUT windowing 16 | // toolkit. The adaptors convert native GLUT UI data to native nvWidgets data. All 17 | // adaptor classes are implemented as in-line code in this header. The adaptor 18 | // defaults to using the standard OpenGL paintor implementation. 19 | // 20 | // Author: Ignacio Castano, Samuel Gateau, Evan Hart 21 | // Email: sdkfeedback@nvidia.com 22 | // 23 | // Copyright (c) NVIDIA Corporation. All rights reserved. 24 | //////////////////////////////////////////////////////////////////////////////////////////////////// 25 | 26 | #ifndef NV_GLUT_WIDGETS_H 27 | #define NV_GLUT_WIDGETS_H 28 | 29 | #include 30 | #include 31 | 32 | 33 | namespace nv { 34 | 35 | class GlutUIContext : public UIContext { 36 | 37 | protected: 38 | 39 | bool _ownPainter; 40 | 41 | public: 42 | 43 | // 44 | // Default UI constructor 45 | // 46 | // Creates private OpenGL painter 47 | ////////////////////////////////////////////////////////////////// 48 | GlutUIContext() : 49 | UIContext( *(new GLUIPainter()) ), 50 | _ownPainter(true) 51 | { 52 | } 53 | 54 | // 55 | // Alternate UI constructor 56 | // 57 | // Allows for overriding the standard painter 58 | ////////////////////////////////////////////////////////////////// 59 | GlutUIContext(UIPainter& painter) : 60 | UIContext( painter ), 61 | _ownPainter(false) 62 | { 63 | } 64 | 65 | // 66 | // UI destructor 67 | // 68 | // Destroy painter if it is private 69 | ////////////////////////////////////////////////////////////////// 70 | ~GlutUIContext() { 71 | if (_ownPainter) delete getPainter(); 72 | } 73 | 74 | // 75 | // UI method for processing GLUT mouse button events 76 | // 77 | // Call this method from the glutMouseFunc callback, the 78 | // modifier parameter maps to glutGetModifiers. 79 | ////////////////////////////////////////////////////////////////// 80 | virtual void mouse(int button, int state, int modifier, int x, int y) { 81 | int modifierMask = 0; 82 | 83 | if ( button == GLUT_LEFT_BUTTON) button = MouseButton_Left; 84 | else if ( button == GLUT_MIDDLE_BUTTON) button = MouseButton_Middle; 85 | else if ( button == GLUT_RIGHT_BUTTON) button = MouseButton_Right; 86 | 87 | if ( modifier & GLUT_ACTIVE_ALT) modifierMask |= ButtonFlags_Alt; 88 | if ( modifier & GLUT_ACTIVE_SHIFT) modifierMask |= ButtonFlags_Shift; 89 | if ( modifier & GLUT_ACTIVE_CTRL) modifierMask |= ButtonFlags_Ctrl; 90 | 91 | if ( state == GLUT_DOWN) state = 1; else state = 0; 92 | 93 | UIContext::mouse( button, state, modifierMask, x, y); 94 | } 95 | 96 | // 97 | // UI method for processing key events 98 | // 99 | // Call this method from the glutReshapeFunc callback 100 | ////////////////////////////////////////////////////////////////// 101 | void specialKeyboard(int k, int x, int y) { UIContext::keyboard( translateKey(k), x, y); } 102 | 103 | // 104 | // Translate non-ascii keys from GLUT to nvWidgets 105 | ////////////////////////////////////////////////////////////////// 106 | unsigned char translateKey( int k ) 107 | { 108 | switch (k) 109 | { 110 | case GLUT_KEY_F1 : 111 | return Key_F1; 112 | case GLUT_KEY_F2 : 113 | return Key_F2; 114 | case GLUT_KEY_F3 : 115 | return Key_F3; 116 | case GLUT_KEY_F4 : 117 | return Key_F4; 118 | case GLUT_KEY_F5 : 119 | return Key_F5; 120 | case GLUT_KEY_F6 : 121 | return Key_F6; 122 | case GLUT_KEY_F7 : 123 | return Key_F7; 124 | case GLUT_KEY_F8 : 125 | return Key_F8; 126 | case GLUT_KEY_F9 : 127 | return Key_F9; 128 | case GLUT_KEY_F10 : 129 | return Key_F10; 130 | case GLUT_KEY_F11 : 131 | return Key_F11; 132 | case GLUT_KEY_F12 : 133 | return Key_F12; 134 | case GLUT_KEY_LEFT : 135 | return Key_Left; 136 | case GLUT_KEY_UP : 137 | return Key_Up; 138 | case GLUT_KEY_RIGHT : 139 | return Key_Right; 140 | case GLUT_KEY_DOWN : 141 | return Key_Down; 142 | case GLUT_KEY_PAGE_UP : 143 | return Key_PageUp; 144 | case GLUT_KEY_PAGE_DOWN : 145 | return Key_PageDown; 146 | case GLUT_KEY_HOME : 147 | return Key_Home; 148 | case GLUT_KEY_END : 149 | return Key_End; 150 | case GLUT_KEY_INSERT : 151 | return Key_Insert; 152 | default: 153 | return 0; 154 | } 155 | } 156 | }; 157 | 158 | }; 159 | 160 | 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /common/inc/nvMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | // 13 | // Template math library for common 3D functionality 14 | // 15 | // This code is in part deriver from glh, a cross platform glut helper library. 16 | // The copyright for glh follows this notice. 17 | // 18 | // Copyright (c) NVIDIA Corporation. All rights reserved. 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | /* 22 | Copyright (c) 2000 Cass Everitt 23 | Copyright (c) 2000 NVIDIA Corporation 24 | All rights reserved. 25 | 26 | Redistribution and use in source and binary forms, with or 27 | without modification, are permitted provided that the following 28 | conditions are met: 29 | 30 | * Redistributions of source code must retain the above 31 | copyright notice, this list of conditions and the following 32 | disclaimer. 33 | 34 | * Redistributions in binary form must reproduce the above 35 | copyright notice, this list of conditions and the following 36 | disclaimer in the documentation and/or other materials 37 | provided with the distribution. 38 | 39 | * The names of contributors to this software may not be used 40 | to endorse or promote products derived from this software 41 | without specific prior written permission. 42 | 43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 44 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 45 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 46 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 47 | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 48 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 49 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 50 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 51 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 53 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 54 | POSSIBILITY OF SUCH DAMAGE. 55 | 56 | 57 | Cass Everitt - cass@r3.nu 58 | */ 59 | 60 | #ifndef NV_MATH_H 61 | #define NV_MATH_H 62 | 63 | #include 64 | 65 | #include 66 | #include 67 | #include 68 | 69 | #define NV_PI float(3.1415926535897932384626433832795) 70 | 71 | namespace nv { 72 | 73 | typedef vec2 vec2f; 74 | typedef vec3 vec3f; 75 | typedef vec3 vec3i; 76 | typedef vec3 vec3ui; 77 | typedef vec4 vec4f; 78 | typedef matrix4 matrix4f; 79 | typedef quaternion quaternionf; 80 | 81 | 82 | inline void applyRotation(const quaternionf & r) 83 | { 84 | float angle; 85 | vec3f axis; 86 | r.get_value(axis, angle); 87 | glRotatef( angle/3.1415926f * 180.0f, axis[0], axis[1], axis[2]); 88 | } 89 | 90 | 91 | 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /common/inc/nvShaderUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | // 13 | // Utility functions for compiling shaders and programs 14 | // 15 | // Author: Evan Hart 16 | // Copyright (c) NVIDIA Corporation. All rights reserved. 17 | //////////////////////////////////////////////////////////////////////////////// 18 | 19 | 20 | #ifndef NV_SHADER_UTILS_H 21 | #define NV_SHADER_UTILS_H 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | namespace nv 29 | { 30 | 31 | 32 | // 33 | // 34 | //////////////////////////////////////////////////////////// 35 | inline GLuint CompileGLSLShader( GLenum target, const char* shader) 36 | { 37 | GLuint object; 38 | 39 | object = glCreateShader( target); 40 | 41 | if (!object) 42 | return object; 43 | 44 | glShaderSource( object, 1, &shader, NULL); 45 | 46 | glCompileShader(object); 47 | 48 | // check if shader compiled 49 | GLint compiled = 0; 50 | glGetShaderiv(object, GL_COMPILE_STATUS, &compiled); 51 | 52 | if (!compiled) 53 | { 54 | #ifdef NV_REPORT_COMPILE_ERRORS 55 | char temp[256] = ""; 56 | glGetShaderInfoLog( object, 256, NULL, temp); 57 | fprintf( stderr, "Compile failed:\n%s\n", temp); 58 | #endif 59 | glDeleteShader( object); 60 | return 0; 61 | } 62 | 63 | return object; 64 | } 65 | 66 | // 67 | // 68 | //////////////////////////////////////////////////////////// 69 | inline GLuint CompileGLSLShaderFromFile( GLenum target, const char* filename) 70 | { 71 | FILE *shaderFile; 72 | char *text; 73 | long size; 74 | size_t fsize = 0; 75 | 76 | // read files as binary to prevent problems from newline translation 77 | #ifdef _WIN32 78 | if (fopen_s(&shaderFile, filename, "rb") != 0) 79 | #else 80 | if ((shaderFile = fopen(filename, "rb")) == 0) 81 | #endif 82 | { 83 | return 0; 84 | } 85 | 86 | // Get the length of the file 87 | fseek( shaderFile, 0, SEEK_END); 88 | size = ftell(shaderFile); 89 | 90 | // Read the file contents from the start, then close file and add a null terminator 91 | fseek( shaderFile, 0, SEEK_SET); 92 | text = new char[size+1]; 93 | fsize = fread( text, size, 1, shaderFile); 94 | fclose( shaderFile); 95 | if (fsize == 0) 96 | printf("CompileGLSLShaderFromFile(), error... fsize = 0\n"); 97 | 98 | text[size] = '\0'; 99 | 100 | GLuint object = CompileGLSLShader( target, text); 101 | 102 | delete []text; 103 | 104 | return object; 105 | } 106 | 107 | 108 | // Create a program composed of vertex and fragment shaders. 109 | inline GLuint LinkGLSLProgram( GLuint vertexShader, GLuint fragmentShader) 110 | { 111 | GLuint program = glCreateProgram(); 112 | glAttachShader(program, vertexShader); 113 | glAttachShader(program, fragmentShader); 114 | glLinkProgram(program); 115 | 116 | #ifdef NV_REPORT_COMPILE_ERRORS 117 | // Get error log. 118 | GLint charsWritten, infoLogLength; 119 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); 120 | 121 | char * infoLog = new char[infoLogLength]; 122 | glGetProgramInfoLog(program, infoLogLength, &charsWritten, infoLog); 123 | printf(infoLog); 124 | delete [] infoLog; 125 | #endif 126 | 127 | // Test linker result. 128 | GLint linkSucceed = GL_FALSE; 129 | glGetProgramiv(program, GL_LINK_STATUS, &linkSucceed); 130 | 131 | if (linkSucceed == GL_FALSE) 132 | { 133 | glDeleteProgram(program); 134 | return 0; 135 | } 136 | 137 | return program; 138 | } 139 | 140 | 141 | // Create a program composed of vertex, geometry and fragment shaders. 142 | inline GLuint LinkGLSLProgram( GLuint vertexShader, GLuint geometryShader, GLint inputType, GLint vertexOut, GLint outputType, GLuint fragmentShader) 143 | { 144 | GLuint program = glCreateProgram(); 145 | glAttachShader(program, vertexShader); 146 | glAttachShader(program, geometryShader); 147 | glProgramParameteriEXT(program, GL_GEOMETRY_INPUT_TYPE_EXT, inputType); 148 | glProgramParameteriEXT(program, GL_GEOMETRY_VERTICES_OUT_EXT, vertexOut); 149 | glProgramParameteriEXT(program, GL_GEOMETRY_OUTPUT_TYPE_EXT, outputType); 150 | glAttachShader(program, fragmentShader); 151 | glLinkProgram(program); 152 | 153 | #ifdef NV_REPORT_COMPILE_ERRORS 154 | // Get error log. 155 | GLint charsWritten, infoLogLength; 156 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); 157 | 158 | char * infoLog = new char[infoLogLength]; 159 | glGetProgramInfoLog(program, infoLogLength, &charsWritten, infoLog); 160 | printf(infoLog); 161 | delete [] infoLog; 162 | #endif 163 | 164 | // Test linker result. 165 | GLint linkSucceed = GL_FALSE; 166 | glGetProgramiv(program, GL_LINK_STATUS, &linkSucceed); 167 | 168 | if (linkSucceed == GL_FALSE) 169 | { 170 | glDeleteProgram(program); 171 | return 0; 172 | } 173 | 174 | return program; 175 | } 176 | 177 | // 178 | // 179 | //////////////////////////////////////////////////////////// 180 | inline GLuint CompileASMShader(GLenum program_type, const char *code) 181 | { 182 | GLuint program_id; 183 | glGenProgramsARB(1, &program_id); 184 | glBindProgramARB(program_type, program_id); 185 | glProgramStringARB(program_type, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei) strlen(code), (GLubyte *) code); 186 | 187 | GLint error_pos; 188 | glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_pos); 189 | if (error_pos != -1) { 190 | #ifdef NV_REPORT_COMPILE_ERRORS 191 | const GLubyte *error_string; 192 | error_string = glGetString(GL_PROGRAM_ERROR_STRING_ARB); 193 | fprintf(stderr, "Program error at position: %d\n%s\n", (int)error_pos, error_string); 194 | #endif 195 | return 0; 196 | } 197 | return program_id; 198 | } 199 | 200 | // 201 | // 202 | //////////////////////////////////////////////////////////// 203 | inline GLuint CompileASMShaderFromFile( GLenum target, const char* filename) 204 | { 205 | FILE *shaderFile; 206 | char *text; 207 | long size; 208 | size_t fsize = 0; 209 | 210 | // read files as binary to prevent problems from newline translation 211 | #ifdef _WIN32 212 | if (fopen_s(&shaderFile, filename, "rb") != 0) 213 | #else 214 | if ((shaderFile = fopen(filename, "rb")) == 0) 215 | #endif 216 | { 217 | return 0; 218 | } 219 | 220 | // Get the length of the file 221 | fseek( shaderFile, 0, SEEK_END); 222 | size = ftell(shaderFile); 223 | 224 | // Read the file contents from the start, then close file and add a null terminator 225 | fseek( shaderFile, 0, SEEK_SET); 226 | text = new char[size+1]; 227 | fsize = fread( text, size, 1, shaderFile); 228 | fclose( shaderFile); 229 | if (fsize == 0) 230 | printf("CompileGLSLShaderFromFile(), error... fsize = 0\n"); 231 | 232 | text[size] = '\0'; 233 | 234 | GLuint program_id = CompileASMShader( target, text); 235 | 236 | delete []text; 237 | 238 | return program_id; 239 | } 240 | 241 | } // nv namespace 242 | 243 | #endif 244 | 245 | -------------------------------------------------------------------------------- /common/inc/param.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* 13 | Simple parameter system 14 | sgreen@nvidia.com 4/2001 15 | */ 16 | 17 | #ifndef PARAM_H 18 | #define PARAM_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // base class for named parameter 28 | class ParamBase { 29 | public: 30 | ParamBase(const char *name) : m_name(name) { } 31 | virtual ~ParamBase() { } 32 | 33 | std::string &GetName() { return m_name; } 34 | 35 | virtual float GetFloatValue() = 0; 36 | virtual int GetIntValue() = 0; 37 | virtual std::string GetValueString() = 0; 38 | 39 | virtual void Reset() = 0; 40 | virtual void Increment() = 0; 41 | virtual void Decrement() = 0; 42 | 43 | virtual float GetPercentage() = 0; 44 | virtual void SetPercentage(float p) = 0; 45 | 46 | virtual void Write(std::ostream &stream) = 0; 47 | virtual void Read(std::istream &stream) = 0; 48 | 49 | virtual bool IsList() = 0; 50 | 51 | protected: 52 | std::string m_name; 53 | }; 54 | 55 | // derived class for single-valued parameter 56 | template class Param : public ParamBase { 57 | public: 58 | Param(const char *name, T value = 0, T min = 0, T max = 10000, T step = 1, T* ptr = 0) : 59 | ParamBase(name), 60 | m_default(value), 61 | m_min(min), 62 | m_max(max), 63 | m_step(step), 64 | m_precision(3) 65 | { 66 | if (ptr) { 67 | m_ptr = ptr; 68 | } else { 69 | m_ptr = &m_value; 70 | } 71 | *m_ptr = value; 72 | } 73 | ~Param() { } 74 | 75 | T GetValue() const { return *m_ptr; } 76 | T SetValue(const T value) { *m_ptr = value; } 77 | 78 | float GetFloatValue() { return (float) *m_ptr; } 79 | int GetIntValue() { return (int) *m_ptr; } 80 | 81 | std::string GetValueString() 82 | { 83 | std::ostringstream ost; 84 | ost< m_max) 107 | *m_ptr = m_max; 108 | } 109 | 110 | void Decrement() 111 | { 112 | *m_ptr -= m_step; 113 | if (*m_ptr < m_min) 114 | *m_ptr = m_min; 115 | } 116 | 117 | void Write(std::ostream &stream) { stream << m_name << " " << *m_ptr << '\n'; } 118 | void Read(std::istream &stream) { stream >> m_name >> *m_ptr; } 119 | 120 | bool IsList() { return false; } 121 | 122 | private: 123 | T m_value; 124 | T *m_ptr; // pointer to value declared elsewhere 125 | T m_default, m_min, m_max, m_step; 126 | int m_precision; // number of digits after decimal point in string output 127 | }; 128 | 129 | 130 | extern const Param dummy; 131 | 132 | // list of parameters 133 | class ParamList : public ParamBase { 134 | public: 135 | ParamList(const char *name = "") : 136 | ParamBase(name) 137 | { 138 | active = true; 139 | } 140 | ~ParamList() { } 141 | 142 | float GetFloatValue() { return 0.0f; } 143 | int GetIntValue() { return 0; } 144 | 145 | void AddParam(ParamBase *param) 146 | { 147 | m_params.push_back(param); 148 | m_map[param->GetName()] = param; 149 | m_current = m_params.begin(); 150 | } 151 | 152 | // look-up parameter based on name 153 | ParamBase *GetParam(char *name) 154 | { 155 | ParamBase *p = m_map[name]; 156 | 157 | if (p) 158 | return p; 159 | else 160 | return (ParamBase *) &dummy; 161 | } 162 | 163 | ParamBase *GetParam(int i) 164 | { 165 | return m_params[i]; 166 | } 167 | 168 | ParamBase *GetCurrent() 169 | { 170 | return *m_current; 171 | } 172 | 173 | int GetSize() { return (int)m_params.size(); } 174 | 175 | std::string GetValueString() 176 | { 177 | return m_name; 178 | } 179 | 180 | // functions to traverse list 181 | void Reset() 182 | { 183 | m_current = m_params.begin(); 184 | } 185 | 186 | void Increment() 187 | { 188 | m_current++; 189 | if (m_current == m_params.end()) 190 | m_current = m_params.begin(); 191 | } 192 | 193 | void Decrement() 194 | { 195 | if (m_current == m_params.begin()) 196 | m_current = m_params.end()-1; 197 | else 198 | m_current--; 199 | 200 | } 201 | 202 | float GetPercentage() { return 0.0f; } 203 | void SetPercentage(float /*p*/) {} 204 | 205 | void Write(std::ostream &stream) 206 | { 207 | stream << m_name << '\n'; 208 | for(std::vector::const_iterator p = m_params.begin(); p != m_params.end(); ++p) { 209 | (*p)->Write(stream); 210 | } 211 | } 212 | 213 | void Read(std::istream &stream) 214 | { 215 | stream >> m_name; 216 | for(std::vector::const_iterator p = m_params.begin(); p != m_params.end(); ++p) { 217 | (*p)->Read(stream); 218 | } 219 | } 220 | 221 | bool IsList() { return true; } 222 | 223 | void ResetAll() 224 | { 225 | for(std::vector::const_iterator p = m_params.begin(); p != m_params.end(); ++p) { 226 | (*p)->Reset(); 227 | } 228 | } 229 | 230 | protected: 231 | bool active; 232 | std::vector m_params; 233 | std::map m_map; 234 | std::vector::const_iterator m_current; 235 | }; 236 | 237 | #endif 238 | -------------------------------------------------------------------------------- /common/inc/paramgl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* 13 | ParamListGL 14 | - class derived from ParamList to do simple OpenGL rendering of a parameter list 15 | sgg 8/2001 16 | */ 17 | 18 | #ifndef PARAMGL_H 19 | #define PARAMGL_H 20 | 21 | #if defined(__APPLE__) || defined(MACOSX) 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | #include 28 | 29 | void beginWinCoords(); 30 | void endWinCoords(); 31 | void glPrint(int x, int y, const char *s, void *font); 32 | void glPrintShadowed(int x, int y, const char *s, void *font, float *color); 33 | 34 | class ParamListGL : public ParamList { 35 | public: 36 | ParamListGL(const char *name = ""); 37 | 38 | void Render(int x, int y, bool shadow = false); 39 | bool Mouse(int x, int y, int button=GLUT_LEFT_BUTTON, int state=GLUT_DOWN); 40 | bool Motion(int x, int y); 41 | void Special(int key, int x, int y); 42 | 43 | void SetFont(void *font, int height) { m_font = font; m_font_h = height; } 44 | 45 | void SetSelectedColor(float r, float g, float b) { m_text_color_selected = Color(r, g, b); } 46 | void SetUnSelectedColor(float r, float g, float b) { m_text_color_unselected = Color(r, g, b); } 47 | void SetBarColorInner(float r, float g, float b) { m_bar_color_inner = Color(r, g, b); } 48 | void SetBarColorOuter(float r, float g, float b) { m_bar_color_outer = Color(r, g, b); } 49 | 50 | private: 51 | void *m_font; 52 | int m_font_h; // font height 53 | 54 | int m_bar_x; // bar start x position 55 | int m_bar_w; // bar width 56 | int m_bar_h; // bar height 57 | int m_text_x; // text start x position 58 | int m_separation; // bar separation in y 59 | int m_value_x; // value text x position 60 | int m_bar_offset; // bar offset in y 61 | 62 | int m_start_x, m_start_y; 63 | 64 | struct Color { 65 | Color(float _r, float _g, float _b) { r = _r; g = _g; b = _b; } 66 | float r, g, b; 67 | }; 68 | 69 | Color m_text_color_selected; 70 | Color m_text_color_unselected; 71 | Color m_text_color_shadow; 72 | Color m_bar_color_outer; 73 | Color m_bar_color_inner; 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /common/inc/rendercheck_d3d10.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | #pragma once 13 | 14 | #ifndef _RENDERCHECK_D3D10_H_ 15 | #define _RENDERCHECK_D3D10_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | class CheckRenderD3D10 25 | { 26 | public: 27 | 28 | CheckRenderD3D10() {} 29 | 30 | static HRESULT ActiveRenderTargetToPPM(ID3D10Device *pDevice, const char *zFileName); 31 | static HRESULT ResourceToPPM(ID3D10Device*pDevice, ID3D10Resource *pResource, const char *zFileName); 32 | 33 | static bool PPMvsPPM( const char *src_file, const char *ref_file, const char *exec_path, 34 | const float epsilon, const float threshold = 0.0f ); 35 | }; 36 | 37 | #endif -------------------------------------------------------------------------------- /common/inc/rendercheck_d3d11.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | 13 | #pragma once 14 | 15 | #ifndef _RENDERCHECK_D3D11_H_ 16 | #define _RENDERCHECK_D3D11_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | class CheckRenderD3D11 26 | { 27 | public: 28 | 29 | CheckRenderD3D11() {} 30 | 31 | static HRESULT ActiveRenderTargetToPPM(ID3D11Device *pDevice, const char *zFileName); 32 | static HRESULT ResourceToPPM(ID3D11Device *pDevice, ID3D11Resource *pResource, const char *zFileName); 33 | 34 | static bool PPMvsPPM( const char *src_file, const char *ref_file, const char *exec_path, 35 | const float epsilon, const float threshold = 0.0f ); 36 | }; 37 | 38 | #endif -------------------------------------------------------------------------------- /common/inc/rendercheck_d3d9.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | #pragma once 13 | 14 | #ifndef _RENDERCHECK_D3D9_H_ 15 | #define _RENDERCHECK_D3D9_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | class CheckRenderD3D9 24 | { 25 | public: 26 | 27 | CheckRenderD3D9() {} 28 | 29 | static HRESULT BackbufferToPPM(IDirect3DDevice9*pDevice, const char *zFileName); 30 | static HRESULT SurfaceToPPM(IDirect3DDevice9*pDevice, IDirect3DSurface9 *pSurface, const char *zFileName); 31 | 32 | static bool PPMvsPPM( const char *src_file, const char *ref_file, const char *exec_path, 33 | const float epsilon, const float threshold = 0.0f ); 34 | }; 35 | 36 | #endif -------------------------------------------------------------------------------- /common/inc/stopwatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 3 | * 4 | * NVIDIA Corporation and its licensors retain all intellectual property and 5 | * proprietary rights in and to this software and related documentation. 6 | * Any use, reproduction, disclosure, or distribution of this software 7 | * and related documentation without an express license agreement from 8 | * NVIDIA Corporation is strictly prohibited. 9 | * 10 | * Please refer to the applicable NVIDIA end user license agreement (EULA) 11 | * associated with this source code for terms and conditions that govern 12 | * your use of this NVIDIA software. 13 | * 14 | */ 15 | 16 | /* CUda UTility Library */ 17 | 18 | #ifndef _STOPWATCH_H_ 19 | #define _STOPWATCH_H_ 20 | 21 | // stop watch base class 22 | #include 23 | 24 | // include OS specific policy 25 | #ifdef _WIN32 26 | # include 27 | typedef StopWatchWin OSStopWatch; 28 | #else 29 | # include 30 | typedef StopWatchLinux OSStopWatch; 31 | #endif 32 | 33 | // concrete stop watch type 34 | typedef StopWatchBase StopWatchC; 35 | 36 | namespace StopWatch 37 | { 38 | //! Create a stop watch 39 | unsigned int create(); 40 | 41 | //! Get a handle to the stop watch with the name \a name 42 | StopWatchC& get( const unsigned int& name); 43 | 44 | // Delete the stop watch with the name \a name 45 | void destroy( const unsigned int& name); 46 | } // end namespace, stopwatch 47 | 48 | #endif // _STOPWATCH_H_ 49 | 50 | -------------------------------------------------------------------------------- /common/inc/stopwatch_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 3 | * 4 | * NVIDIA Corporation and its licensors retain all intellectual property and 5 | * proprietary rights in and to this software and related documentation. 6 | * Any use, reproduction, disclosure, or distribution of this software 7 | * and related documentation without an express license agreement from 8 | * NVIDIA Corporation is strictly prohibited. 9 | * 10 | * Please refer to the applicable NVIDIA end user license agreement (EULA) 11 | * associated with this source code for terms and conditions that govern 12 | * your use of this NVIDIA software. 13 | * 14 | */ 15 | 16 | /* CUda UTility Library */ 17 | 18 | #ifndef _STOPWATCH_BASE_H_ 19 | #define _STOPWATCH_BASE_H_ 20 | 21 | // includes, system 22 | #include 23 | 24 | //! Simple stop watch 25 | template 26 | class StopWatchBase : public OSPolicy 27 | { 28 | public: 29 | 30 | // generic, specialized type 31 | typedef StopWatchBase SelfType; 32 | // generic, specialized type pointer 33 | typedef StopWatchBase* SelfTypePtr; 34 | 35 | //! global index for all stop watches 36 | static std::vector< SelfTypePtr > swatches; 37 | 38 | public: 39 | 40 | //! Constructor, default 41 | StopWatchBase(); 42 | 43 | // Destructor 44 | ~StopWatchBase(); 45 | 46 | public: 47 | 48 | //! Start time measurement 49 | inline void start(); 50 | 51 | //! Stop time measurement 52 | inline void stop(); 53 | 54 | //! Reset time counters to zero 55 | inline void reset(); 56 | 57 | //! Time in msec. after start. If the stop watch is still running (i.e. there 58 | //! was no call to stop()) then the elapsed time is returned, otherwise the 59 | //! time between the last start() and stop call is returned 60 | inline float getTime() const; 61 | 62 | //! Mean time to date based on the number of times the stopwatch has been 63 | //! _stopped_ (ie finished sessions) and the current total time 64 | inline float getAverageTime() const; 65 | 66 | private: 67 | 68 | //! Constructor, copy (not implemented) 69 | StopWatchBase( const StopWatchBase&); 70 | 71 | //! Assignment operator (not implemented) 72 | StopWatchBase& operator=( const StopWatchBase&); 73 | }; 74 | 75 | // include, implementation 76 | #include 77 | 78 | #endif // _STOPWATCH_BASE_H_ 79 | 80 | -------------------------------------------------------------------------------- /common/inc/stopwatch_base.inl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 3 | * 4 | * NVIDIA Corporation and its licensors retain all intellectual property and 5 | * proprietary rights in and to this software and related documentation and 6 | * any modifications thereto. Any use, reproduction, disclosure, or distribution 7 | * of this software and related documentation without an express license 8 | * agreement from NVIDIA Corporation is strictly prohibited. 9 | * 10 | */ 11 | 12 | /* CUda UTility Library */ 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | //! Constructor, default 16 | //////////////////////////////////////////////////////////////////////////////// 17 | template 18 | StopWatchBase::StopWatchBase() : 19 | OSPolicy() 20 | { } 21 | 22 | //////////////////////////////////////////////////////////////////////////////// 23 | //! Destructor 24 | //////////////////////////////////////////////////////////////////////////////// 25 | template 26 | StopWatchBase::~StopWatchBase() { } 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | //! Start time measurement 30 | //////////////////////////////////////////////////////////////////////////////// 31 | template 32 | inline void 33 | StopWatchBase::start() 34 | { 35 | OSPolicy::start(); 36 | } 37 | 38 | //////////////////////////////////////////////////////////////////////////////// 39 | //! Stop time measurement 40 | //////////////////////////////////////////////////////////////////////////////// 41 | template 42 | inline void 43 | StopWatchBase::stop() 44 | { 45 | OSPolicy::stop(); 46 | } 47 | 48 | 49 | //////////////////////////////////////////////////////////////////////////////// 50 | //! Reset the timer to 0. Does not change the timer running state but does 51 | //! recapture this point in time as the current start time if it is running. 52 | //////////////////////////////////////////////////////////////////////////////// 53 | template 54 | inline void 55 | StopWatchBase::reset() 56 | { 57 | OSPolicy::reset(); 58 | } 59 | 60 | //////////////////////////////////////////////////////////////////////////////// 61 | //! Time in msec. after start. If the stop watch is still running (i.e. there 62 | //! was no call to stop()) then the elapsed time is returned, otherwise the 63 | //! time between the last start() and stop call is returned 64 | //////////////////////////////////////////////////////////////////////////////// 65 | template 66 | inline float 67 | StopWatchBase::getTime() const 68 | { 69 | return OSPolicy::getTime(); 70 | } 71 | 72 | //////////////////////////////////////////////////////////////////////////////// 73 | //! Time in msec. for a single run based on the total number of COMPLETED runs 74 | //! and the total time. 75 | //////////////////////////////////////////////////////////////////////////////// 76 | template 77 | inline float 78 | StopWatchBase::getAverageTime() const 79 | { 80 | return OSPolicy::getAverageTime(); 81 | } 82 | -------------------------------------------------------------------------------- /common/inc/stopwatch_linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 3 | * 4 | * NVIDIA Corporation and its licensors retain all intellectual property and 5 | * proprietary rights in and to this software and related documentation. 6 | * Any use, reproduction, disclosure, or distribution of this software 7 | * and related documentation without an express license agreement from 8 | * NVIDIA Corporation is strictly prohibited. 9 | * 10 | * Please refer to the applicable NVIDIA end user license agreement (EULA) 11 | * associated with this source code for terms and conditions that govern 12 | * your use of this NVIDIA software. 13 | * 14 | */ 15 | 16 | /* CUda UTility Library */ 17 | 18 | #ifndef _STOPWATCH_LINUX_H_ 19 | #define _STOPWATCH_LINUX_H_ 20 | 21 | // includes, system 22 | #include 23 | #include 24 | 25 | //! Windows specific implementation of StopWatch 26 | class StopWatchLinux { 27 | 28 | protected: 29 | 30 | //! Constructor, default 31 | StopWatchLinux(); 32 | 33 | // Destructor 34 | ~StopWatchLinux(); 35 | 36 | public: 37 | 38 | //! Start time measurement 39 | inline void start(); 40 | 41 | //! Stop time measurement 42 | inline void stop(); 43 | 44 | //! Reset time counters to zero 45 | inline void reset(); 46 | 47 | //! Time in msec. after start. If the stop watch is still running (i.e. there 48 | //! was no call to stop()) then the elapsed time is returned, otherwise the 49 | //! time between the last start() and stop call is returned 50 | inline float getTime() const; 51 | 52 | //! Mean time to date based on the number of times the stopwatch has been 53 | //! _stopped_ (ie finished sessions) and the current total time 54 | inline float getAverageTime() const; 55 | 56 | private: 57 | 58 | // helper functions 59 | 60 | //! Get difference between start time and current time 61 | inline float getDiffTime() const; 62 | 63 | private: 64 | 65 | // member variables 66 | 67 | //! Start of measurement 68 | struct timeval start_time; 69 | 70 | //! Time difference between the last start and stop 71 | float diff_time; 72 | 73 | //! TOTAL time difference between starts and stops 74 | float total_time; 75 | 76 | //! flag if the stop watch is running 77 | bool running; 78 | 79 | //! Number of times clock has been started 80 | //! and stopped to allow averaging 81 | int clock_sessions; 82 | }; 83 | 84 | // functions, inlined 85 | 86 | //////////////////////////////////////////////////////////////////////////////// 87 | //! Start time measurement 88 | //////////////////////////////////////////////////////////////////////////////// 89 | inline void 90 | StopWatchLinux::start() { 91 | 92 | gettimeofday( &start_time, 0); 93 | running = true; 94 | } 95 | 96 | //////////////////////////////////////////////////////////////////////////////// 97 | //! Stop time measurement and increment add to the current diff_time summation 98 | //! variable. Also increment the number of times this clock has been run. 99 | //////////////////////////////////////////////////////////////////////////////// 100 | inline void 101 | StopWatchLinux::stop() { 102 | 103 | diff_time = getDiffTime(); 104 | total_time += diff_time; 105 | running = false; 106 | clock_sessions++; 107 | } 108 | 109 | //////////////////////////////////////////////////////////////////////////////// 110 | //! Reset the timer to 0. Does not change the timer running state but does 111 | //! recapture this point in time as the current start time if it is running. 112 | //////////////////////////////////////////////////////////////////////////////// 113 | inline void 114 | StopWatchLinux::reset() 115 | { 116 | diff_time = 0; 117 | total_time = 0; 118 | clock_sessions = 0; 119 | if( running ) 120 | gettimeofday( &start_time, 0); 121 | } 122 | 123 | //////////////////////////////////////////////////////////////////////////////// 124 | //! Time in msec. after start. If the stop watch is still running (i.e. there 125 | //! was no call to stop()) then the elapsed time is returned added to the 126 | //! current diff_time sum, otherwise the current summed time difference alone 127 | //! is returned. 128 | //////////////////////////////////////////////////////////////////////////////// 129 | inline float 130 | StopWatchLinux::getTime() const 131 | { 132 | // Return the TOTAL time to date 133 | float retval = total_time; 134 | if( running) { 135 | 136 | retval += getDiffTime(); 137 | } 138 | 139 | return retval; 140 | } 141 | 142 | //////////////////////////////////////////////////////////////////////////////// 143 | //! Time in msec. for a single run based on the total number of COMPLETED runs 144 | //! and the total time. 145 | //////////////////////////////////////////////////////////////////////////////// 146 | inline float 147 | StopWatchLinux::getAverageTime() const 148 | { 149 | return (clock_sessions > 0) ? (total_time/clock_sessions) : 0.0f; 150 | } 151 | 152 | 153 | 154 | //////////////////////////////////////////////////////////////////////////////// 155 | 156 | //////////////////////////////////////////////////////////////////////////////// 157 | inline float 158 | StopWatchLinux::getDiffTime() const 159 | { 160 | struct timeval t_time; 161 | gettimeofday( &t_time, 0); 162 | 163 | // time difference in milli-seconds 164 | return (float) (1000.0 * ( t_time.tv_sec - start_time.tv_sec) 165 | + (0.001 * (t_time.tv_usec - start_time.tv_usec)) ); 166 | } 167 | 168 | #endif // _STOPWATCH_LINUX_H_ 169 | 170 | -------------------------------------------------------------------------------- /common/lib/linux/libGLEW.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/common/lib/linux/libGLEW.a -------------------------------------------------------------------------------- /common/lib/linux/libGLEW_x86_64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/common/lib/linux/libGLEW_x86_64.a -------------------------------------------------------------------------------- /common/shared/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # Copyright 1993-2010 NVIDIA Corporation. All rights reserved. 4 | # 5 | # NOTICE TO USER: 6 | # 7 | # This source code is subject to NVIDIA ownership rights under U.S. and 8 | # international Copyright laws. 9 | # 10 | # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 11 | # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 12 | # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 13 | # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 14 | # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 15 | # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 16 | # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 17 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 18 | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 19 | # OR PERFORMANCE OF THIS SOURCE CODE. 20 | # 21 | # U.S. Government End Users. This source code is a "commercial item" as 22 | # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 23 | # "commercial computer software" and "commercial computer software 24 | # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 25 | # and is provided to the U.S. Government only as a commercial end item. 26 | # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 27 | # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 28 | # source code with only those rights set forth herein. 29 | # 30 | ############################################################################### 31 | # 32 | # CUda UTility library build script 33 | # 34 | ############################################################################### 35 | 36 | ############################################################################### 37 | # SOURCE VARS 38 | CCFILES := src/shrUtils.cpp \ 39 | src/rendercheckGL.cpp \ 40 | src/cmd_arg_reader.cpp 41 | 42 | SRCDIR := src/ 43 | 44 | ROOTDIR := . 45 | 46 | STATIC_LIB := libshrutil.a 47 | 48 | include common.mk 49 | 50 | -------------------------------------------------------------------------------- /common/shared/inc/GL/freeglut.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_H__ 2 | #define __FREEGLUT_H__ 3 | 4 | /* 5 | * freeglut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | #include "freeglut_ext.h" 19 | 20 | /*** END OF FILE ***/ 21 | 22 | #endif /* __FREEGLUT_H__ */ 23 | -------------------------------------------------------------------------------- /common/shared/inc/GL/freeglut_ext.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_EXT_H__ 2 | #define __FREEGLUT_EXT_H__ 3 | 4 | /* 5 | * freeglut_ext.h 6 | * 7 | * The non-GLUT-compatible extensions to the freeglut library include file 8 | * 9 | * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. 10 | * Written by Pawel W. Olszta, 11 | * Creation date: Thu Dec 2 1999 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a 14 | * copy of this software and associated documentation files (the "Software"), 15 | * to deal in the Software without restriction, including without limitation 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | * and/or sell copies of the Software, and to permit persons to whom the 18 | * Software is furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included 21 | * in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 27 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | */ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* 36 | * GLUT API Extension macro definitions -- behaviour when the user clicks on an "x" to close a window 37 | */ 38 | #define GLUT_ACTION_EXIT 0 39 | #define GLUT_ACTION_GLUTMAINLOOP_RETURNS 1 40 | #define GLUT_ACTION_CONTINUE_EXECUTION 2 41 | 42 | /* 43 | * Create a new rendering context when the user opens a new window? 44 | */ 45 | #define GLUT_CREATE_NEW_CONTEXT 0 46 | #define GLUT_USE_CURRENT_CONTEXT 1 47 | 48 | /* 49 | * GLUT API Extension macro definitions -- the glutGet parameters 50 | */ 51 | #define GLUT_ACTION_ON_WINDOW_CLOSE 0x01F9 52 | 53 | #define GLUT_WINDOW_BORDER_WIDTH 0x01FA 54 | #define GLUT_WINDOW_HEADER_HEIGHT 0x01FB 55 | 56 | #define GLUT_VERSION 0x01FC 57 | 58 | #define GLUT_RENDERING_CONTEXT 0x01FD 59 | 60 | /* 61 | * Process loop function, see freeglut_main.c 62 | */ 63 | FGAPI void FGAPIENTRY glutMainLoopEvent( void ); 64 | FGAPI void FGAPIENTRY glutLeaveMainLoop( void ); 65 | 66 | /* 67 | * Window-specific callback functions, see freeglut_callbacks.c 68 | */ 69 | FGAPI void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) ); 70 | FGAPI void FGAPIENTRY glutCloseFunc( void (* callback)( void ) ); 71 | FGAPI void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) ); 72 | /* A. Donev: Also a destruction callback for menus */ 73 | FGAPI void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) ); 74 | 75 | /* 76 | * State setting and retrieval functions, see freeglut_state.c 77 | */ 78 | FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value ) ; 79 | /* A.Donev: User-data manipulation */ 80 | FGAPI void* FGAPIENTRY glutGetWindowData( void ); 81 | FGAPI void FGAPIENTRY glutSetWindowData(void* data); 82 | FGAPI void* FGAPIENTRY glutGetMenuData( void ); 83 | FGAPI void FGAPIENTRY glutSetMenuData(void* data); 84 | 85 | /* 86 | * Font stuff, see freeglut_font.c 87 | */ 88 | FGAPI int FGAPIENTRY glutBitmapHeight( void* font ); 89 | FGAPI GLfloat FGAPIENTRY glutStrokeHeight( void* font ); 90 | FGAPI void FGAPIENTRY glutBitmapString( void* font, const unsigned char *string ); 91 | FGAPI void FGAPIENTRY glutStrokeString( void* font, const unsigned char *string ); 92 | 93 | /* 94 | * Geometry functions, see freeglut_geometry.c 95 | */ 96 | FGAPI void FGAPIENTRY glutWireRhombicDodecahedron( void ); 97 | FGAPI void FGAPIENTRY glutSolidRhombicDodecahedron( void ); 98 | FGAPI void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ; 99 | FGAPI void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ; 100 | FGAPI void FGAPIENTRY glutWireCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks); 101 | FGAPI void FGAPIENTRY glutSolidCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks); 102 | 103 | /* 104 | * Extension functions, see freeglut_ext.c 105 | */ 106 | FGAPI void * FGAPIENTRY glutGetProcAddress( const char *procName ); 107 | 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | /*** END OF FILE ***/ 114 | 115 | #endif /* __FREEGLUT_EXT_H__ */ 116 | -------------------------------------------------------------------------------- /common/shared/inc/dynlink/common_functions_dynlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | 13 | #if !defined(__COMMON_FUNCTIONS_H__) 14 | #define __COMMON_FUNCTIONS_H__ 15 | 16 | /******************************************************************************* 17 | * * 18 | * * 19 | * * 20 | *******************************************************************************/ 21 | 22 | #if defined(__cplusplus) && defined(__CUDACC__) 23 | 24 | #include "host_defines.h" 25 | 26 | #include 27 | #include 28 | 29 | extern "C" 30 | { 31 | 32 | /*DEVICE_BUILTIN*/ 33 | extern __host__ __device__ clock_t clock(void) __THROW; 34 | 35 | /*DEVICE_BUILTIN*/ 36 | extern __host__ __device__ void *memset(void *s, int c, size_t n) __THROW; 37 | 38 | /*DEVICE_BUILTIN*/ 39 | extern __host__ __device__ void *memcpy(void *d, const void *s, size_t n) __THROW; 40 | 41 | } 42 | 43 | #elif !defined(__CUDACC__) 44 | 45 | #include "crt/func_macro.h" 46 | 47 | __device_func__(clock_t __cuda_clock(void)) 48 | { 49 | return clock(); 50 | } 51 | 52 | __device_func__(void *__cuda_memset(void *s, int c, size_t n)) 53 | { 54 | return memset(s, c, n); 55 | } 56 | 57 | __device_func__(void *__cuda_memcpy(void *d, const void *s, size_t n)) 58 | { 59 | return memcpy(d, s, n); 60 | } 61 | 62 | #endif /* __cplusplus && __CUDACC__ */ 63 | 64 | /******************************************************************************* 65 | * * 66 | * * 67 | * * 68 | *******************************************************************************/ 69 | 70 | #include "math_functions_dynlink.h" 71 | 72 | #endif /* !__COMMON_FUNCTIONS_H__ */ 73 | 74 | -------------------------------------------------------------------------------- /common/shared/inc/dynlink/cuda_texture_types_dynlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | 13 | #if !defined(__CUDA_TEXTURE_TYPES_H__) 14 | #define __CUDA_TEXTURE_TYPES_H__ 15 | 16 | #if defined(__cplusplus) && defined(__CUDACC__) 17 | 18 | /******************************************************************************* 19 | * * 20 | * * 21 | * * 22 | *******************************************************************************/ 23 | 24 | #include "channel_descriptor_dynlink.h" 25 | #include "driver_types.h" 26 | #include "host_defines.h" 27 | #include "texture_types.h" 28 | 29 | /******************************************************************************* 30 | * * 31 | * * 32 | * * 33 | *******************************************************************************/ 34 | 35 | /*TEXTURE_TYPE*/ 36 | template 37 | struct texture : public textureReference 38 | { 39 | __host__ texture(int norm = 0, 40 | enum cudaTextureFilterMode fMode = cudaFilterModePoint, 41 | enum cudaTextureAddressMode aMode = cudaAddressModeClamp) 42 | { 43 | normalized = norm; 44 | filterMode = fMode; 45 | addressMode[0] = aMode; 46 | addressMode[1] = aMode; 47 | addressMode[2] = aMode; 48 | channelDesc = cudaCreateChannelDesc(); 49 | } 50 | 51 | __host__ texture(int norm, 52 | enum cudaTextureFilterMode fMode, 53 | enum cudaTextureAddressMode aMode, 54 | struct cudaChannelFormatDesc desc) 55 | { 56 | normalized = norm; 57 | filterMode = fMode; 58 | addressMode[0] = aMode; 59 | addressMode[1] = aMode; 60 | addressMode[2] = aMode; 61 | channelDesc = desc; 62 | } 63 | }; 64 | 65 | #endif /* __cplusplus && __CUDACC__ */ 66 | 67 | #endif /* !__CUDA_TEXTURE_TYPES_H__ */ 68 | -------------------------------------------------------------------------------- /common/shared/inc/exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* CUda UTility Library */ 13 | #ifndef _EXCEPTION_H_ 14 | #define _EXCEPTION_H_ 15 | 16 | // includes, system 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | //! Exception wrapper. 23 | //! @param Std_Exception Exception out of namespace std for easy typing. 24 | template 25 | class Exception : public Std_Exception 26 | { 27 | public: 28 | 29 | //! @brief Static construction interface 30 | //! @return Alwayss throws ( Located_Exception) 31 | //! @param file file in which the Exception occurs 32 | //! @param line line in which the Exception occurs 33 | //! @param detailed details on the code fragment causing the Exception 34 | static void throw_it( const char* file, 35 | const int line, 36 | const char* detailed = "-" ); 37 | 38 | //! Static construction interface 39 | //! @return Alwayss throws ( Located_Exception) 40 | //! @param file file in which the Exception occurs 41 | //! @param line line in which the Exception occurs 42 | //! @param detailed details on the code fragment causing the Exception 43 | static void throw_it( const char* file, 44 | const int line, 45 | const std::string& detailed); 46 | 47 | //! Destructor 48 | virtual ~Exception() throw(); 49 | 50 | private: 51 | 52 | //! Constructor, default (private) 53 | Exception(); 54 | 55 | //! Constructor, standard 56 | //! @param str string returned by what() 57 | Exception( const std::string& str); 58 | 59 | }; 60 | 61 | //////////////////////////////////////////////////////////////////////////////// 62 | //! Exception handler function for arbitrary exceptions 63 | //! @param ex exception to handle 64 | //////////////////////////////////////////////////////////////////////////////// 65 | template 66 | inline void 67 | handleException( const Exception_Typ& ex) 68 | { 69 | std::cerr << ex.what() << std::endl; 70 | 71 | exit( EXIT_FAILURE); 72 | } 73 | 74 | //! Convenience macros 75 | 76 | //! Exception caused by dynamic program behavior, e.g. file does not exist 77 | #define RUNTIME_EXCEPTION( msg) \ 78 | Exception::throw_it( __FILE__, __LINE__, msg) 79 | 80 | //! Logic exception in program, e.g. an assert failed 81 | #define LOGIC_EXCEPTION( msg) \ 82 | Exception::throw_it( __FILE__, __LINE__, msg) 83 | 84 | //! Out of range exception 85 | #define RANGE_EXCEPTION( msg) \ 86 | Exception::throw_it( __FILE__, __LINE__, msg) 87 | 88 | //////////////////////////////////////////////////////////////////////////////// 89 | //! Implementation 90 | 91 | // includes, system 92 | #include 93 | 94 | //////////////////////////////////////////////////////////////////////////////// 95 | //! Static construction interface. 96 | //! @param Exception causing code fragment (file and line) and detailed infos. 97 | //////////////////////////////////////////////////////////////////////////////// 98 | /*static*/ template 99 | void 100 | Exception:: 101 | throw_it( const char* file, const int line, const char* detailed) 102 | { 103 | std::stringstream s; 104 | 105 | // Quiet heavy-weight but exceptions are not for 106 | // performance / release versions 107 | s << "Exception in file '" << file << "' in line " << line << "\n" 108 | << "Detailed description: " << detailed << "\n"; 109 | 110 | throw Exception( s.str()); 111 | } 112 | 113 | //////////////////////////////////////////////////////////////////////////////// 114 | //! Static construction interface. 115 | //! @param Exception causing code fragment (file and line) and detailed infos. 116 | //////////////////////////////////////////////////////////////////////////////// 117 | /*static*/ template 118 | void 119 | Exception:: 120 | throw_it( const char* file, const int line, const std::string& msg) 121 | { 122 | throw_it( file, line, msg.c_str()); 123 | } 124 | 125 | //////////////////////////////////////////////////////////////////////////////// 126 | //! Constructor, default (private). 127 | //////////////////////////////////////////////////////////////////////////////// 128 | template 129 | Exception::Exception() : 130 | Exception("Unknown Exception.\n") 131 | { } 132 | 133 | //////////////////////////////////////////////////////////////////////////////// 134 | //! Constructor, standard (private). 135 | //! String returned by what(). 136 | //////////////////////////////////////////////////////////////////////////////// 137 | template 138 | Exception::Exception( const std::string& s) : 139 | Std_Exception( s) 140 | { } 141 | 142 | //////////////////////////////////////////////////////////////////////////////// 143 | //! Destructor 144 | //////////////////////////////////////////////////////////////////////////////// 145 | template 146 | Exception::~Exception() throw() { } 147 | 148 | // functions, exported 149 | 150 | #endif // #ifndef _EXCEPTION_H_ 151 | 152 | -------------------------------------------------------------------------------- /common/shared/inc/multithreading.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 MULTITHREADING_H 13 | #define MULTITHREADING_H 14 | 15 | 16 | //Simple portable thread library. 17 | 18 | #if _WIN32 19 | //Windows threads. 20 | #include 21 | 22 | typedef HANDLE CUTThread; 23 | typedef unsigned (WINAPI *CUT_THREADROUTINE)(void *); 24 | 25 | #define CUT_THREADPROC unsigned WINAPI 26 | #define CUT_THREADEND return 0 27 | 28 | #else 29 | //POSIX threads. 30 | #include 31 | 32 | typedef pthread_t CUTThread; 33 | typedef void *(*CUT_THREADROUTINE)(void *); 34 | 35 | #define CUT_THREADPROC void 36 | #define CUT_THREADEND 37 | #endif 38 | 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | //Create thread. 45 | CUTThread cutStartThread(CUT_THREADROUTINE, void *data); 46 | 47 | //Wait for thread to finish. 48 | void cutEndThread(CUTThread thread); 49 | 50 | //Destroy thread. 51 | void cutDestroyThread(CUTThread thread); 52 | 53 | //Wait for multiple threads. 54 | void cutWaitForThreads(const CUTThread *threads, int num); 55 | 56 | #ifdef __cplusplus 57 | } //extern "C" 58 | #endif 59 | 60 | #endif //MULTITHREADING_H 61 | -------------------------------------------------------------------------------- /common/shared/inc/nvGlutWidgets.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | // 13 | // nvGlutWidgets 14 | // 15 | // Adaptor classes to integrate the nvWidgets UI library with the GLUT windowing 16 | // toolkit. The adaptors convert native GLUT UI data to native nvWidgets data. All 17 | // adaptor classes are implemented as in-line code in this header. The adaptor 18 | // defaults to using the standard OpenGL paintor implementation. 19 | // 20 | // Author: Ignacio Castano, Samuel Gateau, Evan Hart 21 | // Email: sdkfeedback@nvidia.com 22 | // 23 | // Copyright (c) NVIDIA Corporation. All rights reserved. 24 | //////////////////////////////////////////////////////////////////////////////////////////////////// 25 | 26 | #ifndef NV_GLUT_WIDGETS_H 27 | #define NV_GLUT_WIDGETS_H 28 | 29 | #include 30 | #include 31 | 32 | 33 | namespace nv { 34 | 35 | class GlutUIContext : public UIContext { 36 | 37 | protected: 38 | 39 | bool _ownPainter; 40 | 41 | public: 42 | 43 | // 44 | // Default UI constructor 45 | // 46 | // Creates private OpenGL painter 47 | ////////////////////////////////////////////////////////////////// 48 | GlutUIContext() : 49 | UIContext( *(new GLUIPainter()) ), 50 | _ownPainter(true) 51 | { 52 | } 53 | 54 | // 55 | // Alternate UI constructor 56 | // 57 | // Allows for overriding the standard painter 58 | ////////////////////////////////////////////////////////////////// 59 | GlutUIContext(UIPainter& painter) : 60 | UIContext( painter ), 61 | _ownPainter(false) 62 | { 63 | } 64 | 65 | // 66 | // UI destructor 67 | // 68 | // Destroy painter if it is private 69 | ////////////////////////////////////////////////////////////////// 70 | ~GlutUIContext() { 71 | if (_ownPainter) delete getPainter(); 72 | } 73 | 74 | // 75 | // UI method for processing GLUT mouse button events 76 | // 77 | // Call this method from the glutMouseFunc callback, the 78 | // modifier parameter maps to glutGetModifiers. 79 | ////////////////////////////////////////////////////////////////// 80 | virtual void mouse(int button, int state, int modifier, int x, int y) { 81 | int modifierMask = 0; 82 | 83 | if ( button == GLUT_LEFT_BUTTON) button = MouseButton_Left; 84 | else if ( button == GLUT_MIDDLE_BUTTON) button = MouseButton_Middle; 85 | else if ( button == GLUT_RIGHT_BUTTON) button = MouseButton_Right; 86 | 87 | if ( modifier & GLUT_ACTIVE_ALT) modifierMask |= ButtonFlags_Alt; 88 | if ( modifier & GLUT_ACTIVE_SHIFT) modifierMask |= ButtonFlags_Shift; 89 | if ( modifier & GLUT_ACTIVE_CTRL) modifierMask |= ButtonFlags_Ctrl; 90 | 91 | if ( state == GLUT_DOWN) state = 1; else state = 0; 92 | 93 | UIContext::mouse( button, state, modifierMask, x, y); 94 | } 95 | 96 | // 97 | // UI method for processing key events 98 | // 99 | // Call this method from the glutReshapeFunc callback 100 | ////////////////////////////////////////////////////////////////// 101 | void specialKeyboard(int k, int x, int y) { UIContext::keyboard( translateKey(k), x, y); } 102 | 103 | // 104 | // Translate non-ascii keys from GLUT to nvWidgets 105 | ////////////////////////////////////////////////////////////////// 106 | unsigned char translateKey( int k ) 107 | { 108 | switch (k) 109 | { 110 | case GLUT_KEY_F1 : 111 | return Key_F1; 112 | case GLUT_KEY_F2 : 113 | return Key_F2; 114 | case GLUT_KEY_F3 : 115 | return Key_F3; 116 | case GLUT_KEY_F4 : 117 | return Key_F4; 118 | case GLUT_KEY_F5 : 119 | return Key_F5; 120 | case GLUT_KEY_F6 : 121 | return Key_F6; 122 | case GLUT_KEY_F7 : 123 | return Key_F7; 124 | case GLUT_KEY_F8 : 125 | return Key_F8; 126 | case GLUT_KEY_F9 : 127 | return Key_F9; 128 | case GLUT_KEY_F10 : 129 | return Key_F10; 130 | case GLUT_KEY_F11 : 131 | return Key_F11; 132 | case GLUT_KEY_F12 : 133 | return Key_F12; 134 | case GLUT_KEY_LEFT : 135 | return Key_Left; 136 | case GLUT_KEY_UP : 137 | return Key_Up; 138 | case GLUT_KEY_RIGHT : 139 | return Key_Right; 140 | case GLUT_KEY_DOWN : 141 | return Key_Down; 142 | case GLUT_KEY_PAGE_UP : 143 | return Key_PageUp; 144 | case GLUT_KEY_PAGE_DOWN : 145 | return Key_PageDown; 146 | case GLUT_KEY_HOME : 147 | return Key_Home; 148 | case GLUT_KEY_END : 149 | return Key_End; 150 | case GLUT_KEY_INSERT : 151 | return Key_Insert; 152 | default: 153 | return 0; 154 | } 155 | } 156 | }; 157 | 158 | }; 159 | 160 | 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /common/shared/inc/nvMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | // 13 | // Template math library for common 3D functionality 14 | // 15 | // This code is in part deriver from glh, a cross platform glut helper library. 16 | // The copyright for glh follows this notice. 17 | // 18 | // Copyright (c) NVIDIA Corporation. All rights reserved. 19 | //////////////////////////////////////////////////////////////////////////////// 20 | 21 | /* 22 | Copyright (c) 2000 Cass Everitt 23 | Copyright (c) 2000 NVIDIA Corporation 24 | All rights reserved. 25 | 26 | Redistribution and use in source and binary forms, with or 27 | without modification, are permitted provided that the following 28 | conditions are met: 29 | 30 | * Redistributions of source code must retain the above 31 | copyright notice, this list of conditions and the following 32 | disclaimer. 33 | 34 | * Redistributions in binary form must reproduce the above 35 | copyright notice, this list of conditions and the following 36 | disclaimer in the documentation and/or other materials 37 | provided with the distribution. 38 | 39 | * The names of contributors to this software may not be used 40 | to endorse or promote products derived from this software 41 | without specific prior written permission. 42 | 43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 44 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 45 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 46 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 47 | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 48 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 49 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 50 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 51 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 53 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 54 | POSSIBILITY OF SUCH DAMAGE. 55 | 56 | 57 | Cass Everitt - cass@r3.nu 58 | */ 59 | 60 | #ifndef NV_MATH_H 61 | #define NV_MATH_H 62 | 63 | #include 64 | 65 | #include 66 | #include 67 | #include 68 | 69 | #define NV_PI float(3.1415926535897932384626433832795) 70 | 71 | namespace nv { 72 | 73 | typedef vec2 vec2f; 74 | typedef vec3 vec3f; 75 | typedef vec3 vec3i; 76 | typedef vec3 vec3ui; 77 | typedef vec4 vec4f; 78 | typedef matrix4 matrix4f; 79 | typedef quaternion quaternionf; 80 | 81 | 82 | inline void applyRotation(const quaternionf & r) 83 | { 84 | float angle; 85 | vec3f axis; 86 | r.get_value(axis, angle); 87 | glRotatef( angle/3.1415926f * 180.0f, axis[0], axis[1], axis[2]); 88 | } 89 | 90 | 91 | 92 | }; 93 | 94 | #endif -------------------------------------------------------------------------------- /common/shared/inc/nvShaderUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | // 13 | // Utility functions for compiling shaders and programs 14 | // 15 | // Author: Evan Hart 16 | // Copyright (c) NVIDIA Corporation. All rights reserved. 17 | //////////////////////////////////////////////////////////////////////////////// 18 | 19 | 20 | #ifndef NV_SHADER_UTILS_H 21 | #define NV_SHADER_UTILS_H 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | namespace nv 29 | { 30 | 31 | 32 | // 33 | // 34 | //////////////////////////////////////////////////////////// 35 | inline GLuint CompileGLSLShader( GLenum target, const char* shader) 36 | { 37 | GLuint object; 38 | 39 | object = glCreateShader( target); 40 | 41 | if (!object) 42 | return object; 43 | 44 | glShaderSource( object, 1, &shader, NULL); 45 | 46 | glCompileShader(object); 47 | 48 | // check if shader compiled 49 | GLint compiled = 0; 50 | glGetShaderiv(object, GL_COMPILE_STATUS, &compiled); 51 | 52 | if (!compiled) 53 | { 54 | #ifdef NV_REPORT_COMPILE_ERRORS 55 | char temp[256] = ""; 56 | glGetShaderInfoLog( object, 256, NULL, temp); 57 | fprintf( stderr, "Compile failed:\n%s\n", temp); 58 | #endif 59 | glDeleteShader( object); 60 | return 0; 61 | } 62 | 63 | return object; 64 | } 65 | 66 | // 67 | // 68 | //////////////////////////////////////////////////////////// 69 | inline GLuint CompileGLSLShaderFromFile( GLenum target, const char* filename) 70 | { 71 | FILE *shaderFile; 72 | char *text; 73 | long size; 74 | size_t count; 75 | 76 | //must read files as binary to prevent problems from newline translation 77 | #ifdef WIN32 78 | fopen_s(&shaderFile, filename, "rb"); 79 | #else 80 | shaderFile = fopen(filename, "rb"); 81 | #endif 82 | 83 | if (shaderFile == NULL) 84 | return 0; 85 | 86 | fseek(shaderFile, 0, SEEK_END); 87 | 88 | size = ftell(shaderFile); 89 | 90 | fseek(shaderFile, 0, SEEK_SET); 91 | 92 | text = new char[size+1]; 93 | 94 | count = fread(text, size, 1, shaderFile); 95 | 96 | fclose(shaderFile); 97 | 98 | if (count < 1) 99 | { 100 | delete []text; 101 | return 0; 102 | } 103 | 104 | text[size] = '\0'; 105 | 106 | GLuint object = CompileGLSLShader( target, text); 107 | 108 | delete []text; 109 | 110 | return object; 111 | } 112 | 113 | 114 | // Create a program composed of vertex and fragment shaders. 115 | inline GLuint LinkGLSLProgram( GLuint vertexShader, GLuint fragmentShader) 116 | { 117 | GLuint program = glCreateProgram(); 118 | glAttachShader(program, vertexShader); 119 | glAttachShader(program, fragmentShader); 120 | glLinkProgram(program); 121 | 122 | #ifdef NV_REPORT_COMPILE_ERRORS 123 | // Get error log. 124 | GLint charsWritten, infoLogLength; 125 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); 126 | 127 | char * infoLog = new char[infoLogLength]; 128 | glGetProgramInfoLog(program, infoLogLength, &charsWritten, infoLog); 129 | printf(infoLog); 130 | delete [] infoLog; 131 | #endif 132 | 133 | // Test linker result. 134 | GLint linkSucceed = GL_FALSE; 135 | glGetProgramiv(program, GL_LINK_STATUS, &linkSucceed); 136 | 137 | if (linkSucceed == GL_FALSE) 138 | { 139 | glDeleteProgram(program); 140 | return 0; 141 | } 142 | 143 | return program; 144 | } 145 | 146 | 147 | // Create a program composed of vertex, geometry and fragment shaders. 148 | inline GLuint LinkGLSLProgram( GLuint vertexShader, GLuint geometryShader, GLint inputType, GLint vertexOut, GLint outputType, GLuint fragmentShader) 149 | { 150 | GLuint program = glCreateProgram(); 151 | glAttachShader(program, vertexShader); 152 | glAttachShader(program, geometryShader); 153 | glProgramParameteriEXT(program, GL_GEOMETRY_INPUT_TYPE_EXT, inputType); 154 | glProgramParameteriEXT(program, GL_GEOMETRY_VERTICES_OUT_EXT, vertexOut); 155 | glProgramParameteriEXT(program, GL_GEOMETRY_OUTPUT_TYPE_EXT, outputType); 156 | glAttachShader(program, fragmentShader); 157 | glLinkProgram(program); 158 | 159 | #ifdef NV_REPORT_COMPILE_ERRORS 160 | // Get error log. 161 | GLint charsWritten, infoLogLength; 162 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); 163 | 164 | char * infoLog = new char[infoLogLength]; 165 | glGetProgramInfoLog(program, infoLogLength, &charsWritten, infoLog); 166 | printf(infoLog); 167 | delete [] infoLog; 168 | #endif 169 | 170 | // Test linker result. 171 | GLint linkSucceed = GL_FALSE; 172 | glGetProgramiv(program, GL_LINK_STATUS, &linkSucceed); 173 | 174 | if (linkSucceed == GL_FALSE) 175 | { 176 | glDeleteProgram(program); 177 | return 0; 178 | } 179 | 180 | return program; 181 | } 182 | 183 | 184 | // 185 | // 186 | //////////////////////////////////////////////////////////// 187 | inline GLuint CompileASMShader(GLenum program_type, const char *code) 188 | { 189 | GLuint program_id; 190 | glGenProgramsARB(1, &program_id); 191 | glBindProgramARB(program_type, program_id); 192 | glProgramStringARB(program_type, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei) strlen(code), (GLubyte *) code); 193 | 194 | GLint error_pos; 195 | glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_pos); 196 | if (error_pos != -1) { 197 | #ifdef NV_REPORT_COMPILE_ERRORS 198 | const GLubyte *error_string; 199 | error_string = glGetString(GL_PROGRAM_ERROR_STRING_ARB); 200 | fprintf(stderr, "Program error at position: %d\n%s\n", (int)error_pos, error_string); 201 | #endif 202 | return 0; 203 | } 204 | return program_id; 205 | } 206 | 207 | // 208 | // 209 | //////////////////////////////////////////////////////////// 210 | inline GLuint CompileASMShaderFromFile( GLenum target, const char* filename) 211 | { 212 | FILE *shaderFile; 213 | char *text; 214 | long size; 215 | size_t count; 216 | 217 | //must read files as binary to prevent problems from newline translation 218 | #ifdef WIN32 219 | fopen_s(&shaderFile, filename, "rb"); 220 | #else 221 | shaderFile = fopen(filename, "rb"); 222 | #endif 223 | 224 | if (shaderFile == NULL) 225 | return 0; 226 | 227 | fseek(shaderFile, 0, SEEK_END); 228 | 229 | size = ftell(shaderFile); 230 | 231 | fseek(shaderFile, 0, SEEK_SET); 232 | 233 | text = new char[size+1]; 234 | 235 | count = fread(text, size, 1, shaderFile); 236 | 237 | fclose(shaderFile); 238 | 239 | if (count < 1) 240 | { 241 | delete []text; 242 | return 0; 243 | } 244 | 245 | text[size] = '\0'; 246 | 247 | GLuint program_id = CompileASMShader( target, text); 248 | 249 | delete []text; 250 | 251 | return program_id; 252 | } 253 | 254 | } // nv namespace 255 | 256 | #endif 257 | 258 | -------------------------------------------------------------------------------- /common/shared/inc/stopwatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* CUda UTility Library */ 13 | 14 | #ifndef _STOPWATCH_H_ 15 | #define _STOPWATCH_H_ 16 | 17 | // stop watch base class 18 | #include 19 | 20 | // include OS specific policy 21 | #ifdef _WIN32 22 | # include 23 | typedef StopWatchWin OSStopWatch; 24 | #else 25 | # include 26 | typedef StopWatchLinux OSStopWatch; 27 | #endif 28 | 29 | // concrete stop watch type 30 | typedef StopWatchBase StopWatchC; 31 | 32 | namespace StopWatch 33 | { 34 | //! Create a stop watch 35 | const unsigned int create(); 36 | 37 | //! Get a handle to the stop watch with the name \a name 38 | StopWatchC& get( const unsigned int& name); 39 | 40 | // Delete the stop watch with the name \a name 41 | void destroy( const unsigned int& name); 42 | } // end namespace, stopwatch 43 | 44 | #endif // _STOPWATCH_H_ 45 | 46 | -------------------------------------------------------------------------------- /common/shared/inc/stopwatch_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* CUda UTility Library */ 13 | 14 | #ifndef _STOPWATCH_BASE_H_ 15 | #define _STOPWATCH_BASE_H_ 16 | 17 | // includes, system 18 | #include 19 | 20 | //! Simple stop watch 21 | template 22 | class StopWatchBase : public OSPolicy 23 | { 24 | public: 25 | 26 | // generic, specialized type 27 | typedef StopWatchBase SelfType; 28 | // generic, specialized type pointer 29 | typedef StopWatchBase* SelfTypePtr; 30 | 31 | //! global index for all stop watches 32 | static std::vector< SelfTypePtr > swatches; 33 | 34 | public: 35 | 36 | //! Constructor, default 37 | StopWatchBase(); 38 | 39 | // Destructor 40 | ~StopWatchBase(); 41 | 42 | public: 43 | 44 | //! Start time measurement 45 | inline void start(); 46 | 47 | //! Stop time measurement 48 | inline void stop(); 49 | 50 | //! Reset time counters to zero 51 | inline void reset(); 52 | 53 | //! Time in msec. after start. If the stop watch is still running (i.e. there 54 | //! was no call to stop()) then the elapsed time is returned, otherwise the 55 | //! time between the last start() and stop call is returned 56 | inline const float getTime() const; 57 | 58 | //! Mean time to date based on the number of times the stopwatch has been 59 | //! _stopped_ (ie finished sessions) and the current total time 60 | inline const float getAverageTime() const; 61 | 62 | private: 63 | 64 | //! Constructor, copy (not implemented) 65 | StopWatchBase( const StopWatchBase&); 66 | 67 | //! Assignment operator (not implemented) 68 | StopWatchBase& operator=( const StopWatchBase&); 69 | }; 70 | 71 | // include, implementation 72 | #include 73 | 74 | #endif // _STOPWATCH_BASE_H_ 75 | 76 | -------------------------------------------------------------------------------- /common/shared/inc/stopwatch_base.inl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2006 NVIDIA Corporation. All rights reserved. 3 | * 4 | * NOTICE TO USER: 5 | * 6 | * This source code is subject to NVIDIA ownership rights under U.S. and 7 | * international Copyright laws. 8 | * 9 | * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 10 | * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 11 | * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 12 | * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 14 | * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 15 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 17 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 18 | * OR PERFORMANCE OF THIS SOURCE CODE. 19 | * 20 | * U.S. Government End Users. This source code is a "commercial item" as 21 | * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 22 | * "commercial computer software" and "commercial computer software 23 | * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 24 | * and is provided to the U.S. Government only as a commercial end item. 25 | * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 26 | * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 27 | * source code with only those rights set forth herein. 28 | */ 29 | 30 | /* CUda UTility Library */ 31 | 32 | //////////////////////////////////////////////////////////////////////////////// 33 | //! Constructor, default 34 | //////////////////////////////////////////////////////////////////////////////// 35 | template 36 | StopWatchBase::StopWatchBase() : 37 | OSPolicy() 38 | { } 39 | 40 | //////////////////////////////////////////////////////////////////////////////// 41 | //! Destructor 42 | //////////////////////////////////////////////////////////////////////////////// 43 | template 44 | StopWatchBase::~StopWatchBase() { } 45 | 46 | /////////////////////////////////////////////////////////////////////////////// 47 | //! Start time measurement 48 | //////////////////////////////////////////////////////////////////////////////// 49 | template 50 | inline void 51 | StopWatchBase::start() 52 | { 53 | OSPolicy::start(); 54 | } 55 | 56 | //////////////////////////////////////////////////////////////////////////////// 57 | //! Stop time measurement 58 | //////////////////////////////////////////////////////////////////////////////// 59 | template 60 | inline void 61 | StopWatchBase::stop() 62 | { 63 | OSPolicy::stop(); 64 | } 65 | 66 | 67 | //////////////////////////////////////////////////////////////////////////////// 68 | //! Reset the timer to 0. Does not change the timer running state but does 69 | //! recapture this point in time as the current start time if it is running. 70 | //////////////////////////////////////////////////////////////////////////////// 71 | template 72 | inline void 73 | StopWatchBase::reset() 74 | { 75 | OSPolicy::reset(); 76 | } 77 | 78 | //////////////////////////////////////////////////////////////////////////////// 79 | //! Time in msec. after start. If the stop watch is still running (i.e. there 80 | //! was no call to stop()) then the elapsed time is returned, otherwise the 81 | //! time between the last start() and stop call is returned 82 | //////////////////////////////////////////////////////////////////////////////// 83 | template 84 | inline const float 85 | StopWatchBase::getTime() const 86 | { 87 | return OSPolicy::getTime(); 88 | } 89 | 90 | //////////////////////////////////////////////////////////////////////////////// 91 | //! Time in msec. for a single run based on the total number of COMPLETED runs 92 | //! and the total time. 93 | //////////////////////////////////////////////////////////////////////////////// 94 | template 95 | inline const float 96 | StopWatchBase::getAverageTime() const 97 | { 98 | return OSPolicy::getAverageTime(); 99 | } 100 | -------------------------------------------------------------------------------- /common/shared/inc/stopwatch_linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* CUda UTility Library */ 13 | 14 | #ifndef _STOPWATCH_LINUX_H_ 15 | #define _STOPWATCH_LINUX_H_ 16 | 17 | // includes, system 18 | #include 19 | #include 20 | 21 | //! Windows specific implementation of StopWatch 22 | class StopWatchLinux { 23 | 24 | protected: 25 | 26 | //! Constructor, default 27 | StopWatchLinux(); 28 | 29 | // Destructor 30 | ~StopWatchLinux(); 31 | 32 | public: 33 | 34 | //! Start time measurement 35 | inline void start(); 36 | 37 | //! Stop time measurement 38 | inline void stop(); 39 | 40 | //! Reset time counters to zero 41 | inline void reset(); 42 | 43 | //! Time in msec. after start. If the stop watch is still running (i.e. there 44 | //! was no call to stop()) then the elapsed time is returned, otherwise the 45 | //! time between the last start() and stop call is returned 46 | inline const float getTime() const; 47 | 48 | //! Mean time to date based on the number of times the stopwatch has been 49 | //! _stopped_ (ie finished sessions) and the current total time 50 | inline const float getAverageTime() const; 51 | 52 | private: 53 | 54 | // helper functions 55 | 56 | //! Get difference between start time and current time 57 | inline float getDiffTime() const; 58 | 59 | private: 60 | 61 | // member variables 62 | 63 | //! Start of measurement 64 | struct timeval start_time; 65 | 66 | //! Time difference between the last start and stop 67 | float diff_time; 68 | 69 | //! TOTAL time difference between starts and stops 70 | float total_time; 71 | 72 | //! flag if the stop watch is running 73 | bool running; 74 | 75 | //! Number of times clock has been started 76 | //! and stopped to allow averaging 77 | int clock_sessions; 78 | }; 79 | 80 | // functions, inlined 81 | 82 | //////////////////////////////////////////////////////////////////////////////// 83 | //! Start time measurement 84 | //////////////////////////////////////////////////////////////////////////////// 85 | inline void 86 | StopWatchLinux::start() { 87 | 88 | gettimeofday( &start_time, 0); 89 | running = true; 90 | } 91 | 92 | //////////////////////////////////////////////////////////////////////////////// 93 | //! Stop time measurement and increment add to the current diff_time summation 94 | //! variable. Also increment the number of times this clock has been run. 95 | //////////////////////////////////////////////////////////////////////////////// 96 | inline void 97 | StopWatchLinux::stop() { 98 | 99 | diff_time = getDiffTime(); 100 | total_time += diff_time; 101 | running = false; 102 | clock_sessions++; 103 | } 104 | 105 | //////////////////////////////////////////////////////////////////////////////// 106 | //! Reset the timer to 0. Does not change the timer running state but does 107 | //! recapture this point in time as the current start time if it is running. 108 | //////////////////////////////////////////////////////////////////////////////// 109 | inline void 110 | StopWatchLinux::reset() 111 | { 112 | diff_time = 0; 113 | total_time = 0; 114 | clock_sessions = 0; 115 | if( running ) 116 | gettimeofday( &start_time, 0); 117 | } 118 | 119 | //////////////////////////////////////////////////////////////////////////////// 120 | //! Time in msec. after start. If the stop watch is still running (i.e. there 121 | //! was no call to stop()) then the elapsed time is returned added to the 122 | //! current diff_time sum, otherwise the current summed time difference alone 123 | //! is returned. 124 | //////////////////////////////////////////////////////////////////////////////// 125 | inline const float 126 | StopWatchLinux::getTime() const 127 | { 128 | // Return the TOTAL time to date 129 | float retval = total_time; 130 | if( running) { 131 | 132 | retval += getDiffTime(); 133 | } 134 | 135 | return retval; 136 | } 137 | 138 | //////////////////////////////////////////////////////////////////////////////// 139 | //! Time in msec. for a single run based on the total number of COMPLETED runs 140 | //! and the total time. 141 | //////////////////////////////////////////////////////////////////////////////// 142 | inline const float 143 | StopWatchLinux::getAverageTime() const 144 | { 145 | return total_time/clock_sessions; 146 | } 147 | 148 | 149 | 150 | //////////////////////////////////////////////////////////////////////////////// 151 | 152 | //////////////////////////////////////////////////////////////////////////////// 153 | inline float 154 | StopWatchLinux::getDiffTime() const 155 | { 156 | struct timeval t_time; 157 | gettimeofday( &t_time, 0); 158 | 159 | // time difference in milli-seconds 160 | return (float) (1000.0 * ( t_time.tv_sec - start_time.tv_sec) 161 | + (0.001 * (t_time.tv_usec - start_time.tv_usec)) ); 162 | } 163 | 164 | #endif // _STOPWATCH_LINUX_H_ 165 | 166 | -------------------------------------------------------------------------------- /common/shared/lib/libshrutil_x86_64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/common/shared/lib/libshrutil_x86_64.a -------------------------------------------------------------------------------- /common/shared/lib/linux/libGLEW.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/common/shared/lib/linux/libGLEW.a -------------------------------------------------------------------------------- /common/shared/lib/linux/libGLEW_x86_64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/common/shared/lib/linux/libGLEW_x86_64.a -------------------------------------------------------------------------------- /common/shared/src/cmd_arg_reader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2010 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 | /* CUda UTility Library */ 13 | 14 | // includes, file 15 | #include 16 | 17 | // includes, system 18 | #include 19 | 20 | // internal unnamed namespace 21 | 22 | namespace 23 | { 24 | // types, internal (class, enum, struct, union, typedef) 25 | 26 | // variables, internal 27 | 28 | } // namespace { 29 | 30 | // variables, exported 31 | 32 | /*static*/ CmdArgReader* CmdArgReader::self; 33 | /*static*/ char** CmdArgReader::rargv; 34 | /*static*/ int CmdArgReader::rargc; 35 | 36 | // functions, exported 37 | 38 | //////////////////////////////////////////////////////////////////////////////// 39 | //! Public construction interface 40 | //! @return a handle to the class instance 41 | //! @param argc number of command line arguments (as given to main()) 42 | //! @param argv command line argument string (as given to main()) 43 | //////////////////////////////////////////////////////////////////////////////// 44 | /*static*/ void 45 | CmdArgReader::init( const int argc, const char** argv) 46 | { 47 | if ( NULL != self) 48 | { 49 | return; 50 | } 51 | 52 | // command line arguments 53 | if (( 0 == argc) || ( 0 == argv)) 54 | { 55 | LOGIC_EXCEPTION( "No command line arguments given."); 56 | } 57 | 58 | self = new CmdArgReader(); 59 | 60 | self->createArgsMaps( argc, argv); 61 | 62 | rargc = argc; 63 | rargv = const_cast( argv); 64 | } 65 | 66 | //////////////////////////////////////////////////////////////////////////////// 67 | //! Constructor, default 68 | //////////////////////////////////////////////////////////////////////////////// 69 | CmdArgReader::CmdArgReader() : 70 | args(), 71 | unprocessed(), 72 | iter(), 73 | iter_unprocessed() 74 | { } 75 | 76 | //////////////////////////////////////////////////////////////////////////////// 77 | //! Destructor 78 | //////////////////////////////////////////////////////////////////////////////// 79 | CmdArgReader::~CmdArgReader() 80 | { 81 | for( iter = args.begin(); iter != args.end(); ++iter) 82 | { 83 | if( *(iter->second.first) == typeid( int)) 84 | { 85 | delete static_cast( iter->second.second); 86 | break; 87 | } 88 | else if( *(iter->second.first) == typeid( bool)) 89 | { 90 | delete static_cast( iter->second.second); 91 | break; 92 | } 93 | else if( *(iter->second.first) == typeid( std::string)) 94 | { 95 | delete static_cast( iter->second.second); 96 | break; 97 | } 98 | else if( *(iter->second.first) == typeid( std::vector< std::string>) ) 99 | { 100 | delete static_cast< std::vector< std::string>* >( iter->second.second); 101 | break; 102 | } 103 | else if( *(iter->second.first) == typeid( std::vector) ) 104 | { 105 | delete static_cast< std::vector* >( iter->second.second); 106 | break; 107 | } 108 | } 109 | } 110 | 111 | //////////////////////////////////////////////////////////////////////////////// 112 | //! Read args as token value pair into map for better processing (Even the 113 | //! values remain strings until the parameter values is requested by the 114 | //! program.) 115 | //! @param argc the argument count (as given to 'main') 116 | //! @param argv the char* array containing the command line arguments 117 | //////////////////////////////////////////////////////////////////////////////// 118 | void 119 | CmdArgReader::createArgsMaps( const int argc, const char** argv) { 120 | 121 | std::string token; 122 | std::string val_str; 123 | 124 | std::map< std::string, std::string> args; 125 | 126 | std::string::size_type pos; 127 | std::string arg; 128 | for( int i=1; i args; 125 | 126 | std::string::size_type pos; 127 | std::string arg; 128 | for( int i=1; i 2 | #include 3 | #include "cudaUtilities.h.cu" 4 | 5 | // Timer variables 6 | unsigned int cpuTimerVariable; 7 | cudaEvent_t eventTimerStart; 8 | cudaEvent_t eventTimerStop; 9 | 10 | 11 | //////////////////////////////////////////////////////////////////////////////// 12 | // Copy a 3D texture from a host (float*) array to a device cudaArray 13 | // The extent should be specified with all dimensions in units of *elements* 14 | inline void prepareCudaTexture(float* h_src, 15 | cudaArray *d_dst, 16 | cudaExtent const texExtent) 17 | { 18 | cudaMemcpy3DParms copyParams = {0}; 19 | cudaPitchedPtr cppImgPsf = make_cudaPitchedPtr( (void*)h_src, 20 | texExtent.width*FLOAT_SZ, 21 | texExtent.width, 22 | texExtent.height); 23 | copyParams.srcPtr = cppImgPsf; 24 | copyParams.dstArray = d_dst; 25 | copyParams.extent = texExtent; 26 | copyParams.kind = cudaMemcpyHostToDevice; 27 | cutilSafeCall( cudaMemcpy3D(©Params) ); 28 | } 29 | 30 | 31 | //////////////////////////////////////////////////////////////////////////////// 32 | // Simple Timing Calls 33 | void cpuStartTimer(void) 34 | { 35 | // GPU Timer Functions 36 | cpuTimerVariable = 0; 37 | cutCreateTimer( &cpuTimerVariable ); 38 | cutStartTimer( cpuTimerVariable ); 39 | } 40 | 41 | //////////////////////////////////////////////////////////////////////////////// 42 | // Stopping also resets the timer 43 | // returns milliseconds 44 | float cpuStopTimer(void) 45 | { 46 | cutStopTimer( cpuTimerVariable ); 47 | float cpuTime = cutGetTimerValue(cpuTimerVariable); 48 | cutDeleteTimer( cpuTimerVariable ); 49 | return cpuTime; 50 | } 51 | 52 | //////////////////////////////////////////////////////////////////////////////// 53 | // Timing Calls for GPU -- this only counts GPU clock cycles, which will be 54 | // more precise for measuring GFLOPS and xfer rates, but shorter than wall time 55 | void gpuStartTimer(void) 56 | { 57 | cudaEventCreate(&eventTimerStart); 58 | cudaEventCreate(&eventTimerStop); 59 | cudaEventRecord(eventTimerStart); 60 | } 61 | 62 | //////////////////////////////////////////////////////////////////////////////// 63 | // Stopping also resets the timer 64 | float gpuStopTimer(void) 65 | { 66 | cudaEventRecord(eventTimerStop); 67 | cudaEventSynchronize(eventTimerStop); 68 | float gpuTime; 69 | cudaEventElapsedTime(&gpuTime, eventTimerStart, eventTimerStop); 70 | return gpuTime; 71 | } 72 | 73 | //////////////////////////////////////////////////////////////////////////////// 74 | // Read/Write images from/to files 75 | void ReadFile(string fn, int* targPtr, int nRows, int nCols) 76 | { 77 | ifstream in(fn.c_str(), ios::in); 78 | // We work with Row-Col format, but files written in Col-Row, so switch loop 79 | for(int r=0; r> targPtr[r*nRows+c]; 82 | in.close(); 83 | } 84 | 85 | //////////////////////////////////////////////////////////////////////////////// 86 | // Writing file in space-separated format 87 | void WriteFile(string fn, int* srcPtr, int nRows, int nCols) 88 | { 89 | ofstream out(fn.c_str(), ios::out); 90 | // We work with Row-Col format, but files written in Col-Row, so switch loop 91 | for(int r=0; r 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | // MASSIVE SPEED HIT for using wrong integer-multiply for compute capability 12 | #if __CUDA_ARCH__ == 100 // Device code path for compute capability 1.0 13 | 14 | #define IMULT(a, b) (__mul24(a,b)) 15 | #define IMULTADD(a, b, c) (__mul24(a,b) + (c)) 16 | 17 | #elif __CUDA_ARCH__ == 200 // Device code path for compute capability 2.0 18 | 19 | #define IMULT(a, b) ((a)*(b)) 20 | #define IMULTADD(a, b, c) ((a)*(b) + (c)) 21 | 22 | #elif !defined(__CUDA_ARCH__) // Host code path 23 | 24 | #define IMULT(a, b) ((a)*(b)) 25 | #define IMULTADD(a, b, c) ((a)*(b) + (c)) 26 | 27 | #endif 28 | 29 | #define IDX_1D(Row, Col, stride) (IMULTADD(Row, stride, Col)) 30 | #define ROW_2D(index, stride) (index / stride) 31 | #define COL_2D(index, stride) (index % stride) 32 | #define ROUNDUP32(integer) ( ((integer-1)/32 + 1) * 32 ) 33 | 34 | #define FLOAT_SZ sizeof(float) 35 | #define INT_SZ sizeof(int) 36 | 37 | using namespace std; 38 | 39 | 40 | //////////////////////////////////////////////////////////////////////////////// 41 | // Copy a 3D texture from a host (float*) array to a device cudaArray 42 | // The extent should be specified with all dimensions in units of *elements* 43 | inline void prepareCudaTexture(float* h_src, 44 | cudaArray *d_dst, 45 | cudaExtent const texExtent); 46 | 47 | //////////////////////////////////////////////////////////////////////////////// 48 | // CPU timer pretty much measures real time (wall clock time). GPU timer 49 | // measures based on the number of GPU clock cycles, which is useful for 50 | // benchmarking memory copies and GFLOPs, but not wall time. 51 | void cpuStartTimer(void); 52 | float cpuStopTimer(void); 53 | void gpuStartTimer(void); 54 | float gpuStopTimer(void); 55 | 56 | //////////////////////////////////////////////////////////////////////////////// 57 | // Read/Write images from/to files 58 | void ReadFile(string fn, int* targPtr, int nRows, int nCols); 59 | 60 | //////////////////////////////////////////////////////////////////////////////// 61 | // Writing file in space-separated format 62 | void WriteFile(string fn, int* srcPtr, int nRows, int nCols); 63 | 64 | //////////////////////////////////////////////////////////////////////////////// 65 | // Writing image to stdout 66 | void PrintArray(int* srcPtr, int nRows, int nCols); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /dispGpuSoln.m: -------------------------------------------------------------------------------- 1 | function dispGpuSoln() 2 | 3 | in = load('ImageIn.txt'); 4 | dilate = load('ImageDilate.txt'); 5 | erode = load('ImageErode.txt'); 6 | se = load('asymmPSF_17x17.txt'); 7 | 8 | figure(1); 9 | subplot(2,2,1); imagesc(in); colormap(gray); axis image; title('Original Image'); 10 | subplot(2,2,2); imagesc(se); colormap(gray); axis image; title('Structuring Element Used'); 11 | subplot(2,2,3); imagesc(dilate); colormap(gray); axis image; title('Dilated'); 12 | subplot(2,2,4); imagesc(erode); colormap(gray); axis image; title('Eroded'); 13 | 14 | row64_left = [1:64]; 15 | col64_left = [1:64]; 16 | row64_right = [1:64]; 17 | col64_right = [193:256]; 18 | 19 | figure(2); 20 | subplot(3,2,1); imagesc(in(row64_left, col64_left)); 21 | colormap(gray); axis image; title('Original Image Left Side'); 22 | subplot(3,2,2); imagesc(in(row64_right, col64_right)); 23 | colormap(gray); axis image; title('Original Image Right Side'); 24 | subplot(3,2,3); imagesc(dilate(row64_left, col64_left)); 25 | colormap(gray); axis image; title('Dilate Left Side'); 26 | subplot(3,2,4); imagesc(dilate(row64_right, col64_right)); 27 | colormap(gray); axis image; title('Dilate Right Side'); 28 | subplot(3,2,5); imagesc(erode(row64_left, col64_left)); 29 | colormap(gray); axis image; title('Erode Left Side'); 30 | subplot(3,2,6); imagesc(erode(row64_right, col64_right)); 31 | colormap(gray); axis image; title('Erode Image Right Side'); 32 | 33 | 34 | dilate3x3 = load('Image3x3_dilate.txt'); 35 | erode3x3 = load('Image3x3_erode.txt'); 36 | erodethin = load('Image3x3_erode_thin.txt'); 37 | figure(3); 38 | subplot(3,2,1); imagesc(dilate3x3(row64_left, col64_left)); 39 | colormap(gray); axis image; title('Dilate3x3 Left Side'); 40 | subplot(3,2,2); imagesc(dilate3x3(row64_right, col64_right)); 41 | colormap(gray); axis image; title('Dilate3x3 Right Side'); 42 | subplot(3,2,3); imagesc(erode3x3(row64_left, col64_left)); 43 | colormap(gray); axis image; title('Erode3x3 Left Side'); 44 | subplot(3,2,4); imagesc(erode3x3(row64_right, col64_right)); 45 | colormap(gray); axis image; title('Erode3x3 Right Side'); 46 | subplot(3,2,5); imagesc(erodethin(row64_left, col64_left)); 47 | colormap(gray); axis image; title('Erode&Thin Left Side'); 48 | subplot(3,2,6); imagesc(erodethin(row64_right, col64_right)); 49 | colormap(gray); axis image; title('Erode&Thin Right Side'); 50 | 51 | 52 | 53 | %figure(3); 54 | %diff = in-gpu; 55 | %%subplot(1,2,1); imagesc(diff); colormap(gray); axis image; 56 | %subplot(1,2,2); imagesc(diff([1:64],[1:64])); colormap(gray); axis image; 57 | 58 | -------------------------------------------------------------------------------- /lib/libcutil_x86_64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/lib/libcutil_x86_64.a -------------------------------------------------------------------------------- /lib/libcutil_x86_64D.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/lib/libcutil_x86_64D.a -------------------------------------------------------------------------------- /lib/libshrutil_x86_64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/lib/libshrutil_x86_64.a -------------------------------------------------------------------------------- /lib/libshrutil_x86_64D.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etotheipi/CUDA-Image-Processing/46f276b923526ebe27384037289ff41475a08e83/lib/libshrutil_x86_64D.a --------------------------------------------------------------------------------