diff --git a/Makefile b/Makefile index f3622f8..03b2c40 100755 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ DESTDIR=$(shell pwd) ARCH=$(shell getconf LONG_BIT) -VMDVER="1.9.4a55" -OPTIX="" -OSPRAY="" +VMDVER="1.9.4a57" +OPTIX= +OSPRAY= ifeq ($(ARCH),64) PLUGINTEXT=LINUXAMD64 #OPTIX=LIBOPTIX #Uncomment this if you want to add in the OptiX renderer. @@ -16,7 +16,7 @@ TCL_INCLUDE_DIR=/usr/include/tcl8.6/ TCL_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu TK_INCLUDE_DIR=/usr/include/tcl8.6/ TK_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -PYTHON_INCLUDE_DIR=/usr/include/python3.8 +PYTHON_INCLUDE_DIR=/usr/include/python3.10 export all: compileplugins compilevmd diff --git a/README.md b/README.md index 90e628c..2e6713a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ For completeness, we also provide instructions for [building packages](#bonus-li This is pretty straightforward, since we'll need to grab a copy of the VMD source code, as well as packages that unlock VMD features. Getting the VMD source is easy, since you just go to the [VMD download page](https://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=VMD) and grab a copy of the source. -This will be a compressed archive, so you will need to uncompress it with `tar -zxf vmdsourcecode.tgz`, with the filenames actually looking something like: `vmd-1.9.4a55.src.tar.gz`. +This will be a compressed archive, so you will need to uncompress it with `tar -zxf vmdsourcecode.tgz`, with the filenames actually looking something like: `vmd-1.9.4a57.src.tar.gz`. This specific alpha version is the one that is assumed throughout the guide, and may require revision to be used for other versions. Now, there are other packages that we will need to grab that are not installed by default on Ubuntu installations. @@ -36,7 +36,7 @@ The last two lines might look a little funny, but there is an unrelated package There are also Debian packages that need to be installed as basic dependencies. ```bash sudo apt install devscripts debhelper #Package building and general compilation -sudo apt install libtachyon-mt-0-dev python3.8-dev tcl8.6-dev tk8.6-dev libnetcdf-dev libpng-dev python3-numpy python3-tk mesa-common-dev libglu1-mesa-dev libxinerama-dev libfltk1.3-dev coreutils sed #VMD required headers and libraries. +sudo apt install libtachyon-mt-0-dev python3.10-dev tcl8.6-dev tk8.6-dev libnetcdf-dev libpng-dev python3-numpy python3-tk mesa-common-dev libglu1-mesa-dev libxinerama-dev libfltk1.3-dev coreutils sed #VMD required headers and libraries. ``` To build VMD with CUDA, you will need a CUDA toolkit. @@ -50,14 +50,14 @@ The code below will install the CUDA toolkit from NVIDIA for Ubuntu 20.04. ```bash -sudo wget -O /etc/apt/preferences.d/cuda-repository-pin-600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin -sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub -sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" +wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb +sudo dpkg -i cuda-keyring_1.0-1_all.deb sudo apt update sudo apt install cuda ``` If you prefer the older CUDA packages in the Ubuntu repositories, you'd do the following. +I cannot emphasize enough how much of a pain it is to work with the Ubuntu version, which has at least one showstopping compilation bug in 22.04. ```bash sudo apt install nvidia-cuda-toolkit ``` @@ -69,9 +69,9 @@ The structure is defined by Debian, and as a result, the [Debian package buildin Debian expects a rigid directory structure for packaging: ``` vmdpackaging -| vmd_1.9.4a55.orig.tar.gz +| vmd_1.9.4a57.orig.tar.gz | -└───vmd-1.9.4a55 +└───vmd-1.9.4a57 | Makefile | vmd.png | @@ -95,11 +95,11 @@ Feel free to copy from this github repository to start with. ```bash mkdir vmdpackaging cd vmdpackaging -mv ~/vmd-1.9.4a55.src.tar.gz vmd_1.9.4a55.orig.tar.gz -mkdir vmd-1.9.4a55 -cd vmd-1.9.4a55 -tar -zxf ../vmd_1.9.4a55.orig.tar.gz -mv vmd-1.9.4a55 vmd +mv ~/vmd-1.9.4a57.src.tar.gz vmd_1.9.4a57.orig.tar.gz +mkdir vmd-1.9.4a57 +cd vmd-1.9.4a57 +tar -zxf ../vmd_1.9.4a57.orig.tar.gz +mv vmd-1.9.4a57 vmd #Get the initial, not totally broken debian files. git init git remote add origin https://github.com/jvermaas/vmd-packaging-instructions.git @@ -190,6 +190,7 @@ This is the diff: + "-gencode arch=compute_75,code=sm_75 " . + "-gencode arch=compute_80,code=sm_80 " . + "-gencode arch=compute_86,code=sm_86 " . ++ "-gencode arch=compute_89,code=sm_89 " . "--ftz=true "; # "-gencode arch=compute_75,code=sm_75 " . $arch_gcc = "gcc"; @@ -249,7 +250,7 @@ This is the diff: $stock_numpy_include_dir=$ENV{"NUMPY_INCLUDE_DIR"} || "$vmd_library_dir/numpy/lib_$config_arch/include"; $stock_numpy_library_dir=$ENV{"NUMPY_LIBRARY_DIR"} || "$vmd_library_dir/python/lib_$config_arch/lib/python2.5/site-packages/numpy/core/include"; - $python_libs = "-lpython2.5 -lpthread"; -+ $python_libs = "-lpython3.8 -lpthread"; ++ $python_libs = "-lpython3.10 -lpthread"; } $python_defines = "-DVMDPYTHON"; @@ -354,12 +355,9 @@ This has stride, tachyon, and surf executables set to weird paths. I put them in ``` Again, you could copy this from the edited version from github. `cp edited/vmd.sh vmd/bin/vmd.sh` -There is a syntactical mistake in `vmd/src/OptiXRenderer.C` in version 1.9.4a55 that newer versions of `gcc` don't like, so we also have one more copy to make. -`cp edited/OptiXRenderer.C vmd/src/OptiXRenderer.C` - ## Debuild builds packages -The build process itself is largely automated by `debuild`, run from the base directory we have been working from (`vmdpackaging/vmd-1.9.4a55`). +The build process itself is largely automated by `debuild`, run from the base directory we have been working from (`vmdpackaging/vmd-1.9.4a57`). ```bash debuild -b @@ -373,7 +371,7 @@ This is to be expected, and so long as the `.deb` files are produced, these erro To install these packages directly, you would do something like: ```bash cd .. #Puts you in the right directory. -sudo dpkg -i vmd-cuda_1.9.4a55-3_amd64.deb vmd-plugins_1.9.4a55-3_amd64.deb +sudo dpkg -i vmd-cuda_1.9.4a57-1_amd64.deb vmd-plugins_1.9.4a55-1_amd64.deb ``` This would get you a `vmd` command already added to your path, which includes Python support through system Python libraries. @@ -389,9 +387,9 @@ With the setup complete, the commands to add the newly built packages to the rep ```bash cd /var/www/repos/apt/ubuntu/ -sudo reprepro includedeb focal ~/vmdpackaging/vmd-cuda_1.9.4a55-3_amd64.deb -sudo reprepro includedeb focal ~/vmdpackaging/vmd-plugins_1.9.4a55-3_amd64.deb -sudo reprepro includedeb focal ~/vmdpackaging/vmd_1.9.4a55-3_amd64.deb +sudo reprepro includedeb focal ~/vmdpackaging/vmd-cuda_1.9.4a57-1_amd64.deb +sudo reprepro includedeb focal ~/vmdpackaging/vmd-plugins_1.9.4a57-1_amd64.deb +sudo reprepro includedeb focal ~/vmdpackaging/vmd_1.9.4a57-1_amd64.deb ``` diff --git a/edited/OptiXRenderer.C b/edited/OptiXRenderer.C deleted file mode 100644 index c0ab3da..0000000 --- a/edited/OptiXRenderer.C +++ /dev/null @@ -1,7291 +0,0 @@ -/*************************************************************************** - *cr - *cr (C) Copyright 1995-2019 The Board of Trustees of the - *cr University of Illinois - *cr All Rights Reserved - *cr - ***************************************************************************/ - -/*************************************************************************** -* RCS INFORMATION: -* -* $RCSfile: OptiXRenderer.C,v $ -* $Author: johns $ $Locker: $ $State: Exp $ -* $Revision: 1.388 $ $Date: 2021/10/08 04:15:09 $ -* -***************************************************************************/ -/** - * \file OptiXRenderer.C - * \brief VMD built-in Tachyon/OptiX ray tracing engine. - * - * This work is described in: - * "GPU-Accelerated Molecular Visualization on - * Petascale Supercomputing Platforms" - * John E. Stone, Kirby L. Vandivort, and Klaus Schulten. - * UltraVis'13: Proceedings of the 8th International Workshop on - * Ultrascale Visualization, pp. 6:1-6:8, 2013. - * http://dx.doi.org/10.1145/2535571.2535595 - * - * "Atomic Detail Visualization of Photosynthetic Membranes with - * GPU-Accelerated Ray Tracing" - * John E. Stone, Melih Sener, Kirby L. Vandivort, Angela Barragan, - * Abhishek Singharoy, Ivan Teo, João V. Ribeiro, Barry Isralewitz, - * Bo Liu, Boon Chong Goh, James C. Phillips, Craig MacGregor-Chatwin, - * Matthew P. Johnson, Lena F. Kourkoutis, C. Neil Hunter, and Klaus Schulten - * J. Parallel Computing, 55:17-27, 2016. - * http://dx.doi.org/10.1016/j.parco.2015.10.015 - * - * "Immersive Molecular Visualization with Omnidirectional - * Stereoscopic Ray Tracing and Remote Rendering" - * John E. Stone, William R. Sherman, and Klaus Schulten. - * High Performance Data Analysis and Visualization Workshop, - * 2016 IEEE International Parallel and Distributed Processing - * Symposium Workshops (IPDPSW), pp. 1048-1057, 2016. - * http://dx.doi.org/10.1109/IPDPSW.2016.121 - * - * "Omnidirectional Stereoscopic Projections for VR" - * John E. Stone. - * In, William R. Sherman, editor, - * VR Developer Gems, Taylor and Francis / CRC Press, Chapter 24, 2019. - * - * "Interactive Ray Tracing Techniques for - * High-Fidelity Scientific Visualization" - * John E. Stone. - * In, Eric Haines and Tomas Akenine-Möller, editors, - * Ray Tracing Gems, Apress, Chapter 27, pp. 493-515, 2019. - * https://link.springer.com/book/10.1007/978-1-4842-4427-2 - * - * "A Planetarium Dome Master Camera" - * John E. Stone. - * In, Eric Haines and Tomas Akenine-Möller, editors, - * Ray Tracing Gems, Apress, Chapter 4, pp. 49-60, 2019. - * https://link.springer.com/book/10.1007/978-1-4842-4427-2 - * - * Portions of this code are derived from Tachyon: - * "An Efficient Library for Parallel Ray Tracing and Animation" - * John E. Stone. Master's Thesis, University of Missouri-Rolla, - * Department of Computer Science, April 1998 - * - * "Rendering of Numerical Flow Simulations Using MPI" - * John Stone and Mark Underwood. - * Second MPI Developers Conference, pages 138-141, 1996. - * http://dx.doi.org/10.1109/MPIDC.1996.534105 - */ - -// low-level OptiX headers have to be included first -// to prevent issues with compilation on Windows due to -// header-internal min/max macro (re)definition, etc. -#include "OptiXRenderer.h" -#include "OptiXShaders.h" - -#include -#include -#include -#include -#include -#if OPTIX_VERSION >= 50200 -#include // needed for cudaGetDeviceCount() etc -#endif - -#if defined(__linux) -#include // needed for symlink() in movie recorder -#endif - -#include "VMDApp.h" // needed for video streaming -#include "VideoStream.h" // needed for video streaming -#include "DisplayDevice.h" // needed for video streaming - -#include "Inform.h" -#include "ImageIO.h" -#include "Matrix4.h" -#include "utilities.h" -#include "WKFUtils.h" -#include "ProfileHooks.h" -#if defined(VMDOPTIXRTRT) -#include "DispCmds.h" // needed to process VMDDisplayList command tokens -#endif - -// Enable the use of RT_GEOMETRY_BUILD_FLAG_RELEASE_BUFFERS on -// RTX-specific triangle mesh vertex/index buffers optimization -// -// XXX This is presently disabled due to observed performance -// losses compared to self-managed buffer deallocation when -// rendering frames in a tight loop. -// #define VMDOPTIXRTXRELEASEBUFS 1 - -// Enable HMD if VMD compiled with Oculus VR SDK or OpenHMD -#if defined(VMDUSEOPENHMD) -#define VMDOPTIX_USE_HMD 1 -#endif - -#if defined(VMDOPTIX_USE_HMD) -#include "HMDMgr.h" -#endif - -// support Linux event I/O based joystick/spaceball input -#if defined(VMDUSEEVENTIO) -#include "eventio.h" -#endif - -// enable the interactive ray tracing capability -#if defined(VMDOPTIX_INTERACTIVE_OPENGL) -#if (defined(WIN32) || defined(_WIN64)) && defined(_MSC_VER) -#include // must include windows.h prior to GL -#endif - -#include -#endif - -// the ORT_USE_TEMPLATE_SHADERS macro enables or disables the use of -// an array of template-specialized shaders for every combination of -// scene-wide and material-specific shader features. -#if defined(ORT_USE_TEMPLATE_SHADERS) -static const char *onoffstr(int onoff) { - return (onoff) ? "on" : "off"; -} -#endif - -// OptiX 5.2 HW triangle APIs -#define ORT_USE_HW_TRIANGLES 1 - -// check environment for verbose timing/debugging output flags -static OptiXRenderer::Verbosity get_verbose_flag(int inform=0) { - OptiXRenderer::Verbosity verbose = OptiXRenderer::RT_VERB_MIN; - char *verbstr = getenv("VMDOPTIXVERBOSE"); - if (verbstr != NULL) { -// printf("OptiXRenderer) verbosity config request: '%s'\n", verbstr); - if (!strupcmp(verbstr, "MIN")) { - verbose = OptiXRenderer::RT_VERB_MIN; - if (inform) - printf("OptiXRenderer) verbose setting: minimum\n"); - } else if (!strupcmp(verbstr, "TIMING")) { - verbose = OptiXRenderer::RT_VERB_TIMING; - if (inform) - printf("OptiXRenderer) verbose setting: timing data\n"); - } else if (!strupcmp(verbstr, "DEBUG")) { - verbose = OptiXRenderer::RT_VERB_DEBUG; - if (inform) - printf("OptiXRenderer) verbose setting: full debugging data\n"); - } - } - return verbose; -} - - -#if 0 -// Enable the use of OptiX timeout callbacks to help reduce the likelihood -// of kernel timeouts when rendering on GPUs that are also used for display -#define VMD_ENABLE_OPTIX_TIMEOUTS 1 - -static int vmd_timeout_init = 0; -static wkf_timerhandle cbtimer; -static float vmd_timeout_lastcallback = 0.0f; - -static void vmd_timeout_reset(void) { - if (vmd_timeout_init == 0) { - vmd_timeout_init = 1; - cbtimer = wkf_timer_create(); - } - wkf_timer_start(cbtimer); - vmd_timeout_lastcallback = wkf_timer_timenow(cbtimer); -} - -static void vmd_timeout_time(float &deltat, float &totalt) { - double now = wkf_timer_timenow(cbtimer); - deltat = now - vmd_timeout_lastcallback; - totalt = now; - vmd_timeout_lastcallback = now; -} - -static int vmd_timeout_cb(void) { - int earlyexit = 0; - float deltat, totalt; - - if (vmd_timeout_init == 0) - vmd_timeout_reset(); - - vmd_timeout_time(deltat, totalt); - printf("OptiXRenderer) timeout callback: since last %f sec, total %f sec\n", - deltat, totalt); - return earlyexit; -} - -#endif - - -// assumes current scope has Context variable named 'ctx' -#define RTERR( func ) \ - { \ - RTresult code = func; \ - if (code != RT_SUCCESS) { \ - lasterror = code; /* preserve error code for subsequent tests */ \ - const char* message; \ - rtContextGetErrorString(ctx, code, &message); \ - msgErr << "OptiXRenderer) ERROR: " << message << " (" \ - << __FILE__ << ":" << __LINE__ << sendmsg; \ - } \ - } - - -// assumes current scope has Context variable named 'ctx' -// caller-provided 'code' error return value is used so that subsequent -// code can use that for its own purposes. -#define RTERR2( func, code ) \ - { \ - code = func; \ - if (code != RT_SUCCESS) { \ - lasterror = code; /* preserve error code for subsequent tests */ \ - const char* message; \ - rtContextGetErrorString(ctx, code, &message); \ - msgErr << "OptiXRenderer) ERROR: " << message << " (" \ - << __FILE__ << ":" << __LINE__ << sendmsg; \ - } \ - } - - -#if defined(ORT_USERTXAPIS) - -// -// helper routines for OptiX RTX hardware triangle APIs -// - -// helper function that tests triangles for degeneracy and -// computes geometric normals -__forceinline__ int hwtri_test_calc_Ngeom(const float3 * __restrict__ vertices, - float3 &Ngeometric) { - // Compute unnormalized geometric normal - float3 Ng = cross(vertices[1]-vertices[0], vertices[2]-vertices[0]); - - // Cull any degenerate triangles - float area = length(Ng); // we want non-zero parallelogram area - if (area > 0.0f && !isinf(area)) { - // finish normalizing the geometric vector - Ngeometric = Ng * (1.0f / area); - return 0; // return success - } - - return 1; // cull any triangle that fails area test -} - - -// helper function to allocate and map RT buffers for hardware triangles -static void hwtri_alloc_bufs_v3f_n4u4_c4u(RTcontext ctx, int numfacets, - RTbuffer &vbuf, float3 *&vertices, - RTbuffer &nbuf, uint4 *&normals, - RTbuffer &cbuf, int numcolors, - uchar4 *&colors, - const float *uniform_color) { - // Create and fill vertex/normal buffers - rtBufferCreate(ctx, RT_BUFFER_INPUT, &vbuf); - rtBufferSetFormat(vbuf, RT_FORMAT_FLOAT3); - rtBufferSetSize1D(vbuf, numfacets * 3); - - rtBufferCreate(ctx, RT_BUFFER_INPUT, &nbuf); - rtBufferSetFormat(nbuf, RT_FORMAT_UNSIGNED_INT4); - rtBufferSetSize1D(nbuf, numfacets); - - rtBufferCreate(ctx, RT_BUFFER_INPUT, &cbuf); - rtBufferSetFormat(cbuf, RT_FORMAT_UNSIGNED_BYTE4); - rtBufferSetSize1D(cbuf, numcolors); - - rtBufferMap(vbuf, (void**) &vertices); - rtBufferMap(nbuf, (void**) &normals); - rtBufferMap(cbuf, (void**) &colors); - - if ((numcolors == 1) && (uniform_color != NULL)) { - colors[0].x = uniform_color[0] * 255.0f; - colors[0].y = uniform_color[1] * 255.0f; - colors[0].z = uniform_color[2] * 255.0f; - colors[0].w = 255; - } -} - - -// helper function to set instance state variables to flag -// the availability of per-vertex normals and colors for the triangle mesh -static void hwtri_set_vertex_flags(RTcontext ctx, - RTgeometryinstance instance_hwtri, - RTbuffer nbuf, RTbuffer cbuf, - int has_vertex_normals, - int has_vertex_colors) { - RTresult lasterror = RT_SUCCESS; - - // register normal buffer - RTvariable nbuf_v; - RTERR( rtGeometryInstanceDeclareVariable(instance_hwtri, "normalBuffer", &nbuf_v) ); - RTERR( rtVariableSetObject(nbuf_v, nbuf) ); - - // register color buffer - RTvariable cbuf_v; - RTERR( rtGeometryInstanceDeclareVariable(instance_hwtri, "colorBuffer", &cbuf_v) ); - RTERR( rtVariableSetObject(cbuf_v, cbuf) ); - - // Enable/disable per-vertex normals (or use geometric normal) - RTvariable has_vertex_normals_v; - RTERR( rtGeometryInstanceDeclareVariable(instance_hwtri, "has_vertex_normals", &has_vertex_normals_v) ); - RTERR( rtVariableSet1i(has_vertex_normals_v, has_vertex_normals) ); - - // Enable/disable per-vertex colors (or use uniform color) - RTvariable has_vertex_colors_v; - RTERR( rtGeometryInstanceDeclareVariable(instance_hwtri, "has_vertex_colors", &has_vertex_colors_v) ); - RTERR( rtVariableSet1i(has_vertex_colors_v, has_vertex_colors) ); - - if (lasterror != RT_SUCCESS) { - printf("OptiXRenderer::hwtri_set_vertex_flags() error!\n"); - } -} - -#endif - - -#if defined(VMDOPTIX_INTERACTIVE_OPENGL) - -static void print_ctx_devices(RTcontext ctx) { - unsigned int devcount = 0; - rtContextGetDeviceCount(ctx, &devcount); - if (devcount > 0) { - int *devlist = (int *) calloc(1, devcount * sizeof(int)); - rtContextGetDevices(ctx, devlist); - printf("OptiXRenderer) Using %d device%s:\n", - devcount, (devcount == 1) ? "" : "s"); - - unsigned int d; - for (d=0; d 0) { - int *devlist = (int *) calloc(1, devcount * sizeof(int)); - RTERR( rtContextGetDevices(ctx, devlist) ); - unsigned int d; - for (d=0; d(RT_CONTEXT_ATTRIBUTE_AVAILABLE_DEVICE_MEMORY+ordinal), sizeof(freememsz), &freememsz) ); - if (lasterror != RT_SUCCESS) { - free(devlist); - return -1; - } - - RTERR( rtDeviceGetAttribute(devlist[d], RT_DEVICE_ATTRIBUTE_TOTAL_MEMORY, sizeof(physmemsz), &physmemsz) ); - if (lasterror != RT_SUCCESS) { - free(devlist); - return -1; - } - - if (d==0) { - freemem = freememsz; - physmem = physmemsz; - } else { - if (freemem < freememsz) - freemem = freememsz; - - if (physmem < physmemsz) - physmem = physmemsz; - } - } - free(devlist); - return 0; - } - - return -1; -} - - -int OptiXPrintRayStats(RTbuffer raystats1_buffer, RTbuffer raystats2_buffer, - double rtruntime) { - int rc = 0; - RTcontext ctx; - RTresult result; - RTsize buffer_width, buffer_height; - const char* error; - - rtBufferGetContext(raystats1_buffer, &ctx); - - // buffer must be 2-D (for now) - unsigned int bufdim; - if (rtBufferGetDimensionality(raystats1_buffer, &bufdim) != RT_SUCCESS) { - msgErr << "OptiXPrintRayStats: Failed to get ray stats buffer dimensions!" << sendmsg; - return -1; - } - if (bufdim != 2) { - msgErr << "OptiXPrintRayStats: Output buffer is not 2-D!" << sendmsg; - return -1; - } - - result = rtBufferGetSize2D(raystats1_buffer, &buffer_width, &buffer_height); - if (result != RT_SUCCESS) { - // Get error from context - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXRenderer) Error getting dimensions of buffers: " << error << sendmsg; - return -1; - } - - volatile uint4 *raystats1, *raystats2; - result = rtBufferMap(raystats1_buffer, (void**) &raystats1); - result = rtBufferMap(raystats2_buffer, (void**) &raystats2); - if (result != RT_SUCCESS) { - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXPrintRayStats: Error mapping stats buffers: " - << error << sendmsg; - return -1; - } - - // no stats data - if (buffer_width < 1 || buffer_height < 1 || - raystats1 == NULL || raystats2 == NULL) { - msgErr << "OptiXPrintRayStats: No data in ray stats buffers!" << sendmsg; - return -1; - } - - // collect and sum all per-pixel ray stats - int i; - int totalsz = buffer_width * buffer_height; - unsigned long misses, transkips; - unsigned long primaryrays, shadowlights, shadowao, transrays, reflrays; - misses = transkips = primaryrays = shadowlights - = shadowao = transrays = reflrays = 0; - - // accumulate per-pixel ray stats into totals - for (i=0; i 0.0) { - printf("OptiXRenderer) Rays/sec: %g\n", totalrays / rtruntime); - } - printf("OptiXRenderer)\n"); - - result = rtBufferUnmap(raystats1_buffer); - result = rtBufferUnmap(raystats2_buffer); - if (result != RT_SUCCESS) { - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXPrintRayStats: Error unmapping ray stats buffer: " - << error << sendmsg; - return -1; - } - - return rc; -} - - -int OptiXWriteImage(const char* filename, int writealpha, - RTbuffer buffer, RTformat buffer_format, - RTsize buffer_width, RTsize buffer_height) { - RTresult result; - - void * imageData; - result = rtBufferMap(buffer, &imageData); - if (result != RT_SUCCESS) { - RTcontext ctx; - const char* error; - rtBufferGetContext(buffer, &ctx); - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXWriteImage: Error mapping image buffer: " - << error << sendmsg; - return -1; - } - - // no image data - if (buffer_width < 1 || buffer_height < 1 || imageData == NULL) { - msgErr << "OptiXWriteImage: No image data in output buffer!" << sendmsg; - return -1; - } - - // write the image to a file, according to the buffer format - int xs = buffer_width; - int ys = buffer_height; - int rc = 0; - if (buffer_format == RT_FORMAT_FLOAT4) { - if (writealpha) { -//printf("Writing rgba4f alpha channel output image 2\n"); - if (write_image_file_rgba4f(filename, (const float *) imageData, xs, ys)) - rc = -1; - } else { - if (write_image_file_rgb4f(filename, (const float *) imageData, xs, ys)) - rc = -1; - } - } else if (buffer_format == RT_FORMAT_UNSIGNED_BYTE4) { - if (writealpha) { -//printf("Writing rgba4u alpha channel output image 2\n"); - if (write_image_file_rgba4u(filename, (const unsigned char *) imageData, xs, ys)) - rc = -1; - } else { - if (write_image_file_rgb4u(filename, (const unsigned char *) imageData, xs, ys)) - rc = -1; - } - } else { - rc = -1; - } - - result = rtBufferUnmap(buffer); - if (result != RT_SUCCESS) { - RTcontext ctx; - const char* error; - rtBufferGetContext(buffer, &ctx); - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXWriteImage: Error unmapping image buffer: " - << error << sendmsg; - return -1; - } - - return rc; -} - - -int OptiXWriteImage(const char* filename, int writealpha, RTbuffer buffer) { - RTresult result; - RTformat buffer_format; - RTsize buffer_width, buffer_height; - - // buffer must be 2-D - unsigned int bufdim; - if (rtBufferGetDimensionality(buffer, &bufdim) != RT_SUCCESS) { - msgErr << "OptiXWriteImage: Failed to get output buffer dimensions!" << sendmsg; - return -1; - } - - if (bufdim != 2) { - msgErr << "OptiXWriteImage: Output buffer is not 2-D!" << sendmsg; - return -1; - } - - void * imageData; - result = rtBufferMap(buffer, &imageData); - if (result != RT_SUCCESS) { - RTcontext ctx; - const char* error; - rtBufferGetContext(buffer, &ctx); - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXWriteImage: Error mapping image buffer: " - << error << sendmsg; - return -1; - } - - // no image data - if (imageData == NULL) { - msgErr << "OptiXWriteImage: No image data in output buffer!" << sendmsg; - return -1; - } - - result = rtBufferGetSize2D(buffer, &buffer_width, &buffer_height); - if (result != RT_SUCCESS) { - // Get error from context - RTcontext ctx; - const char* error; - rtBufferGetContext(buffer, &ctx); - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXRenderer) Error getting dimensions of buffer: " << error << sendmsg; - return -1; - } - - if (rtBufferGetFormat(buffer, &buffer_format) != RT_SUCCESS) { - msgErr << "OptiXWriteImage: failed to query output buffer format!" - << sendmsg; - return -1; - } - - // write the image to a file, according to the buffer format - int xs = buffer_width; - int ys = buffer_height; - int rc = 0; - - if (buffer_format == RT_FORMAT_FLOAT4) { - if (writealpha) { -//printf("Writing rgba4f alpha channel output image 1\n"); - if (write_image_file_rgba4f(filename, (const float *) imageData, xs, ys)) - rc = -1; - } else { - if (write_image_file_rgb4f(filename, (const float *) imageData, xs, ys)) - rc = -1; - } - } else if (buffer_format == RT_FORMAT_UNSIGNED_BYTE4) { - if (writealpha) { -//printf("Writing rgba4u alpha channel output image 1\n"); - if (write_image_file_rgba4u(filename, (const unsigned char *) imageData, xs, ys)) - rc = -1; - } else { - if (write_image_file_rgb4u(filename, (const unsigned char *) imageData, xs, ys)) - rc = -1; - } - } else { - rc = -1; - } - - result = rtBufferUnmap(buffer); - if (result != RT_SUCCESS) { - RTcontext ctx; - const char* error; - rtBufferGetContext(buffer, &ctx); - rtContextGetErrorString(ctx, result, &error); - msgErr << "OptiXWriteImage: Error unmapping image buffer: " - << error << sendmsg; - return -1; - } - - return rc; -} - - -/// constructor ... initialize some variables -OptiXRenderer::OptiXRenderer(VMDApp *vmdapp) { - PROFILE_PUSH_RANGE("OptiXRenderer::OptiXRenderer()", 0); - app = vmdapp; // store VMDApp ptr for video streaming - ort_timer = wkf_timer_create(); // create and initialize timer - wkf_timer_start(ort_timer); - - // setup path to pre-compiled shader PTX code - const char *vmddir = getenv("VMDDIR"); - if (vmddir == NULL) - vmddir = "."; - sprintf(shaderpath, "%s/shaders/%s", vmddir, "OptiXShaders.ptx"); - - // allow runtime override of the default shader path for testing - if (getenv("VMDOPTIXSHADERPATH")) { - strcpy(shaderpath, getenv("VMDOPTIXSHADERPATH")); - msgInfo << "User-override of OptiX shader path: " << getenv("VMDOPTIXSHADERPATH") << sendmsg; - } - -#if defined(ORT_USERTXAPIS) - rtx_enabled = 1; // RTX execution mode enabled - hwtri_enabled = 1; // RTX hardware triangle APIs enabled by default -#endif - - lasterror = RT_SUCCESS; // begin with no error state set - context_created = 0; // no context yet - buffers_allocated = 0; // flag no buffer allocated yet - buffers_progressive = 0; // buf bound using progressive API or not - scene_created = 0; // scene has been created - - // clear timers - time_ctx_setup = 0.0; - time_ctx_validate = 0.0; - time_ctx_AS_build = 0.0; - time_ray_tracing = 0.0; - time_image_io = 0.0; - - // set default scene background state - scene_background_mode = RT_BACKGROUND_TEXTURE_SOLID; - memset(scene_bg_color, 0, sizeof(scene_bg_color)); - memset(scene_bg_grad_top, 0, sizeof(scene_bg_grad_top)); - memset(scene_bg_grad_bot, 0, sizeof(scene_bg_grad_bot)); - memset(scene_gradient, 0, sizeof(scene_gradient)); - scene_gradient_topval = 1.0f; - scene_gradient_botval = 0.0f; - // XXX this has to be recomputed prior to rendering.. - scene_gradient_invrange = 1.0f / (scene_gradient_topval - scene_gradient_botval); - - // zero out the array of material usage counts for the scene - memset(material_special_counts, 0, sizeof(material_special_counts)); - - cam_zoom = 1.0f; - cam_stereo_eyesep = 0.06f; - cam_stereo_convergence_dist = 2.0f; - - clipview_mode = RT_CLIP_NONE; // VR HMD fade+clipping plane/sphere - clipview_start = 1.0f; // VR HMD fade+clipping radial start dist - clipview_end = 0.2f; // VR HMD fade+clipping radial end dist - - // check for VR headlight and HMD/camera view clipping plane/sphere - if (getenv("VMDOPTIXCLIPVIEW")) { - clipview_mode = RT_CLIP_SPHERE; - msgInfo << "OptiXRenderer) Overriding default clipping mode with RT_CLIP_SPHERE" << sendmsg; - } - if (getenv("VMDOPTIXCLIPVIEWSTART")) { - clipview_start = atof(getenv("VMDOPTIXCLIPVIEWSTART")); - msgInfo << "OptiXRenderer) Overriding default clipping start: " - << clipview_start << sendmsg; - } - if (getenv("VMDOPTIXCLIPVIEWEND")) { - clipview_start = atof(getenv("VMDOPTIXCLIPVIEWEND")); - msgInfo << "OptiXRenderer) Overriding default clipping end: " - << clipview_start << sendmsg; - } - - headlight_mode = RT_HEADLIGHT_OFF; // VR HMD headlight disabled by default - if (getenv("VMDOPTIXHEADLIGHT")) { - headlight_mode = RT_HEADLIGHT_ON; - msgInfo << "OptiXRenderer) Overriding default headlight mode with RT_HEADLIGHT_ON" << sendmsg; - } - - shadows_enabled = RT_SHADOWS_OFF; // disable shadows by default - aa_samples = 0; // no AA samples by default - - ao_samples = 0; // no AO samples by default - ao_direct = 0.3f; // AO direct contribution is 30% - ao_ambient = 0.7f; // AO ambient contribution is 70% - ao_maxdist = RT_DEFAULT_MAX; // default is no max occlusion distance - - dof_enabled = 0; // disable DoF by default - cam_dof_focal_dist = 2.0f; - cam_dof_fnumber = 64.0f; - - fog_mode = RT_FOG_NONE; // fog/cueing disabled by default - fog_start = 0.0f; - fog_end = 10.0f; - fog_density = 0.32f; - - verbose = RT_VERB_MIN; // keep console quiet except for perf/debugging cases - check_verbose_env(); // see if the user has overridden verbose flag - - create_context(); - destroy_scene(); // zero out object counters, prepare for rendering - - PROFILE_POP_RANGE(); -} - -/// destructor -OptiXRenderer::~OptiXRenderer(void) { - PROFILE_PUSH_RANGE("OptiXRenderer::~OptiXRenderer()", 0); - - if (context_created) - destroy_context(); - wkf_timer_destroy(ort_timer); - - PROFILE_POP_RANGE(); -} - - -void OptiXRenderer::check_verbose_env() { - verbose = get_verbose_flag(1); -} - - - -// -// This routine enumerates the set of GPUs that are usable by OptiX, -// both in terms of their compatibility with the OptiX library we have -// compiled against, and also in terms of user preferences to exclude -// particular GPUs, GPUs that have displays attached, and so on. -// -unsigned int OptiXRenderer::device_list(int **devlist, char ***devnames) { - OptiXRenderer::Verbosity dl_verbose = get_verbose_flag(); - if (dl_verbose == RT_VERB_DEBUG) - printf("OptiXRenderer) OptiXRenderer::device_list()\n"); - - unsigned int count=0; - RTresult devcntresult = rtDeviceGetDeviceCount(&count); - if (devcntresult != RT_SUCCESS) { -#if OPTIX_VERSION >= 50200 - if (devcntresult == RT_ERROR_OPTIX_NOT_LOADED) { - int cudadevcount = 0; - cudaGetDeviceCount(&cudadevcount); - if (cudadevcount > 0) { - printf("OptiXRenderer) ERROR: Failed to load OptiX shared library.\n"); - printf("OptiXRenderer) NVIDIA driver may be too old.\n"); - printf("OptiXRenderer) Check/update NVIDIA driver\n"); - } - } -#endif - - if (dl_verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) rtDeviceGetDeviceCount() returned error %08x\n", - devcntresult); - printf("OptiXRenderer) No GPUs available\n"); - } - - count = 0; - if (devlist != NULL) - *devlist = NULL; - if (devnames != NULL) - *devnames = NULL; - - return 0; - } - - if (dl_verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) OptiX rtDeviceGetDeviceCount() reports\n"); - printf("OptiXRenderer) that %d GPUs are available\n", count); - } - - // check to see if the user wants to limit what device(s) are used - unsigned int gpumask = 0xffffffff; - const char *gpumaskstr = getenv("VMDOPTIXDEVICEMASK"); - if (gpumaskstr != NULL) { - unsigned int tmp; - if (sscanf(gpumaskstr, "%x", &tmp) == 1) { - gpumask = tmp; - msgInfo << "Using OptiX device mask '" - << gpumaskstr << "'" << sendmsg; - } else { - msgInfo << "Failed to parse OptiX GPU device mask string '" - << gpumaskstr << "'" << sendmsg; - } - } - - if (devlist != NULL) { - *devlist = NULL; - if (count > 0) { - *devlist = (int *) calloc(1, count * sizeof(int)); - } - } - if (devnames != NULL) { - *devnames = NULL; - if (count > 0) { - *devnames = (char **) calloc(1, count * sizeof(char *)); - } - } - - // walk through the list of available devices and screen out - // any that may cause problems with the version of OptiX we are using - unsigned int i, goodcount; - for (goodcount=0,i=0; i 3) { - if (dl_verbose == RT_VERB_DEBUG) { - char msgbuf[1024]; - sprintf(msgbuf, " Excluded GPU[%d] due to unsupported compute capability\n", i); - msgInfo << msgbuf << sendmsg; - } - continue; - } -#endif - - // record all usable GPUs we find... - if (dl_verbose == RT_VERB_DEBUG) { - char msgbuf[1024]; - sprintf(msgbuf, "Found usable GPU[%i]\n", i); - msgInfo << msgbuf << sendmsg; - } - - if (devlist != NULL) { - if (dl_verbose == RT_VERB_DEBUG) { - char msgbuf[1024]; - sprintf(msgbuf, " Adding usable GPU[%i] to list[%d]\n", i, goodcount); - msgInfo << msgbuf << sendmsg; - } - (*devlist)[goodcount] = i; - } - - if (devnames != NULL) { - char *namebuf = (char *) calloc(1, 65 * sizeof(char)); - rtDeviceGetAttribute(i, RT_DEVICE_ATTRIBUTE_NAME, - 64*sizeof(char), namebuf); - if (dl_verbose == RT_VERB_DEBUG) { - char msgbuf[1024]; - sprintf(msgbuf, " Adding usable GPU[%i] to list[%d]: '%s'\n", i, goodcount, namebuf); - msgInfo << msgbuf << sendmsg; - } - (*devnames)[goodcount] = namebuf; - } - goodcount++; - } - - return goodcount; -} - - -unsigned int OptiXRenderer::device_count(void) { - OptiXRenderer::Verbosity dl_verbose = get_verbose_flag(); - if (dl_verbose == RT_VERB_DEBUG) - printf("OptiXRenderer) OptiXRenderer::device_count()\n"); - -#if 1 - return device_list(NULL, NULL); -#else - unsigned int count=0; - if (rtDeviceGetDeviceCount(&count) != RT_SUCCESS) - count = 0; - return count; -#endif -} - - -unsigned int OptiXRenderer::optix_version(void) { - OptiXRenderer::Verbosity dl_verbose = get_verbose_flag(); - if (dl_verbose == RT_VERB_DEBUG) - msgInfo << "OptiXRenderer) OptiXRenderer::optix_version()" << sendmsg; - - unsigned int version=0; - if (rtGetVersion(&version) != RT_SUCCESS) - version = 0; - return version; -} - - -int OptiXRenderer::material_shader_table_size(void) { - // used for initialization info printed to console -#if defined(ORT_USE_TEMPLATE_SHADERS) - return ORTMTABSZ; -#else - return 1; -#endif -} - - -void OptiXRenderer::create_context() { - time_ctx_create = 0; - if (context_created) - return; - - double starttime = wkf_timer_timenow(ort_timer); - - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) creating context...\n"); - -#if defined(ORT_USERTXAPIS) - // Starting with OptiX 6.0.0, the OptiX runtime can select either an - // RTX execution strategy, or a classic non-RTX execution strategy - // using a new global API flag that takes effect at context creation time. - // RTX mode is only supported on Maxwell and later - // GPUs, earlier Kepler hardware do not support RTX mode. - int rtxonoff = 1; - if (getenv("VMDOPTIXNORTX") != NULL) { - rtxonoff = 0; - - // if the RTX mode isn't on, then we can't use the hardware triangle APIs. - rtx_enabled = 0; - hwtri_enabled = 0; - } - - // The OptiX RTX execution strategy mode has to be set very early on, - // otherwise the API call will return without error, but the OptiX - // runtime will ignore the state change and continue with the existing - // execution strategy (e.g. the default of '0' if set too late...) - if (rtGlobalSetAttribute(RT_GLOBAL_ATTRIBUTE_ENABLE_RTX, sizeof(rtxonoff), &rtxonoff) != RT_SUCCESS) { - printf("OptiXRenderer) Error setting RT_GLOBAL_ATTRIBUTE_ENABLE_RTX!!!\n"); - } else { - if (verbose == RT_VERB_TIMING || verbose == RT_VERB_DEBUG) - printf("OptiXRenderer) OptiX RTX execution mode is %s.\n", - (rtxonoff) ? "on" : "off"); - } -#endif - - // Create our objects and set state - RTresult ctxrc; - RTERR2( rtContextCreate(&ctx), ctxrc ); - if (ctxrc != RT_SUCCESS) { - msgErr << "OptiXRenderer) Failed to create OptiX rendering context" << sendmsg; - context_created=0; - return; - } - - // screen and set what GPU device(s) are used for this context - // We shouldn't need the compute capability exclusions post-OptiX 3.6.x, - // but this will benefit from other updates. - if (getenv("VMDOPTIXDEVICEMASK") != NULL) { - int *optixdevlist; - int optixdevcount = device_list(&optixdevlist, NULL); - if (optixdevcount > 0) { - RTERR( rtContextSetDevices(ctx, optixdevcount, optixdevlist) ); - } - free(optixdevlist); - } else if (getenv("VMDOPTIXDEVICE") != NULL) { - int optixdev = atoi(getenv("VMDOPTIXDEVICE")); - msgInfo << "Setting OptiX GPU device to: " << optixdev << sendmsg; - RTERR( rtContextSetDevices(ctx, 1, &optixdev) ); - } - - // register ray types for both shadow and radiance rays - RTERR( rtContextSetRayTypeCount(ctx, RT_RAY_TYPE_COUNT) ); - - // flag to indicate whether we're running in progressive mode or not - RTERR( rtContextDeclareVariable(ctx, "progressive_enabled", &progressive_enabled_v) ); - RTERR( rtVariableSet1i(progressive_enabled_v, 0) ); - - // declare various internal state variables - RTERR( rtContextDeclareVariable(ctx, "max_depth", &max_depth_v) ); - RTERR( rtContextDeclareVariable(ctx, "max_trans", &max_trans_v) ); - RTERR( rtContextDeclareVariable(ctx, "radiance_ray_type", &radiance_ray_type_v) ); - RTERR( rtContextDeclareVariable(ctx, "shadow_ray_type", &shadow_ray_type_v) ); - RTERR( rtContextDeclareVariable(ctx, "scene_epsilon", &scene_epsilon_v) ); - - // create light buffers/variables now, populate at render time... -#if defined(VMDOPTIX_LIGHTUSEROBJS) - RTERR( rtContextDeclareVariable(ctx, "dir_light_list", &dir_light_list_v) ); - RTERR( rtContextDeclareVariable(ctx, "pos_light_list", &pos_light_list_v) ); -#else - RTERR( rtContextDeclareVariable(ctx, "dir_lights", &dir_lightbuffer_v) ); - RTERR( rtBufferCreate(ctx, RT_BUFFER_INPUT, &dir_lightbuffer) ); - RTERR( rtBufferSetFormat(dir_lightbuffer, RT_FORMAT_USER) ); - RTERR( rtBufferSetElementSize(dir_lightbuffer, sizeof(DirectionalLight)) ); - - RTERR( rtContextDeclareVariable(ctx, "pos_lights", &pos_lightbuffer_v) ); - RTERR( rtBufferCreate(ctx, RT_BUFFER_INPUT, &pos_lightbuffer) ); - RTERR( rtBufferSetFormat(pos_lightbuffer, RT_FORMAT_USER) ); - RTERR( rtBufferSetElementSize(pos_lightbuffer, sizeof(PositionalLight)) ); -#endif - - // Current accumulation subframe count, used as part of generating - // AA and AO random number sequences - RTERR( rtContextDeclareVariable(ctx, "accumCount", &accum_count_v) ); - RTERR( rtVariableSet1ui(accum_count_v, 0) ); - - // AO direct lighting scale factors, max occlusion distance - RTERR( rtContextDeclareVariable(ctx, "ao_direct", &ao_direct_v) ); - RTERR( rtContextDeclareVariable(ctx, "ao_ambient", &ao_ambient_v) ); - RTERR( rtContextDeclareVariable(ctx, "ao_maxdist", &ao_maxdist_v) ); - - // shadows, antialiasing, ambient occlusion - RTERR( rtContextDeclareVariable(ctx, "shadows_enabled", &shadows_enabled_v) ); - RTERR( rtContextDeclareVariable(ctx, "aa_samples", &aa_samples_v) ); - RTERR( rtContextDeclareVariable(ctx, "ao_samples", &ao_samples_v) ); - - // background color / gradient - RTERR( rtContextDeclareVariable(ctx, "scene_bg_color", &scene_bg_color_v) ); - RTERR( rtContextDeclareVariable(ctx, "scene_bg_color_grad_top", &scene_bg_grad_top_v) ); - RTERR( rtContextDeclareVariable(ctx, "scene_bg_color_grad_bot", &scene_bg_grad_bot_v) ); - RTERR( rtContextDeclareVariable(ctx, "scene_gradient", &scene_gradient_v) ); - RTERR( rtContextDeclareVariable(ctx, "scene_gradient_topval", &scene_gradient_topval_v) ); - RTERR( rtContextDeclareVariable(ctx, "scene_gradient_botval", &scene_gradient_botval_v) ); - RTERR( rtContextDeclareVariable(ctx, "scene_gradient_invrange", &scene_gradient_invrange_v) ); - - // VR HMD variables - RTERR( rtContextDeclareVariable(ctx, "clipview_mode", &clipview_mode_v) ); - RTERR( rtContextDeclareVariable(ctx, "clipview_start", &clipview_start_v) ); - RTERR( rtContextDeclareVariable(ctx, "clipview_end", &clipview_end_v) ); - RTERR( rtContextDeclareVariable(ctx, "headlight_mode", &headlight_mode_v) ); - - // cueing/fog variables - RTERR( rtContextDeclareVariable(ctx, "fog_mode", &fog_mode_v) ); - RTERR( rtContextDeclareVariable(ctx, "fog_start", &fog_start_v) ); - RTERR( rtContextDeclareVariable(ctx, "fog_end", &fog_end_v) ); - RTERR( rtContextDeclareVariable(ctx, "fog_density", &fog_density_v) ); - - // variables for top level scene graph objects - RTERR( rtContextDeclareVariable(ctx, "root_object", &root_object_v) ); - RTERR( rtContextDeclareVariable(ctx, "root_shadower", &root_shadower_v) ); - - // define all of the standard camera params - RTERR( rtContextDeclareVariable(ctx, "cam_zoom", &cam_zoom_v) ); - RTERR( rtContextDeclareVariable(ctx, "cam_pos", &cam_pos_v) ); - RTERR( rtContextDeclareVariable(ctx, "cam_U", &cam_U_v) ); - RTERR( rtContextDeclareVariable(ctx, "cam_V", &cam_V_v) ); - RTERR( rtContextDeclareVariable(ctx, "cam_W", &cam_W_v) ); - - // define stereoscopic camera parameters - RTERR( rtContextDeclareVariable(ctx, "cam_stereo_eyesep", &cam_stereo_eyesep_v) ); - RTERR( rtContextDeclareVariable(ctx, "cam_stereo_convergence_dist", &cam_stereo_convergence_dist_v) ); - - // define camera DoF parameters - RTERR( rtContextDeclareVariable(ctx, "cam_dof_focal_dist", &cam_dof_focal_dist_v) ); - RTERR( rtContextDeclareVariable(ctx, "cam_dof_aperture_rad", &cam_dof_aperture_rad_v) ); - - RTERR( rtContextDeclareVariable(ctx, "accumulation_normalization_factor", &accum_norm_v) ); - - - // - // allow runtime override of the default shader path for testing - // this has to be done prior to all calls that load programs from - // the shader PTX - // - if (getenv("VMDOPTIXSHADERPATH")) { - strcpy(shaderpath, getenv("VMDOPTIXSHADERPATH")); - if (verbose == RT_VERB_DEBUG) - printf("OptiXRenderer) user-override shaderpath: '%s'\n", shaderpath); - } - - if (verbose >= RT_VERB_TIMING) { - printf("OptiXRenderer) creating shader programs...\n"); - fflush(stdout); - } - - // load and initialize all of the material programs - init_materials(); - - double time_materials = wkf_timer_timenow(ort_timer); - if (verbose >= RT_VERB_TIMING) { - printf("OptiXRenderer) "); - printf("materials(%.1f) ", time_materials - starttime); - fflush(stdout); - } - -#if defined(ORT_RAYSTATS) - // program for clearing the raystats buffers - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "clear_raystats_buffers", &clear_raystats_buffers_pgm) ); -#endif - - // program for clearing the accumulation buffer - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "clear_accumulation_buffer", &clear_accumulation_buffer_pgm) ); - - // program for copying the accumulation buffer to the framebuffer - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "draw_accumulation_buffer", &draw_accumulation_buffer_pgm) ); - - // empty placeholder program for copying the accumulation buffer - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "draw_accumulation_buffer_stub", &draw_accumulation_buffer_stub_pgm) ); - - double time_fbops = wkf_timer_timenow(ort_timer); - if (verbose >= RT_VERB_TIMING) { - printf("fbops(%.1f) ", time_fbops - time_materials); - fflush(stdout); - } - - // register cubemap VR camera ray gen programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_cubemap", &ray_gen_pgm_cubemap) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_cubemap_dof", &ray_gen_pgm_cubemap_dof) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_cubemap_stereo", &ray_gen_pgm_cubemap_stereo) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_cubemap_stereo_dof", &ray_gen_pgm_cubemap_stereo_dof) ); - - // register planetarium dome master camera ray gen programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_dome_master", &ray_gen_pgm_dome_master) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_dome_master_dof", &ray_gen_pgm_dome_master_dof) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_dome_master_stereo", &ray_gen_pgm_dome_master_stereo) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_dome_master_stereo_dof", &ray_gen_pgm_dome_master_stereo_dof) ); - - // register 360-degree equirectantular projection of spherical camera - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_equirectangular", &ray_gen_pgm_equirectangular) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_equirectangular_dof", &ray_gen_pgm_equirectangular_dof) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_equirectangular_stereo", &ray_gen_pgm_equirectangular_stereo) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_equirectangular_stereo_dof", &ray_gen_pgm_equirectangular_stereo_dof) ); - - // register Oculus Rift projection - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_oculus_rift", &ray_gen_pgm_oculus_rift) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_oculus_rift_dof", &ray_gen_pgm_oculus_rift_dof) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_oculus_rift_stereo", &ray_gen_pgm_oculus_rift_stereo) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_oculus_rift_stereo_dof", &ray_gen_pgm_oculus_rift_stereo_dof) ); - - // register perspective camera ray gen programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_perspective", &ray_gen_pgm_perspective) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_perspective_dof", &ray_gen_pgm_perspective_dof) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_perspective_stereo", &ray_gen_pgm_perspective_stereo) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_perspective_stereo_dof", &ray_gen_pgm_perspective_stereo_dof) ); - - // register othographic camera ray gen programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_orthographic", &ray_gen_pgm_orthographic) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_orthographic_dof", &ray_gen_pgm_orthographic_dof) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_orthographic_stereo", &ray_gen_pgm_orthographic_stereo) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, - "vmd_camera_orthographic_stereo_dof", &ray_gen_pgm_orthographic_stereo_dof) ); - - // miss programs for background (solid, gradient sphere/plane) - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "miss_gradient_bg_sky_sphere", &miss_pgm_sky_sphere) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "miss_gradient_bg_sky_plane", &miss_pgm_sky_ortho_plane) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "miss_solid_bg", &miss_pgm_solid) ); - - // exception handler program - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "exception", &exception_pgm) ); - - double time_cambgops = wkf_timer_timenow(ort_timer); - if (verbose >= RT_VERB_TIMING) { - printf("cambgops(%.1f) ", time_cambgops - time_fbops); - fflush(stdout); - } - - // cylinder array programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "cylinder_array_bounds", &cylinder_array_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "cylinder_array_intersect", &cylinder_array_isct_pgm) ); - - // color-per-cylinder array programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "cylinder_array_color_bounds", &cylinder_array_color_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "cylinder_array_color_intersect", &cylinder_array_color_isct_pgm) ); - - // color-per-ring array programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "ring_array_color_bounds", &ring_array_color_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "ring_array_color_intersect", &ring_array_color_isct_pgm) ); - - // sphere array programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "sphere_array_bounds", &sphere_array_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "sphere_array_intersect", &sphere_array_isct_pgm) ); - - // color-per-sphere array programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "sphere_array_color_bounds", &sphere_array_color_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "sphere_array_color_intersect", &sphere_array_color_isct_pgm) ); - - // tricolor list programs - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "tricolor_bounds", &tricolor_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "tricolor_intersect", &tricolor_isct_pgm) ); - - // c4u_n3b_v3f - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_c4u_n3b_v3f_bounds", &trimesh_c4u_n3b_v3f_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_c4u_n3b_v3f_intersect", &trimesh_c4u_n3b_v3f_isct_pgm) ); - - // n3f_v3f - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_n3f_v3f_bounds", &trimesh_n3f_v3f_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_n3f_v3f_intersect", &trimesh_n3f_v3f_isct_pgm) ); - - // n3b_v3f - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_n3b_v3f_bounds", &trimesh_n3b_v3f_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_n3b_v3f_intersect", &trimesh_n3b_v3f_isct_pgm) ); - - // v3f - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_v3f_bounds", &trimesh_v3f_bbox_pgm) ); - RTERR( rtProgramCreateFromPTXFile(ctx, shaderpath, "trimesh_v3f_intersect", &trimesh_v3f_isct_pgm) ); - - double time_geompgms = wkf_timer_timenow(ort_timer); - if (verbose >= RT_VERB_TIMING) { - printf("geompgms(%.1f) ", time_geompgms - time_cambgops); - fflush(stdout); - } - - if (verbose >= RT_VERB_TIMING) { - printf("\n"); - } - - time_ctx_create = wkf_timer_timenow(ort_timer) - starttime; - - if (verbose == RT_VERB_TIMING || verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) context creation time: %.2f\n", time_ctx_create); - } - - context_created = 1; -} - - -void OptiXRenderer::setup_context(int w, int h) { - double starttime = wkf_timer_timenow(ort_timer); - time_ctx_setup = 0; - - lasterror = RT_SUCCESS; // clear any error state - width = w; - height = h; - - if (!context_created) - return; - - check_verbose_env(); // update verbose flag if changed since last run - - // set default global ray tracing recursion depth and/or allow - // runtime user override here. - scene_max_depth = 20; - if (getenv("VMDOPTIXMAXDEPTH")) { - int maxdepth = atoi(getenv("VMDOPTIXMAXDEPTH")); - if (maxdepth > 0 && maxdepth <= 30) { - printf("OptiXRenderer) Setting maxdepth to %d...\n", maxdepth); - scene_max_depth = maxdepth; // set context-wide property - RTERR( rtVariableSet1ui(max_depth_v, scene_max_depth) ); - } else { - printf("OptiXRenderer) ignoring out-of-range maxdepth to %d...\n", maxdepth); - } - } - - scene_max_trans = scene_max_depth; - if (getenv("VMDOPTIXMAXTRANS")) { - int maxtrans = atoi(getenv("VMDOPTIXMAXTRANS")); - if (maxtrans > 0 && maxtrans <= 30) { - printf("OptiXRenderer) Setting maxtrans to %d...\n", maxtrans); - scene_max_trans = maxtrans; // set context-wide property - RTERR( rtVariableSet1ui(max_trans_v, scene_max_trans) ); - } else { - printf("OptiXRenderer) ignoring out-of-range maxtrans to %d...\n", maxtrans); - } - } - - // set maxdepth and maxtrans with new values - RTERR( rtVariableSet1ui(max_depth_v, scene_max_depth) ); - RTERR( rtVariableSet1ui(max_trans_v, scene_max_trans) ); - - // assign indices to ray types - RTERR( rtVariableSet1ui(radiance_ray_type_v, 0u) ); - RTERR( rtVariableSet1ui(shadow_ray_type_v, 1u) ); - - // set default scene epsilon - float scene_epsilon = 5.e-5f; - RTERR( rtVariableSet1f(scene_epsilon_v, scene_epsilon) ); - - // Current accumulation subframe count, used as part of generating - // AA and AO random number sequences - RTERR( rtVariableSet1ui(accum_count_v, 0) ); - - // zero out the array of material usage counts for the scene - memset(material_special_counts, 0, sizeof(material_special_counts)); - time_ctx_setup = wkf_timer_timenow(ort_timer) - starttime; -} - - -void OptiXRenderer::report_context_stats() { - if (!context_created) - return; - - unsigned int ctx_varcount=0; - RTERR( rtContextGetVariableCount(ctx, &ctx_varcount) ); - printf("OptiXRenderer) ctx var cnt: %u\n", ctx_varcount); -} - - -void OptiXRenderer::destroy_scene() { - double starttime = wkf_timer_timenow(ort_timer); - time_ctx_destroy_scene = 0; - - // zero out all object counters - cylinder_array_cnt = 0; - cylinder_array_color_cnt = 0; - ring_array_color_cnt = 0; - sphere_array_cnt = 0; - sphere_array_color_cnt = 0; - tricolor_cnt = 0; - trimesh_c4u_n3b_v3f_cnt = 0; - trimesh_n3b_v3f_cnt = 0; - trimesh_n3f_v3f_cnt = 0; - trimesh_v3f_cnt = 0; - - if (!context_created) - return; - - if (scene_created) { - int i; - - RTERR( rtAccelerationDestroy(acceleration) ); -#if defined(ORT_USERTXAPIS) - // OptiX RTX hardware-accelerated triangles API - RTERR( rtAccelerationDestroy(trianglesacceleration) ); -#endif - - RTERR( rtAccelerationDestroy(root_acceleration) ); - RTERR( rtGroupDestroy(root_group) ); - - RTERR( rtGeometryGroupDestroy(geometrygroup) ); -#if defined(ORT_USERTXAPIS) - // OptiX RTX hardware-accelerated triangles API - RTERR( rtGeometryGroupDestroy(geometrytrianglesgroup) ); -#endif - - int instcount = geominstancelist.num(); - for (i=0; i= 60500) - // XXX Destroying the RTX triangle instances can cause crashes, - // both in the OptiX 5.2 DEV build w/ triangle API 0.3, - // and also the production OptiX 6.0.0 build w/ driver 418.30. - // This may be caused by an interaction between our use of - // RT_GEOMETRY_BUILD_FLAG_RELEASE_BUFFERS in the triangle APIs - // and the instance nodes. - // As of OptiX 6.5.0 and driver version 440.44, this problem - // seems to be corrected, and this workaround is no longer needed. - int insttrianglescount = geomtrianglesinstancelist.num(); - for (i=0; i 0) { - printf("OptiXRenderer) material_special[%d] usage count: %d\n", - i, material_special_counts[i]); - - printf("OptiXRenderer) " - "ClipView %s, " - "Headlight %s, " - "Fog %s, " - "Shadows %s, " - "AO %s, " - "Outline %s, " - "Refl %s, " - "Trans %s\n", -#if defined(VMDOPTIX_VCA_TABSZHACK) - onoffstr(1), - onoffstr(1), -#else - onoffstr(i & 128), - onoffstr(i & 64), -#endif - onoffstr(i & 32), - onoffstr(i & 16), - onoffstr(i & 8), - onoffstr(i & 4), - onoffstr(i & 2), - onoffstr(i & 1)); - } - } - printf("OptiXRenderer)\n"); - } else { - printf("OptiXRenderer) using fully general shader and materials.\n"); - } -#else - printf("OptiXRenderer) using fully general shader and materials.\n"); -#endif - } - - RTERR( rtVariableSet3fv(scene_bg_color_v, scene_bg_color) ); - RTERR( rtVariableSet3fv(scene_bg_grad_top_v, scene_bg_grad_top) ); - RTERR( rtVariableSet3fv(scene_bg_grad_bot_v, scene_bg_grad_bot) ); - RTERR( rtVariableSet3fv(scene_gradient_v, scene_gradient) ); - RTERR( rtVariableSet1f(scene_gradient_topval_v, scene_gradient_topval) ); - RTERR( rtVariableSet1f(scene_gradient_botval_v, scene_gradient_botval) ); - - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) HMD/camera view clipping mode: %d start: %.2f end: %.2f\n", - clipview_mode, clipview_start, clipview_end); - - printf("OptiXRenderer) HMD/camera headlight mode: %d\n", headlight_mode); - - printf("OptiXRenderer) scene bg mode: %d\n", scene_background_mode); - - printf("OptiXRenderer) scene bgsolid: %.2f %.2f %.2f\n", - scene_bg_color[0], scene_bg_color[1], scene_bg_color[2]); - - printf("OptiXRenderer) scene bggradT: %.2f %.2f %.2f\n", - scene_bg_grad_top[0], scene_bg_grad_top[1], scene_bg_grad_top[2]); - - printf("OptiXRenderer) scene bggradB: %.2f %.2f %.2f\n", - scene_bg_grad_bot[0], scene_bg_grad_bot[1], scene_bg_grad_bot[2]); - - printf("OptiXRenderer) bg gradient: %f %f %f top: %f bot: %f\n", - scene_gradient[0], scene_gradient[1], scene_gradient[2], - scene_gradient_topval, scene_gradient_botval); - } - - // update in case the caller changed top/bottom values since last recalc - scene_gradient_invrange = 1.0f / (scene_gradient_topval - scene_gradient_botval); - RTERR( rtVariableSet1f(scene_gradient_invrange_v, scene_gradient_invrange) ); - - RTERR( rtVariableSet1i(clipview_mode_v, clipview_mode) ); - RTERR( rtVariableSet1f(clipview_start_v, clipview_start) ); - RTERR( rtVariableSet1f(clipview_end_v, clipview_end) ); - RTERR( rtVariableSet1i(headlight_mode_v, (int) headlight_mode) ); - - RTERR( rtVariableSet1i(fog_mode_v, (int) fog_mode) ); - RTERR( rtVariableSet1f(fog_start_v, fog_start) ); - RTERR( rtVariableSet1f(fog_end_v, fog_end) ); - RTERR( rtVariableSet1f(fog_density_v, fog_density) ); - - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) adding lights: dir: %ld pos: %ld\n", - directional_lights.num(), positional_lights.num()); - } - -#if defined(VMDOPTIX_LIGHTUSEROBJS) - DirectionalLightList dir_lights; - memset(&dir_lights, 0, sizeof(DirectionalLightList)); - dir_lights.num_lights = directional_lights.num(); - int dlcount = directional_lights.num(); - dlcount = (dlcount > DISP_LIGHTS) ? DISP_LIGHTS : dlcount; - for (i=0; i DISP_LIGHTS) ? DISP_LIGHTS : plcount; - for (i=0; i= 3050) && (OPTIX_VERSION < 3060) || (OPTIX_VERSION == 3063) || (OPTIX_VERSION == 3080) - // OptiX 3.5.0 was the first to include the new fast "Trbvh" AS builder - // OptiX 3.6.3 fixed Trbvh bugs on huge models - // OptiX 3.8.0 has cured all known Trbvh bugs for VMD so far - RTERR( rtAccelerationSetBuilder(acceleration, "Trbvh") ); - RTERR( rtAccelerationSetTraverser(acceleration, "Bvh") ); -#else - // For older revs of OptiX (or those with bugs in Trbvh), - // the "MedianBvh" AS builder gives the best compromise between - // builder speed and ray tracing speed. - // OptiX 3.6.[012] and 3.7.0 had Trbvh bugs on huge models that - // could cause VMD to crash in some cases -// RTERR( rtAccelerationSetBuilder(acceleration, "Sbvh") ); -// RTERR( rtAccelerationSetBuilder(acceleration, "Bvh") ); - RTERR( rtAccelerationSetBuilder(acceleration, "MedianBvh") ); - RTERR( rtAccelerationSetTraverser(acceleration, "Bvh") ); -#endif - } - - - // allow user-override of the builder type (e.g. "GPU", or "CPU") when - // the AS builder provides more than one choice. - if (getenv("VMDOPTIXBUILDTYPE") != NULL) { - const char *buildtypestr = getenv("VMDOPTIXBUILDTYPE"); - const char *curbuilderstr = NULL; - RTERR( rtAccelerationGetBuilder(acceleration, &curbuilderstr) ); - if (!strcmp(curbuilderstr, "Trbvh")) { - msgInfo << "OptiXRenderer) user-override of Trbvh AS build type: " - << buildtypestr << sendmsg; - RTERR( rtAccelerationSetProperty(acceleration, "build_type", buildtypestr) ); - } else { - msgErr << "OptiXRenderer) Can't set build type for AS builders other than Trbvh" << sendmsg; - } - } - - - RTERR( rtGeometryGroupSetAcceleration(geometrygroup, acceleration) ); - RTERR( rtAccelerationMarkDirty(acceleration) ); - -#if defined(ORT_USERTXAPIS) - // OptiX RTX hardware-accelerated triangles API - // Acceleration structure for triangle geometry - RTERR( rtAccelerationCreate(ctx, &trianglesacceleration) ); - RTERR( rtAccelerationSetBuilder(trianglesacceleration, "Trbvh") ); - RTERR( rtAccelerationSetTraverser(trianglesacceleration, "Bvh") ); - RTERR( rtGeometryGroupSetAcceleration(geometrytrianglesgroup, trianglesacceleration) ); - RTERR( rtAccelerationMarkDirty(trianglesacceleration) ); -#endif - - - // create the root node of the scene graph - RTERR( rtGroupCreate(ctx, &root_group) ); -#if defined(ORT_USERTXAPIS) - RTERR( rtGroupSetChildCount(root_group, 2) ); - RTERR( rtGroupSetChild(root_group, 0, geometrygroup) ); - RTERR( rtGroupSetChild(root_group, 1, geometrytrianglesgroup) ); -#else - RTERR( rtGroupSetChildCount(root_group, 1) ); - RTERR( rtGroupSetChild(root_group, 0, geometrygroup) ); -#endif - RTERR( rtVariableSetObject(root_object_v, root_group) ); - RTERR( rtVariableSetObject(root_shadower_v, root_group) ); - - // create an acceleration object for the entire scene graph - RTERR( rtAccelerationCreate(ctx, &root_acceleration) ); - RTERR( rtAccelerationSetBuilder(root_acceleration,"NoAccel") ); - RTERR( rtAccelerationSetTraverser(root_acceleration,"NoAccel") ); - RTERR( rtGroupSetAcceleration(root_group, root_acceleration) ); - RTERR( rtAccelerationMarkDirty(root_acceleration) ); - scene_created=1; - - - // do final state variable updates before rendering begins - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) cam zoom factor %f\n", cam_zoom); - printf("OptiXRenderer) cam stereo eye separation %f\n", cam_stereo_eyesep); - printf("OptiXRenderer) cam stereo convergence distance %f\n", - cam_stereo_convergence_dist); - printf("OptiXRenderer) cam DoF focal distance %f\n", cam_dof_focal_dist); - printf("OptiXRenderer) cam DoF f/stop %f\n", cam_dof_fnumber); - } - - // define all of the standard camera params - RTERR( rtVariableSet1f(cam_zoom_v, cam_zoom) ); - RTERR( rtVariableSet3f( cam_pos_v, 0.0f, 0.0f, 2.0f) ); - RTERR( rtVariableSet3f( cam_U_v, 1.0f, 0.0f, 0.0f) ); - RTERR( rtVariableSet3f( cam_V_v, 0.0f, 1.0f, 0.0f) ); - RTERR( rtVariableSet3f( cam_W_v, 0.0f, 0.0f, -1.0f) ); - - // define stereoscopic camera parameters - RTERR( rtVariableSet1f(cam_stereo_eyesep_v, cam_stereo_eyesep) ); - RTERR( rtVariableSet1f(cam_stereo_convergence_dist_v, cam_stereo_convergence_dist) ); - - // define camera DoF parameters - RTERR( rtVariableSet1f(cam_dof_focal_dist_v, cam_dof_focal_dist) ); - RTERR( rtVariableSet1f(cam_dof_aperture_rad_v, cam_dof_focal_dist / (2.0f * cam_zoom * cam_dof_fnumber)) ); - - // for batch mode rendering, we prefer correctness to speed, so - // we currently ignore USE_REVERSE_SHADOW_RAYS_DEFAULT except when - // running interactively. When the reverse ray optimizatoin is 100% - // bulletproof, we will use it for batch rendering also. - RTERR( rtVariableSet1i(shadows_enabled_v, - (shadows_enabled) ? RT_SHADOWS_ON : RT_SHADOWS_OFF) ); - - RTERR( rtVariableSet1i(ao_samples_v, ao_samples) ); - RTERR( rtVariableSet1f(ao_ambient_v, ao_ambient) ); - RTERR( rtVariableSet1f(ao_direct_v, ao_direct) ); - RTERR( rtVariableSet1f(ao_maxdist_v, ao_maxdist) ); - if (getenv("VMDOPTIXAOMAXDIST")) { - float tmp = atof(getenv("VMDOPTIXAOMAXDIST")); - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) setting AO maxdist: %f\n", tmp); - } - RTERR( rtVariableSet1f(ao_maxdist_v, tmp) ); - } - - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) setting sample counts: AA %d AO %d\n", aa_samples, ao_samples); - printf("OptiXRenderer) setting AO factors: AOA %f AOD %f\n", ao_ambient, ao_direct); - } - - // - // Handle AA samples either internally with loops internal to - // each ray launch point thread, or externally by iterating over - // multiple launches, adding each sample to an accumulation buffer, - // or a hybrid combination of the two. The final framebuffer output - // is written by launching a special accumulation buffer drawing - // program that range clamps and converts the pixel data while copying - // the GPU-local accumulation buffer to the final output buffer... - // - ext_aa_loops = 1; - int totrays = (aa_samples + 1) * ((ao_samples > 0) ? ao_samples : 1); - int maxrayspass = 16; - if (getenv("VMDOPTIXMAXRAYSPERPASS") != NULL) { - maxrayspass = atoi(getenv("VMDOPTIXMAXRAYSPERPASS")); - printf("OptiXRenderer) User-override of max rays per pass: %d\n", maxrayspass); - } - if ((getenv("VMDOPTIXFORCEMULTIPASS") != NULL) || (totrays > maxrayspass)) { - // if we have too much work for a single-pass rendering, we need to - // break it up into multiple passes or we risk having kernel timeouts - ext_aa_loops = 1 + aa_samples; - RTERR( rtVariableSet1i(aa_samples_v, 1) ); - } else { - // if the scene is simple, e.g. no AO rays and AA sample count is small, - // we can run it in a single pass and get better performance - RTERR( rtVariableSet1i(aa_samples_v, aa_samples + 1) ); - } - RTERR( rtVariableSet1f(accum_norm_v, 1.0f / float(1 + aa_samples)) ); - - if (verbose == RT_VERB_DEBUG) { - if (ext_aa_loops > 1) - printf("OptiXRenderer) Running OptiX multi-pass: %d loops\n", ext_aa_loops); - else - printf("OptiXRenderer) Running OptiX single-pass: %d total samples\n", 1+aa_samples); - } - - // set the ray generation program to the active camera code... - RTERR( rtContextSetEntryPointCount(ctx, RT_RAY_GEN_COUNT) ); - RTERR( rtContextSetRayGenerationProgram(ctx, RT_RAY_GEN_CLEAR_ACCUMULATION_BUFFER, clear_accumulation_buffer_pgm) ); -#if defined(ORT_RAYSTATS) - RTERR( rtContextSetRayGenerationProgram(ctx, RT_RAY_GEN_CLEAR_RAYSTATS, clear_raystats_buffers_pgm) ); -#endif - - // set the active color accumulation ray gen program based on the - // camera/projection mode, stereoscopic display mode, - // and depth-of-field state - set_accum_raygen_pgm(camera_projection, 0, dof_enabled); - - // - // set the ray gen program to use for the copy/finish operations - // -#if defined(VMDOPTIX_PROGRESSIVEAPI) - if (interactive) { - RTERR( rtContextSetRayGenerationProgram(ctx, RT_RAY_GEN_COPY_FINISH, draw_accumulation_buffer_stub_pgm) ); - } else -#endif - { - RTERR( rtContextSetRayGenerationProgram(ctx, RT_RAY_GEN_COPY_FINISH, draw_accumulation_buffer_pgm) ); - } - - // Link up miss program depending on background rendering mode - switch (scene_background_mode) { - case RT_BACKGROUND_TEXTURE_SKY_SPHERE: - RTERR( rtContextSetMissProgram(ctx, RT_RAY_TYPE_RADIANCE, miss_pgm_sky_sphere) ); - break; - - case RT_BACKGROUND_TEXTURE_SKY_ORTHO_PLANE: - RTERR( rtContextSetMissProgram(ctx, RT_RAY_TYPE_RADIANCE, miss_pgm_sky_ortho_plane) ); - break; - - case RT_BACKGROUND_TEXTURE_SOLID: - default: - RTERR( rtContextSetMissProgram(ctx, RT_RAY_TYPE_RADIANCE, miss_pgm_solid) ); - break; - } - - // enable exception handling for all defined entry points - unsigned int epcnt=0; - RTERR( rtContextGetEntryPointCount(ctx, &epcnt) ); - unsigned int epidx; - for (epidx=0; epidx= 60000) - // When running in RTX mode, OptiX >= 6.x provides an API to set - // the maximum trace depth which is used to automatically compute the - // required stack size. - if (rtx_enabled) { - // We need to tell OptiX to allow a recursion depth that includes - // not only the surface hit, but also shadow feelers and any other - // secondary rays that aren't being tracked explicitly by the - // internal recursion depth counter implemented in the top level - // ray gen and shading code. - int newmaxdepth = scene_max_depth + 1; - - // A last-ditch workaround for issues observed in the field where - // the requested max trace depth somehow didn't provide sufficient - // stack space in practice. This can be used for force OptiX to - // use the maximum stack size allowed by the RTX runtime. - if (getenv("VMDOPTIXMAXSTACKSIZE")) { - printf("OptiXRenderer) Setting RTX runtime to max depth / stack size\n"); - - // The maximum recursion depth supported by OptiX 6.0 is 31. - newmaxdepth = 31; - } - - // Enforce maximum supported trace depth limit. - // The maximum recursion depth supported by OptiX 6.0 is 31. - if (newmaxdepth > 31) - newmaxdepth = 31; - - RTERR( rtContextSetMaxTraceDepth(ctx, newmaxdepth) ); - RTERR( rtContextSetMaxCallableProgramDepth(ctx, newmaxdepth) ); - - stacksizeadjusted = 1; - } -#endif - - // When not running in RTX mode, we revert to the old OptiX [1-5.x] - // stack size APIs to set the stack size required for VMD scenes - // with a typical recursion depth. - // XXX The rtContext[GS]etStackSize() APIs are not supported when - // using the RTX execution strategy. Although they don't (yet) - // return errors in that case, we protect against calling them here - // except when running in a non-RTX mode. Presumably these APIs will - // be deprecated in future OptiX releases. - if (!stacksizeadjusted) { - // increase default OptiX stack size to prevent runtime failures - RTsize ssz; - rtContextGetStackSize(ctx, &ssz); - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) original stack size: %ld\n", ssz); - - // a decent default stack size is 7KB - long newstacksize = 7 * 1024; - - // allow runtime user override of the OptiX stack size in - // case we need to render a truly massive scene - if (getenv("VMDOPTIXSTACKSIZE")) { - newstacksize = atoi(getenv("VMDOPTIXSTACKSIZE")); - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) user stack size override: %ld\n", newstacksize); - } - rtContextSetStackSize(ctx, newstacksize); - rtContextGetStackSize(ctx, &ssz); - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) new stack size: %ld\n", ssz); - } - -#if !defined(VMDOPTIX_PROGRESSIVEAPI) - // Set print buffer size when using the old non-progressive APIs - rtContextSetPrintEnabled(ctx, 1); - rtContextSetPrintBufferSize(ctx, 1*1024*1024); -#endif - -#if defined(VMD_ENABLE_OPTIX_TIMEOUTS) - // Add a custom OptiX timeout callback to see if we can overcome - // some of the timeout issues we've had previously - double timeoutlimit = 0.5; - const char *tmstr = getenv("VMDOPTIXTIMEOUTLIMIT"); - if (tmstr) { - timeoutlimit = atof(tmstr); - printf("Setting OptiX timeout: %f sec\n", timeoutlimit); - } - - if (verbose == RT_VERB_DEBUG) - printf("Setting OptiX timeout: %f sec\n", timeoutlimit); - - RTERR( rtContextSetTimeoutCallback(ctx, vmd_timeout_cb, timeoutlimit) ); -#endif -} - - -void OptiXRenderer::framebuffer_config(int fbwidth, int fbheight, - int interactive) { - if (!context_created) - return; - - width = fbwidth; - height = fbheight; - -#ifdef VMDOPTIX_PROGRESSIVEAPI - // If VMD is using the progressive APIs, we have to check that - // the requested framebuffer config matches the existing one in - // terms of bindings for streaming output, otherwise we have to - // destroy and re-create the framebuffer and any needed streaming - // bindings. - if (buffers_progressive != (interactive != 0)) { - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) switching between progressive/non-progressive mode\n"); - printf("OptiXRenderer) remaking framebuffer\n"); - } - framebuffer_destroy(); - } -#endif - - // allocate and resize buffers to match request - if (buffers_allocated) { - // if the buffers already exist and match the current - // progressive/non-progressive rendering mode, just resize them - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) resizing framebuffer\n"); - } - framebuffer_resize(width, height); - } else { - // (re)allocate framebuffer and associated accumulation buffers if they - // don't already exist or if they weren't bound properly for - // current progressive/non-progressive rendering needs. - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) creating framebuffer and accum. buffer\n"); - } - - // create intermediate GPU-local accumulation buffer - RTERR( rtContextDeclareVariable(ctx, "accumulation_buffer", &accumulation_buffer_v) ); - -#ifdef VMDOPTIX_PROGRESSIVEAPI - if (interactive) { - RTERR( rtBufferCreate(ctx, RT_BUFFER_OUTPUT, &accumulation_buffer) ); - buffers_progressive = 1; - } else -#endif - { - RTERR( rtBufferCreate(ctx, RT_BUFFER_INPUT_OUTPUT | RT_BUFFER_GPU_LOCAL, &accumulation_buffer) ); - buffers_progressive = 0; - } - - RTERR( rtBufferSetFormat(accumulation_buffer, RT_FORMAT_FLOAT4) ); - RTERR( rtBufferSetSize2D(accumulation_buffer, width, height) ); - RTERR( rtVariableSetObject(accumulation_buffer_v, accumulation_buffer) ); - -#if defined(ORT_RAYSTATS) - // (re)create intermediate GPU-local ray stats buffers - // the ray stat buffers get cleared when clearing the accumulation buffer - RTERR( rtContextDeclareVariable(ctx, "raystats1_buffer", &raystats1_buffer_v) ); - RTERR( rtBufferCreate(ctx, RT_BUFFER_OUTPUT, &raystats1_buffer) ); - RTERR( rtBufferSetFormat(raystats1_buffer, RT_FORMAT_UNSIGNED_INT4) ); - RTERR( rtBufferSetSize2D(raystats1_buffer, width, height) ); - RTERR( rtVariableSetObject(raystats1_buffer_v, raystats1_buffer) ); - - RTERR( rtContextDeclareVariable(ctx, "raystats2_buffer", &raystats2_buffer_v) ); - RTERR( rtBufferCreate(ctx, RT_BUFFER_OUTPUT, &raystats2_buffer) ); - RTERR( rtBufferSetFormat(raystats2_buffer, RT_FORMAT_UNSIGNED_INT4) ); - RTERR( rtBufferSetSize2D(raystats2_buffer, width, height) ); - RTERR( rtVariableSetObject(raystats2_buffer_v, raystats2_buffer) ); -#endif - - // create output framebuffer -#ifdef VMDOPTIX_PROGRESSIVEAPI - if (interactive) { - RTERR( rtBufferCreate(ctx, RT_BUFFER_PROGRESSIVE_STREAM, &framebuffer) ); - - // allow user-override of default 5 Mbit/s video encoding bit rate - int stream_bitrate = 5000000; - if (getenv("VMDOPTIXBITRATE")) - stream_bitrate = atoi(getenv("VMDOPTIXBITRATE")); - RTERR( rtBufferSetAttribute(framebuffer, RT_BUFFER_ATTRIBUTE_STREAM_BITRATE, sizeof(int), &stream_bitrate) ); - - // allow user-override of default 30 FPS target frame rate - int stream_fps = 30; - if (getenv("VMDOPTIXFPS")) - stream_fps = atoi(getenv("VMDOPTIXFPS")); - RTERR( rtBufferSetAttribute(framebuffer, RT_BUFFER_ATTRIBUTE_STREAM_FPS, sizeof(int), &stream_fps) ); - - // allow user-override of Gamma - float stream_gamma = 1.0f; - if (getenv("VMDOPTIXGAMMS")) - stream_gamma = atoi(getenv("VMDOPTIXGAMMA")); - RTERR( rtBufferSetAttribute(framebuffer, RT_BUFFER_ATTRIBUTE_STREAM_GAMMA, sizeof(float), &stream_gamma) ); - } else -#endif - { - RTERR( rtBufferCreate(ctx, RT_BUFFER_OUTPUT, &framebuffer) ); - } - - RTERR( rtBufferSetFormat(framebuffer, RT_FORMAT_UNSIGNED_BYTE4) ); - RTERR( rtBufferSetSize2D(framebuffer, width, height) ); - -#ifdef VMDOPTIX_PROGRESSIVEAPI - if (interactive) { - RTERR( rtBufferBindProgressiveStream( framebuffer, accumulation_buffer) ); - } else -#endif - { - RTERR( rtContextDeclareVariable(ctx, "framebuffer", &framebuffer_v) ); - RTERR( rtVariableSetObject(framebuffer_v, framebuffer) ); - } - - buffers_allocated = 1; - } -} - - -void OptiXRenderer::framebuffer_resize(int fbwidth, int fbheight) { - if (!context_created) - return; - - width = fbwidth; - height = fbheight; - - if (buffers_allocated) { - if (verbose == RT_VERB_DEBUG) - printf("OptiXRenderer) framebuffer_resize(%d x %d)\n", width, height); - - RTERR( rtBufferSetSize2D(framebuffer, width, height) ); - RTERR( rtBufferSetSize2D(accumulation_buffer, width, height) ); -#if defined(ORT_RAYSTATS) - RTERR( rtBufferSetSize2D(raystats1_buffer, width, height) ); - RTERR( rtBufferSetSize2D(raystats2_buffer, width, height) ); -#endif - } -} - - -void OptiXRenderer::framebuffer_map_rgb4u(unsigned char **imgrgb4u) { - rtBufferMap(framebuffer, (void **) imgrgb4u); -} - - -void OptiXRenderer::framebuffer_unmap() { - rtBufferUnmap(framebuffer); -} - - -void OptiXRenderer::framebuffer_destroy() { - if (!context_created) - return; - - if (buffers_allocated) { -#if defined(ORT_RAYSTATS) - RTERR( rtContextRemoveVariable(ctx, raystats1_buffer_v) ); - RTERR( rtBufferDestroy(raystats1_buffer) ); - RTERR( rtContextRemoveVariable(ctx, raystats2_buffer_v) ); - RTERR( rtBufferDestroy(raystats2_buffer) ); -#endif - RTERR( rtContextRemoveVariable(ctx, accumulation_buffer_v) ); - RTERR( rtBufferDestroy(accumulation_buffer) ); -#ifndef VMDOPTIX_PROGRESSIVEAPI - RTERR( rtContextRemoveVariable(ctx, framebuffer_v) ); -#endif - RTERR( rtBufferDestroy(framebuffer) ); - } - buffers_allocated = 0; - buffers_progressive = 0; -} - - -void OptiXRenderer::render_compile_and_validate(void) { - if (!context_created) - return; - - // - // finalize context validation, compilation, and AS generation - // - double startctxtime = wkf_timer_timenow(ort_timer); - - - // - // XXX need to add heuristics to prevent out-of-memory AS build failures on - // versions of OptiX that don't allow multiple AS build attempts - // - // The memory usage of Trbvh is roughly (from Keith's email): - // 68Byte * num_tris * 1.3 + 0.1*total GPU memory + user prim buffers. - // - // VMD should use this as an estimate of peak Trbvh memory demand and - // force a switch from the GPU builder to a CPU builder, or if it's - // still too much. Trbvh built on CPU still uses 2x the memory that - // the geometry does, so there will still be cases where the only - // viable route is to switch away from Trbvh entirely, e.g. use MedianBvh. -#define ORT_AS_BUILD_MEM_HEURISTIC 1 -#if defined(ORT_AS_BUILD_MEM_HEURISTIC) - if (getenv("VMDOPTIXNOMEMHEURISTIC") == NULL) { - const char *curbuilderstr = NULL; - RTERR( rtAccelerationGetBuilder(acceleration, &curbuilderstr) ); - if (!strcmp(curbuilderstr, "Trbvh")) { - long totaltris = tricolor_cnt + trimesh_c4u_n3b_v3f_cnt + - trimesh_n3b_v3f_cnt + trimesh_n3f_v3f_cnt + - trimesh_v3f_cnt; - - long totalobjs = cylinder_array_cnt + cylinder_array_color_cnt + - ring_array_color_cnt + - sphere_array_cnt + sphere_array_color_cnt + - totaltris; - - long totaluserbufsz = - cylinder_array_cnt * sizeof(vmd_cylinder) + - cylinder_array_color_cnt * sizeof(vmd_cylinder_color) + - ring_array_color_cnt * sizeof(vmd_ring_color) + - sphere_array_cnt * sizeof(vmd_sphere) + - sphere_array_color_cnt * sizeof(vmd_sphere_color) + - tricolor_cnt * sizeof(vmd_tricolor) + - trimesh_c4u_n3b_v3f_cnt * sizeof(vmd_trimesh_c4u_n3b_v3f) + - trimesh_n3b_v3f_cnt * sizeof(vmd_trimesh_n3b_v3f) + - trimesh_n3f_v3f_cnt * sizeof(vmd_trimesh_n3f_v3f) + - trimesh_v3f_cnt * sizeof(vmd_trimesh_v3f); - - // Query the current state of all GPUs in the OptiX context - // to determine the smallest amount of free memory, and - // the smallest amount of physical memory among all GPUs. - unsigned long mingpufreemem, mingpuphysmem; - if (query_meminfo_ctx_devices(ctx, mingpufreemem, mingpuphysmem)) { - // If the GPU hardware query fails for some reason, we blindly - // assume we've got a mostly vacant K20-like GPU with 4GB free - mingpufreemem = 4L * 1024L * 1024L * 1024L; - mingpuphysmem = 6L * 1024L * 1024L * 1024L; - } - unsigned long tenpctgpumem = mingpuphysmem / 10; - - // 1.3 * 68 bytes == ~88 bytes - unsigned long trbvhmemsz = totalobjs * 90L + tenpctgpumem; - unsigned long totaltrbvhmemsz = trbvhmemsz + totaluserbufsz; - unsigned long totaltrbvhmemszmb = totaltrbvhmemsz / (1024L * 1024L); - - if (totaltrbvhmemsz > mingpufreemem) { - // issue warning, and try to build the AS using a different builder - msgWarn << "OptiXRenderer) Predicted Trbvh AS peak GPU memory requirement exceeds capacity" << sendmsg; - msgWarn << "OptiXRenderer) Min free GPU mem: " << (mingpufreemem / (1024L * 1024L)) << "MB" << sendmsg; - msgWarn << "OptiXRenderer) Predicted Trbvh AS peak mem during build: " << totaltrbvhmemszmb << "MB" << sendmsg; - -#if 1 - // XXX the Trbvh CPU builder can segfault in some cases, e.g. on - // a 171M triangle mesh on a machine w/ 256GB physical mem. - // for now, we will only use MedianBvh as the fallback path until - // this issue is resolved with greater certainty. - msgWarn << "OptiXRenderer) Switching to MedianBvh AS builder..." << sendmsg; - RTERR( rtAccelerationSetBuilder(acceleration, "MedianBvh") ); - RTERR( rtAccelerationSetTraverser(acceleration, "Bvh") ); -#else - - if (trbvhmemsz + totaluserbufsz > maxgpufreemem) { - msgWarn << "OptiXRenderer) Switching to MedianBvh AS builder..." << sendmsg; - RTERR( rtAccelerationSetBuilder(acceleration, "MedianBvh") ); - RTERR( rtAccelerationSetTraverser(acceleration, "Bvh") ); - } else { - msgWarn << "OptiXRenderer) Switching to Trbvh CPU-based AS builder..." << sendmsg; - RTERR( rtAccelerationSetBuilder(acceleration, "Trbvh") ); - RTERR( rtAccelerationSetProperty(acceleration, "build_type", "CPU") ); - RTERR( rtAccelerationSetTraverser(acceleration, "Bvh") ); - } -#endif - - } - } - } -#endif - - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) Finalizing OptiX rendering kernels...\n"); - RTERR( rtContextValidate(ctx) ); - if (lasterror != RT_SUCCESS) { - printf("OptiXRenderer) An error occured validating the context. Rendering is aborted.\n"); - return; - } - - RTERR( rtContextCompile(ctx) ); - if (lasterror != RT_SUCCESS) { - printf("OptiXRenderer) An error occured compiling the context. Rendering is aborted.\n"); - return; - } - - double contextinittime = wkf_timer_timenow(ort_timer); - time_ctx_validate = contextinittime - startctxtime; - - // - // Force OptiX to build the acceleration structure _now_ by using - // an empty launch. This is done in OptiX sample 6... - // -// #define ORT_RETRY_FAILED_AS_BUILD 1 -#if defined(ORT_RETRY_FAILED_AS_BUILD) - RTresult rc; - rc = rtContextLaunch2D(ctx, RT_RAY_GEN_ACCUMULATE, 0, 0); - RTERR( rc ); -#else - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_ACCUMULATE, 0, 0) ); -#endif - -#if defined(ORT_RETRY_FAILED_AS_BUILD) - // XXX this never works right, I just get another error saying: - // "Cannot set builder while asynchronous building is in progress" - if (rc == RT_ERROR_MEMORY_ALLOCATION_FAILED) { - const char *curbuilderstr = NULL; - RTERR( rtAccelerationGetBuilder(acceleration, &curbuilderstr) ); - printf("Current OptiX builder str: '%s'\n", curbuilderstr); - if (!strcmp(curbuilderstr, "Trbvh")) { - // clear previous error so we don't abort immediately... - lasterror = RT_SUCCESS; - - // issue warning, and try to rebuild the AS using a different builder - printf("OptiXRenderer) Trbvh AS ran out of GPU memory, retrying with MedianBvh...\n"); - RTERR( rtAccelerationSetBuilder(acceleration, "MedianBvh") ); - RTERR( rtAccelerationSetTraverser(acceleration, "Bvh") ); - - // try re-validating and re-compiling context after changing the - // AS builder to something that can survive GPU memory shortages - render_compile_and_validate(); - } - } -#endif - - time_ctx_AS_build = wkf_timer_timenow(ort_timer) - contextinittime; - if (verbose == RT_VERB_DEBUG) { - printf("OptiXRenderer) launching render: %d x %d\n", width, height); - } -} - - -#if defined(VMDOPTIX_INTERACTIVE_OPENGL) - -static void *createoptixwindow(const char *wintitle, int width, int height) { - printf("OptiXRenderer) Creating OptiX window: %d x %d...\n", width, height); - - void *win = glwin_create(wintitle, width, height); - while (glwin_handle_events(win, GLWIN_EV_POLL_NONBLOCK) != 0); - - glDrawBuffer(GL_BACK); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearColor(0.0, 0.0, 0.0, 1.0); /* black */ - glViewport(0, 0, width, height); - glClear(GL_COLOR_BUFFER_BIT); - - glShadeModel(GL_FLAT); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, width, height, 0.0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glDrawBuffer(GL_BACK); - glClear(GL_COLOR_BUFFER_BIT); - - glwin_swap_buffers(win); - - return win; -} - - -static void interactive_viewer_usage(RTcontext ctx, void *win) { - printf("OptiXRenderer) VMD TachyonL-OptiX Interactive Ray Tracer help:\n"); - printf("OptiXRenderer) ===============================================\n"); - - print_ctx_devices(ctx); - - // check for Spaceball/SpaceNavigator/Magellan input devices - int havespaceball = ((glwin_spaceball_available(win)) && (getenv("VMDDISABLESPACEBALLXDRV") == NULL)); - printf("OptiXRenderer) Spaceball/SpaceNavigator/Magellan: %s\n", - (havespaceball) ? "Available" : "Not available"); - - // check for stereo-capable display - int havestereo, havestencil; - glwin_get_wininfo(win, &havestereo, &havestencil); - printf("OptiXRenderer) Stereoscopic display: %s\n", - (havestereo) ? "Available" : "Not available"); - - // check for vertical retrace sync - int vsync=0, rc=0; - if ((rc = glwin_query_vsync(win, &vsync)) == GLWIN_SUCCESS) { - printf("OptiXRenderer) Vert retrace sync: %s\n", (vsync) ? "On" : "Off"); - } else { - printf("OptiXRenderer) Vert retrace sync: indeterminate\n"); - } - - printf("OptiXRenderer)\n"); - printf("OptiXRenderer) General controls:\n"); - printf("OptiXRenderer) space: save numbered snapshot image\n"); - printf("OptiXRenderer) =: reset to initial view\n"); - printf("OptiXRenderer) h: print this help info\n"); - printf("OptiXRenderer) p: print current rendering parameters\n"); - printf("OptiXRenderer) ESC,q: quit viewer\n"); - printf("OptiXRenderer)\n"); - printf("OptiXRenderer) Display controls\n"); - printf("OptiXRenderer) F1: override shadows on/off (off=AO off too)\n"); - printf("OptiXRenderer) F2: override AO on/off\n"); - printf("OptiXRenderer) F3: override DoF on/off\n"); - printf("OptiXRenderer) F4: override Depth cueing on/off\n"); -#if defined(VMDOPTIX_USE_HMD) - printf("OptiXRenderer) F5: override HMD/camera clipping plane/sphere\n"); - printf("OptiXRenderer) F6: override HMD/camera headlight\n"); - printf("OPtiXRenderer) F7: toggle HMD interleaved drawing\n"); - printf("OPtiXRenderer) F8: toggle HMD tex caching/update mode\n"); - printf("OPtiXRenderer) F9: switch HMD lens distortion mode\n"); -#endif -#ifdef USE_REVERSE_SHADOW_RAYS - printf("OptiXRenderer) F10: enable/disable shadow ray optimizations\n"); -#endif - printf("OptiXRenderer) F12: toggle full-screen display on/off\n"); - printf("OptiXRenderer) 1-9,0: override samples per update auto-FPS off\n"); - printf("OptiXRenderer) Up: increase DoF focal distance\n"); - printf("OptiXRenderer) Down: decrease DoF focal distance\n"); - printf("OptiXRenderer) Left: decrease DoF f/stop\n"); - printf("OptiXRenderer) Right: increase DoF f/stop\n"); - printf("OptiXRenderer) S: toggle stereoscopic display on/off (if avail)\n"); - printf("OptiXRenderer) a: toggle AA/AO auto-FPS tuning on/off (on)\n"); - printf("OptiXRenderer) g: toggle gradient sky xforms on/off (on)\n"); - printf("OptiXRenderer) l: toggle light xforms on/off (on)\n"); - printf("OptiXRenderer)\n"); - printf("OptiXRenderer) Mouse controls:\n"); - printf("OptiXRenderer) f: mouse depth-of-field mode\n"); - printf("OptiXRenderer) r: mouse rotation mode\n"); - printf("OptiXRenderer) s: mouse scaling mode\n"); - printf("OptiXRenderer) t: mouse translation mode\n"); - - int movie_recording_enabled = (getenv("VMDOPTIXLIVEMOVIECAPTURE") != NULL); - if (movie_recording_enabled) { - printf("OptiXRenderer)\n"); - printf("OptiXRenderer) Movie recording controls:\n"); - printf("OptiXRenderer) R: start/stop movie recording\n"); - printf("OptiXRenderer) F: toggle movie FPS (24, 30, 60)\n"); - } -} - - - -void OptiXRenderer::render_to_glwin(const char *filename, int writealpha) { - int i; - - if (!context_created) - return; - - enum RtMouseMode { RTMM_ROT=0, RTMM_TRANS=1, RTMM_SCALE=2, RTMM_DOF=3 }; - enum RtMouseDown { RTMD_NONE=0, RTMD_LEFT=1, RTMD_MIDDLE=2, RTMD_RIGHT=3 }; - RtMouseMode mm = RTMM_ROT; - RtMouseDown mousedown = RTMD_NONE; - - // initialize HMD free-run flag to off until HMD code enumerates the - // hardware and passes all the way through initialization - int hmd_freerun = 0; -#if defined(VMDOPTIX_USE_HMD) - void *hmd_warp = NULL; -#endif - int hmd_warp_drawmode=1; - - // default HMD distortion correction coefficients assume an Oculus DK2 HMD - int hmd_warp_coeff_update=0; // warp equation was changed - int hmd_warp_coeff_edit=1; // which power of r to edit - int hmd_warp_coeff_set=0; // sets: 0=DK2, 1=MSR, 2=User - const float dk2_warp_coeff[5] = { 1.000f, 0.000f, 0.600f, 0.000f, 0.000f }; -// const float msr_warp_coeff[5] = { 1.000f, 0.290f, 0.195f, 0.045f, 0.360f }; - const float msr_warp_coeff[5] = { 0.950f, 0.330f, 0.195f, 0.045f, 0.360f }; - float user_warp_coeff[5] = { 1.000f, 0.000f, 0.600f, 0.000f, 0.000f }; - float hmd_warp_coeff[5] = { 1.000f, 0.000f, 0.600f, 0.000f, 0.000f }; - - // obtain user-defined warp coefficients from environment variable if set - if (getenv("VMDOPTIXHMDUSERWARPCOEFFS")) { - printf("OptiXRenderer) user-override of default user-defined HMD warp coefficients\n"); - memset(user_warp_coeff, 0, sizeof(user_warp_coeff)); - int cnt=sscanf(getenv("VMDOPTIXHMDUSERWARPCOEFFS"), "%f %f %f %f %f", - &user_warp_coeff[0], &user_warp_coeff[1], - &user_warp_coeff[2], &user_warp_coeff[3], - &user_warp_coeff[4]); - if (cnt != 5) { - printf("OptiXRenderer) Warning: only parsed %d coefficients!\n", cnt); - } else { - printf("OptiXRenderer) user-defined warp coefficients: %d\n", cnt); - printf("OptiXRenderer) %.3f %.3f %.3f %.3f %.3f\n", - user_warp_coeff[0], user_warp_coeff[1], - user_warp_coeff[2], user_warp_coeff[3], user_warp_coeff[4]); - } - } - - // don't interleave extra HMD update/draw passes between buffer updates - // unless the user wants us to, as a means of improving usability of - // slow machines - int hmd_interleave_draws = 0; - if (getenv("VMDOPTIXHMDINTERLEAVEDRAWS")) { - hmd_interleave_draws = 1; - printf("OptiXRenderer) HMD GL draw call interleaving enabled\n"); - } - - int hmd_tex_caching = 0; - if (getenv("VMDOPTIXHMDTEXCACHING")) { - hmd_tex_caching = 1; - printf("OptiXRenderer) HMD texture caching enabled\n"); - } - - // flag to skip the HMD GL draw calls for timing purposes - int hmd_no_draw = 0; - if (getenv("VMDOPTIXHMDNODRAW")) { - hmd_no_draw = 1; - printf("OptiXRenderer) HMD GL draw calls disabled\n"); - } - - // allow user-override of VR HMD sphere geometric res - float hmd_fov = 95; - if (getenv("VMDOPTIXHMDFOV")) { - hmd_fov = atof(getenv("VMDOPTIXHMDFOV")); - printf("OptiXRenderer) User-override of HMD FoV: %.2f\n", hmd_fov); - } - - // allow user-override of VR HMD sphere geometric res - int hmd_spres = 72; // 50 seems like the useful lower-bound spres setting - if (getenv("VMDOPTIXHMDSPRES")) { - hmd_spres = atoi(getenv("VMDOPTIXHMDSPRES")); - printf("OptiXRenderer) User-override of HMD sph res: %d\n", hmd_spres); - } - - // flags to interactively enable/disable shadows, AO, DoF -#if defined(USE_REVERSE_SHADOW_RAYS) && defined(USE_REVERSE_SHADOW_RAYS_DEFAULT) - int gl_shadows_on=(shadows_enabled) ? RT_SHADOWS_ON_REVERSE : RT_SHADOWS_OFF; -#else - int gl_shadows_on=(shadows_enabled) ? RT_SHADOWS_ON : RT_SHADOWS_OFF; -#endif - - int gl_fs_on=0; // fullscreen window state - int fsowsx=0, fsowsy=0; // store last win size before fullscreen - int owsx=0, owsy=0; // last win size - int gl_ao_on=(ao_samples > 0); - int gl_dof_on, gl_dof_on_old; - gl_dof_on=gl_dof_on_old=dof_enabled; - int gl_fog_on=(fog_mode != RT_FOG_NONE); - int gl_clip_on=(clipview_mode != RT_CLIP_NONE); - int gl_headlight_on=(headlight_mode != RT_HEADLIGHT_OFF); - - // Enable live recording of a session to a stream of image files indexed - // by their display presentation time, mapped to the nearest frame index - // in a fixed-frame-rate image sequence (e.g. 24, 30, or 60 FPS), - // to allow subsequent encoding into a standard movie format. - // XXX this feature is disabled by default at present, to prevent people - // from accidentally turning it on during a live demo or the like - int movie_recording_enabled = (getenv("VMDOPTIXLIVEMOVIECAPTURE") != NULL); - int movie_recording_on = 0; - double movie_recording_start_time = 0.0; - int movie_recording_fps = 30; - int movie_framecount = 0; - int movie_lastframeindex = 0; - const char *movie_recording_filebase = "vmdlivemovie.%05d.tga"; - if (getenv("VMDOPTIXLIVEMOVIECAPTUREFILEBASE")) - movie_recording_filebase = getenv("VMDOPTIXLIVEMOVIECAPTUREFILEBASE"); - - // Enable/disable Spaceball/SpaceNavigator/Magellan input - int spaceballenabled=(getenv("VMDDISABLESPACEBALLXDRV") == NULL) ? 1 : 0; - int spaceballmode=0; // default mode is rotation/translation - int spaceballflightmode=0; // 0=moves object, 1=camera fly - if (getenv("VMDOPTIXSPACEBALLFLIGHT")) - spaceballflightmode=1; - - // total AA/AO sample count - int totalsamplecount=0; - - // counter for snapshots of live image... - int snapshotcount=0; - - // flag to enable automatic AO sample count adjustment for FPS rate control -#if defined(VMDOPTIX_PROGRESSIVEAPI) -#if 1 - int autosamplecount=0; // leave disabled for now -#else - int autosamplecount=1; // works partially in current revs of progressive API -#endif -#else - int autosamplecount=1; -#endif - - // flag to enable transformation of lights and gradient sky sphere, - // so that they track camera orientation as they do in the VMD OpenGL display - int xformlights=1, xformgradientsphere=1; - - // - // allocate or reconfigure the framebuffer, accumulation buffer, - // and output streams required for progressive rendering, either - // using the new progressive APIs, or using our own code. - // - // Unless overridden by environment variables, we use the incoming - // window size parameters from VMD to initialize the RT image dimensions. - // If image size is overridden, often when using HMDs, the incoming - // dims are window dims are used to size the GL window, but the image size - // is set independently. - int wsx=width, wsy=height; - const char *imageszstr = getenv("VMDOPTIXIMAGESIZE"); - if (imageszstr) { - if (sscanf(imageszstr, "%d %d", &width, &height) != 2) { - width=wsx; - height=wsy; - } - } - - framebuffer_config(width, height, 1); - - // prepare the majority of OptiX rendering state before we go into - // the interactive rendering loop - update_rendering_state(1); - render_compile_and_validate(); - - // make a copy of state we're going to interactively manipulate, - // so that we can recover to the original state on-demand - int samples_per_pass = 1; - int force_ao_1 = 0; // whether or not to force AO count per pass to 1 - int cur_aa_samples = aa_samples; - int cur_ao_samples = ao_samples; - float cam_zoom_orig = cam_zoom; - float scene_gradient_orig[3] = {0.0f, 1.0f, 0.0f}; - vec_copy(scene_gradient_orig, scene_gradient); - - float cam_pos_orig[3] = {0.0f, 0.0f, 2.0f}; - float cam_U_orig[3] = {1.0f, 0.0f, 0.0f}; - float cam_V_orig[3] = {0.0f, 1.0f, 0.0f}; - float cam_W_orig[3] = {0.0f, 0.0f, -1.0f}; - float cam_pos[3], cam_U[3], cam_V[3], cam_W[3]; - float hmd_U[3], hmd_V[3], hmd_W[3]; - - vec_copy(cam_pos, cam_pos_orig); - vec_copy(cam_U, cam_U_orig); - vec_copy(cam_V, cam_V_orig); - vec_copy(cam_W, cam_W_orig); - - // copy light directions - DirectionalLight *cur_dlights = (DirectionalLight *) calloc(1, directional_lights.num() * sizeof(DirectionalLight)); - for (i=0; idevice_count() < 1) { - delete hmd; - hmd = NULL; - } - } - if (hmd) { - autosamplecount=0; // disable when targeting HMDs - msgInfo << "OptiXRenderer) HMD in use, disabling auto sample count adjustement," << sendmsg; - msgInfo << "OptiXRenderer) optimizing for lowest rendering latency." << sendmsg; - } - -#if defined(VMDOPTIX_PROGRESSIVEAPI) - hmd_freerun = (hmd != NULL && camera_projection == RT_EQUIRECTANGULAR); -#endif - -#if defined(VMDUSEEVENTIO) - evio_handle eviodev = NULL; - const char *eviodevname = getenv("VMDOPTIXEVIODEV"); - if (hmd && eviodevname) { - msgInfo << "OptiXRenderer) Attempting to open '" - << eviodevname << "' for Linux event I/O input..." << sendmsg; - eviodev = evio_open(eviodevname); - if (eviodev) { - msgInfo << "OptiXRenderer) Using Linux event I/O input:" << sendmsg; - evio_print_devinfo(eviodev); - } - } -#endif -#endif - - // create the display window - const char *windowtitle; -#if 1 - windowtitle = "VMD TachyonL-OptiX Interactive Ray Tracer"; -#else - // useful for demos and perf comparisons - if (getenv("VMDOPTIXNORTX") != NULL || rtx_enabled==0) { - windowtitle = "VMD TachyonL-OptiX Interactive Ray Tracer -- Turing RTX DISABLED"; - } else { - windowtitle = "VMD TachyonL-OptiX Interactive Ray Tracer -- Turing RTX ENABLED"; - } -#endif - - void *win = createoptixwindow(windowtitle, width, height); - interactive_viewer_usage(ctx, win); - - // check for stereo-capable display - int havestereo=0, havestencil=0; - int stereoon=0, stereoon_old=0; - glwin_get_wininfo(win, &havestereo, &havestencil); - -#if defined(VMDOPTIX_USE_HMD) && defined(VMDOPTIX_PROGRESSIVEAPI) - if (hmd_freerun && hmd != NULL && camera_projection == RT_EQUIRECTANGULAR) { - glwin_spheremap_draw_prepare(win); - - // enable HMD optical distortion correction, unless force-disabled - if (hmd != NULL && !getenv("VMDOPTIXHMDNOWARP")) - hmd_warp = glwin_spheremap_create_hmd_warp(win, wsx, wsy, 21, 0, - width, height, hmd_warp_coeff); - - // if an HMD is in use, we trigger full-screen display by default - if (hmd) { - if (glwin_fullscreen(win, 1, 0) == 0) { - gl_fs_on = 1; - fsowsx = wsx; - fsowsy = wsy; - glwin_get_winsize(win, &wsx, &wsy); - } else { - printf("OptiXRenderer) Fullscreen mode not available\n"); - } - } - } -#endif - - // Override AA/AO sample counts since we're doing progressive rendering. - // Choosing an initial AO sample count of 1 will give us the peak progressive - // display update rate, but we end up wasting time on re-tracing many - // primary rays. The automatic FPS optimization scheme below will update - // the number of samples per rendering pass and assign the best values for - // AA/AO samples accordingly. - cur_aa_samples = samples_per_pass; - if (cur_ao_samples > 0) { - cur_aa_samples = 1; - cur_ao_samples = samples_per_pass; - } - - const char *statestr = "|/-\\."; - int done=0, winredraw=1; - int state=0, mousedownx=0, mousedowny=0; - float cur_cam_zoom = cam_zoom_orig; - - double fpsexpave=0.0; - double hmdfpsexpave=0.0; - double hmdgldrawtime=0.0; - double mapbuftotaltime=0.0; - double accumbufstarttime=wkf_timer_timenow(ort_timer); - double oldtime = wkf_timer_timenow(ort_timer); -#if defined(VMDOPTIX_USE_HMD) - double hmdoldtime = oldtime; -#endif - while (!done) { - int winevent=0; - -#if 1 - if (app->uivs && app->uivs->srv_connected()) { - if (app->uivs->srv_check_ui_event()) { - int eventtype; - app->uivs->srv_get_last_event_type(eventtype); - switch (eventtype) { - case VideoStream::VS_EV_ROTATE_BY: - { int axis; - float angle; - app->uivs->srv_get_last_rotate_by(angle, axis); - Matrix4 rm; - - switch (axis) { - case 'x': - rm.rotate_axis(cam_U, -angle * VMD_PI/180.0f); - break; - - case 'y': - rm.rotate_axis(cam_V, -angle * VMD_PI/180.0f); - break; - - case 'z': - rm.rotate_axis(cam_W, -angle * VMD_PI/180.0f); - break; - } - rm.multpoint3d(cam_pos, cam_pos); - rm.multnorm3d(cam_U, cam_U); - rm.multnorm3d(cam_V, cam_V); - rm.multnorm3d(cam_W, cam_W); - - if (xformgradientsphere) { - rm.multnorm3d(scene_gradient, scene_gradient); - } - - if (xformlights) { - // update light directions (comparatively costly) - for (i=0; iuivs->srv_get_last_translate_by(tx, ty, tz); - vec_scale(dU, -tx, cam_U); - vec_scale(dV, -ty, cam_V); - vec_scale(dW, -tz, cam_W); - vec_add(cam_pos, cam_pos, dU); - vec_add(cam_pos, cam_pos, dV); - vec_add(cam_pos, cam_pos, dW); - winredraw = 1; - } - break; - - case VideoStream::VS_EV_SCALE_BY: - { float zoominc; - app->uivs->srv_get_last_scale_by(zoominc); - cam_zoom *= 1.0f / zoominc; - winredraw = 1; - } - break; - -#if 0 - } else if (mm == RTMM_DOF) { - cam_dof_fnumber += txdx * 20.0f; - if (cam_dof_fnumber < 1.0f) cam_dof_fnumber = 1.0f; - cam_dof_focal_dist += -txdy; - if (cam_dof_focal_dist < 0.01f) cam_dof_focal_dist = 0.01f; - winredraw = 1; - } - } -#endif - - case VideoStream::VS_EV_NONE: - default: - // should never happen... - break; - } - } - } -#endif - - - while ((winevent = glwin_handle_events(win, GLWIN_EV_POLL_NONBLOCK)) != 0) { - int evdev, evval; - char evkey; - - glwin_get_lastevent(win, &evdev, &evval, &evkey); - glwin_get_winsize(win, &wsx, &wsy); - - if (evdev == GLWIN_EV_WINDOW_CLOSE) { - printf("OptiXRenderer) display window closed, exiting...\n"); - done = 1; - winredraw = 0; - } else if (evdev == GLWIN_EV_KBD) { - switch (evkey) { - case '`': autosamplecount=0; samples_per_pass=1; - force_ao_1 = (!force_ao_1); winredraw=1; - printf("OptiXRenderer) Toggling forced single AO sample per pass: %s\n", - force_ao_1 ? "on" : "off"); - break; - - // update HMD warp distortion coefficients - case '|': hmd_warp_coeff_set = (hmd_warp_coeff_set + 1) % 3; - switch (hmd_warp_coeff_set) { - case 0: - printf("\nDistortion correction: DK2 stock lens\n"); - memcpy(hmd_warp_coeff, dk2_warp_coeff, 5*sizeof(float)); - break; - - case 1: - printf("\nDistortion correction: DK2 w/ MSR lens\n"); - memcpy(hmd_warp_coeff, msr_warp_coeff, 5*sizeof(float)); - break; - - case 2: - printf("\nDistortion correction: User defined lens\n"); - memcpy(hmd_warp_coeff, user_warp_coeff, 5*sizeof(float)); - break; - } - printf("\nHMD warp coeff: %.3f, %.3f, %.3f, %.3f, %.3f\n", - hmd_warp_coeff[0], hmd_warp_coeff[1], - hmd_warp_coeff[2], hmd_warp_coeff[3], - hmd_warp_coeff[4]); - hmd_warp_coeff_update=1; winredraw=1; break; - break; - - case '\\': hmd_warp_coeff_edit = (hmd_warp_coeff_edit + 1) % 5; - printf("\nHMD edit warp coeff: r^%d\n",hmd_warp_coeff_edit); - break; - - case '[': hmd_warp_coeff[hmd_warp_coeff_edit]-=0.005; - printf("\nHMD warp coeff: %.3f, %.3f, %.3f, %.3f, %.3f\n", - hmd_warp_coeff[0], hmd_warp_coeff[1], - hmd_warp_coeff[2], hmd_warp_coeff[3], - hmd_warp_coeff[4]); - memcpy(user_warp_coeff, hmd_warp_coeff, 5*sizeof(float)); - hmd_warp_coeff_update=1; winredraw=1; break; - - case ']': hmd_warp_coeff[hmd_warp_coeff_edit]+=0.005; - printf("\nHMD warp coeff: %.3f, %.3f, %.3f, %.3f, %.3f\n", - hmd_warp_coeff[0], hmd_warp_coeff[1], - hmd_warp_coeff[2], hmd_warp_coeff[3], - hmd_warp_coeff[4]); - memcpy(user_warp_coeff, hmd_warp_coeff, 5*sizeof(float)); - hmd_warp_coeff_update=1; winredraw=1; break; - - // update sample counts - case '1': autosamplecount=0; samples_per_pass=1; winredraw=1; break; - case '2': autosamplecount=0; samples_per_pass=2; winredraw=1; break; - case '3': autosamplecount=0; samples_per_pass=3; winredraw=1; break; - case '4': autosamplecount=0; samples_per_pass=4; winredraw=1; break; - case '5': autosamplecount=0; samples_per_pass=5; winredraw=1; break; - case '6': autosamplecount=0; samples_per_pass=6; winredraw=1; break; - case '7': autosamplecount=0; samples_per_pass=7; winredraw=1; break; - case '8': autosamplecount=0; samples_per_pass=8; winredraw=1; break; - case '9': autosamplecount=0; samples_per_pass=9; winredraw=1; break; - case '0': autosamplecount=0; samples_per_pass=10; winredraw=1; break; - - case '=': /* recover back to initial state */ - vec_copy(scene_gradient, scene_gradient_orig); - cam_zoom = cam_zoom_orig; - vec_copy(cam_pos, cam_pos_orig); - vec_copy(cam_U, cam_U_orig); - vec_copy(cam_V, cam_V_orig); - vec_copy(cam_W, cam_W_orig); - - // restore original light directions - for (i=0; ireset_orientation(); - printf("\nOptiXRenderer) Resetting HMD orientation\n"); - } -#endif - break; - - case ' ': /* spacebar saves current image with counter */ - { - char snapfilename[256]; - sprintf(snapfilename, "vmdsnapshot.%04d.tga", snapshotcount); - if (OptiXWriteImage(snapfilename, writealpha, framebuffer) != -1) { - printf("OptiXRenderer) Saved snapshot to '%s' \n", - snapfilename); - } - snapshotcount++; - } - break; - - case 'a': /* toggle automatic sample count FPS tuning */ - autosamplecount = !(autosamplecount); - printf("\nOptiXRenderer) Automatic AO sample count FPS tuning %s\n", - (autosamplecount) ? "enabled" : "disabled"); - break; - - case 'f': /* DoF mode */ - mm = RTMM_DOF; - printf("\nOptiXRenderer) Mouse DoF aperture and focal dist. mode\n"); - break; - - case 'g': /* toggle gradient sky sphere xforms */ - xformgradientsphere = !(xformgradientsphere); - printf("\nOptiXRenderer) Gradient sky sphere transformations %s\n", - (xformgradientsphere) ? "enabled" : "disabled"); - break; - - case 'h': /* print help message */ - printf("\n"); - interactive_viewer_usage(ctx, win); - - // we have to force a redraw after querying OptiX context - // info due to the current behavior of the progressive API, - // which halts upon any API call other than the simplest queries - winredraw = 1; - break; - - case 'l': /* toggle lighting xforms */ - xformlights = !(xformlights); - printf("\nOptiXRenderer) Light transformations %s\n", - (xformlights) ? "enabled" : "disabled"); - break; - - case 'p': /* print current RT settings */ - printf("\nOptiXRenderer) Current Ray Tracing Parameters:\n"); - printf("OptiXRenderer) -------------------------------\n"); - printf("OptiXRenderer) Camera zoom: %f\n", cur_cam_zoom); - printf("OptiXRenderer) Shadows: %s Ambient occlusion: %s\n", - (gl_shadows_on) ? "on" : "off", - (gl_ao_on) ? "on" : "off"); - printf("OptiXRenderer) Antialiasing samples per-pass: %d\n", - cur_aa_samples); - printf("OptiXRenderer) Ambient occlusion samples per-pass: %d\n", - cur_ao_samples); - printf("OptiXRenderer) Depth-of-Field: %s f/num: %.1f Foc. Dist: %.2f\n", - (gl_dof_on) ? "on" : "off", - cam_dof_fnumber, cam_dof_focal_dist); - printf("OptiXRenderer) Win size: %d x %d\n", wsx, wsy); - printf("OptiXRenderer) Image size: %d x %d\n", width, height); - break; - - case 'r': /* rotate mode */ - mm = RTMM_ROT; - printf("\nOptiXRenderer) Mouse rotation mode\n"); - break; - - case 's': /* scaling mode */ - mm = RTMM_SCALE; - printf("\nOptiXRenderer) Mouse scaling mode\n"); - break; - - case 'F': /* toggle live movie recording FPS (24, 30, 60) */ - if (movie_recording_enabled) { - switch (movie_recording_fps) { - case 24: movie_recording_fps = 30; break; - case 30: movie_recording_fps = 60; break; - case 60: - default: movie_recording_fps = 24; break; - } - printf("\nOptiXRenderer) Movie recording FPS rate: %d\n", - movie_recording_fps); - } else { - printf("\nOptiXRenderer) Movie recording not available.\n"); - } - break; - - case 'R': /* toggle live movie recording mode on/off */ - if (movie_recording_enabled) { - movie_recording_on = !(movie_recording_on); - printf("\nOptiXRenderer) Movie recording %s\n", - (movie_recording_on) ? "STARTED" : "STOPPED"); - if (movie_recording_on) { - movie_recording_start_time = wkf_timer_timenow(ort_timer); - movie_framecount = 0; - movie_lastframeindex = 0; - } else { - printf("OptiXRenderer) Encode movie with:\n"); - printf("OptiXRenderer) ffmpeg -f image2 -i vmdlivemovie.%%05d.tga -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -b:v 15000000 output.mp4\n"); - } - } else { - printf("\nOptiXRenderer) Movie recording not available.\n"); - } - break; - - case 'S': /* toggle stereoscopic display mode */ - if (havestereo) { - stereoon = (!stereoon); - printf("\nOptiXRenderer) Stereoscopic display %s\n", - (stereoon) ? "enabled" : "disabled"); - winredraw = 1; - } else { - printf("\nOptiXRenderer) Stereoscopic display unavailable\n"); - } - break; - - case 't': /* translation mode */ - mm = RTMM_TRANS; - printf("\nOptiXRenderer) Mouse translation mode\n"); - break; - - case 'q': /* 'q' key */ - case 'Q': /* 'Q' key */ - case 0x1b: /* ESC key */ - printf("\nOptiXRenderer) Exiting on user input. \n"); - done=1; /* exit from interactive RT window */ - break; - } - } else if (evdev != GLWIN_EV_NONE) { - switch (evdev) { - case GLWIN_EV_KBD_F1: /* turn shadows on/off */ -#if defined(USE_REVERSE_SHADOW_RAYS) && defined(USE_REVERSE_SHADOW_RAYS_DEFAULT) - gl_shadows_on=(!gl_shadows_on) ? RT_SHADOWS_ON_REVERSE : RT_SHADOWS_OFF; -#else - gl_shadows_on=(!gl_shadows_on) ? RT_SHADOWS_ON : RT_SHADOWS_OFF; - // gl_shadows_on = (!gl_shadows_on); -#endif - - printf("\n"); -#if defined(USE_REVERSE_SHADOW_RAYS) && defined(USE_REVERSE_SHADOW_RAYS_DEFAULT) - printf("OptiXRenderer) Shadows %s\n", - (gl_shadows_on) ? "enabled (reversal opt.)" : "disabled"); -#else - printf("OptiXRenderer) Shadows %s\n", - (gl_shadows_on) ? "enabled" : "disabled"); -#endif - winredraw = 1; - break; - - case GLWIN_EV_KBD_F2: /* turn AO on/off */ - gl_ao_on = (!gl_ao_on); - printf("\n"); - printf("OptiXRenderer) Ambient occlusion %s\n", - (gl_ao_on) ? "enabled" : "disabled"); - winredraw = 1; - break; - - case GLWIN_EV_KBD_F3: /* turn DoF on/off */ - gl_dof_on = (!gl_dof_on); - printf("\n"); - printf("OptiXRenderer) Depth-of-field %s\n", - (gl_dof_on) ? "enabled" : "disabled"); - winredraw = 1; - break; - - case GLWIN_EV_KBD_F4: /* turn fog/depth cueing on/off */ - gl_fog_on = (!gl_fog_on); - printf("\n"); - printf("OptiXRenderer) Depth cueing %s\n", - (gl_fog_on) ? "enabled" : "disabled"); - winredraw = 1; - break; - - case GLWIN_EV_KBD_F5: /* turn HMD/camera fade+clipping on/off */ - gl_clip_on = (!gl_clip_on); - printf("\n"); - printf("OptiXRenderer) HMD/camera clipping plane/sphere %s\n", - (gl_clip_on) ? "enabled" : "disabled"); - winredraw = 1; - break; - - case GLWIN_EV_KBD_F6: /* turn HMD/camera headlight on/off */ - gl_headlight_on = (!gl_headlight_on); - printf("\n"); - printf("OptiXRenderer) HMD/camera headlight %s\n", - (gl_headlight_on) ? "enabled" : "disabled"); - winredraw = 1; - break; - - case GLWIN_EV_KBD_F7: /* turn HMD draw interleaving on/off */ - hmd_interleave_draws = (!hmd_interleave_draws); - printf("\n"); - printf("OptiXRenderer) HMD interleaved draws %s\n", - (hmd_interleave_draws) ? "enabled" : "disabled"); - break; - - case GLWIN_EV_KBD_F8: /* turn HMD tex caching on/off */ - hmd_tex_caching = (!hmd_tex_caching); - printf("\n"); - printf("OptiXRenderer) HMD tex caching %s\n", - (hmd_tex_caching) ? "enabled" : "disabled"); - break; - - case GLWIN_EV_KBD_F9: /* switch HMD lens distortion correction mode */ - hmd_warp_drawmode = (hmd_warp_drawmode+1) % 5; - printf("\n"); - { const char *warpmodestr="Off"; - switch (hmd_warp_drawmode) { - case 0: warpmodestr="Lens: Off Chroma: Off Grid: Off"; break; - case 1: warpmodestr="Lens: On Chroma: On Grid: Off"; break; - case 2: warpmodestr="Lens: On Chroma: On Grid: On "; break; - case 3: warpmodestr="Lens: On Chroma: Off Grid: Off"; break; - case 4: warpmodestr="Lens: On Chroma: Off Grid: On "; break; - } - printf("OptiXRenderer) HMD Corr. %s\n", warpmodestr); - } - break; - -#ifdef USE_REVERSE_SHADOW_RAYS - case GLWIN_EV_KBD_F10: /* toggle shadow ray reversal on/off */ - if (gl_shadows_on == RT_SHADOWS_ON) - gl_shadows_on = RT_SHADOWS_ON_REVERSE; - else if (gl_shadows_on == RT_SHADOWS_ON_REVERSE) - gl_shadows_on = RT_SHADOWS_ON; - printf("\n"); - printf("OptiXRenderer) Shadow ray reversal %s\n", - (gl_shadows_on==RT_SHADOWS_ON_REVERSE) ? "enabled" : "disabled"); - winredraw = 1; - break; -#endif - - case GLWIN_EV_KBD_F12: /* toggle full-screen window on/off */ - gl_fs_on = (!gl_fs_on); - printf("\nOptiXRenderer) Toggling fullscreen window %s\n", - (gl_fs_on) ? "on" : "off"); - if (gl_fs_on) { - if (glwin_fullscreen(win, gl_fs_on, 0) == 0) { - fsowsx = wsx; - fsowsy = wsy; - glwin_get_winsize(win, &wsx, &wsy); - } else { - printf("OptiXRenderer) Fullscreen mode note available\n"); - } - } else { - glwin_fullscreen(win, gl_fs_on, 0); - glwin_resize(win, fsowsx, fsowsy); - } - winredraw = 1; - break; - - case GLWIN_EV_KBD_UP: /* change depth-of-field focal dist */ - cam_dof_focal_dist *= 1.02f; - printf("\nOptiXRenderer) DoF focal dist: %f\n", cam_dof_focal_dist); - winredraw = 1; - break; - - case GLWIN_EV_KBD_DOWN: /* change depth-of-field focal dist */ - cam_dof_focal_dist *= 0.96f; - if (cam_dof_focal_dist < 0.02f) cam_dof_focal_dist = 0.02f; - printf("\nOptiXRenderer) DoF focal dist: %f\n", cam_dof_focal_dist); - winredraw = 1; - break; - - case GLWIN_EV_KBD_RIGHT: /* change depth-of-field f/stop number */ - cam_dof_fnumber += 1.0f; - printf("\nOptiXRenderer) DoF f/stop: %f\n", cam_dof_fnumber); - winredraw = 1; - break; - - case GLWIN_EV_KBD_LEFT: /* change depth-of-field f/stop number */ - cam_dof_fnumber -= 1.0f; - if (cam_dof_fnumber < 1.0f) cam_dof_fnumber = 1.0f; - printf("\nOptiXRenderer) DoF f/stop: %f\n", cam_dof_fnumber); - winredraw = 1; - break; - - case GLWIN_EV_MOUSE_MOVE: - if (mousedown != RTMD_NONE) { - int x, y; - glwin_get_mousepointer(win, &x, &y); - - float zoommod = 2.0f*cur_cam_zoom/cam_zoom_orig; - float txdx = (x - mousedownx) * zoommod / wsx; - float txdy = (y - mousedowny) * zoommod / wsy; - if (mm != RTMM_SCALE) { - mousedownx = x; - mousedowny = y; - } - - if (mm == RTMM_ROT) { - Matrix4 rm; - if (mousedown == RTMD_LEFT) { - // when zooming in further from the initial view, we - // rotate more slowly so control remains smooth - rm.rotate_axis(cam_V, -txdx); - rm.rotate_axis(cam_U, -txdy); - } else if (mousedown == RTMD_MIDDLE || - mousedown == RTMD_RIGHT) { - rm.rotate_axis(cam_W, txdx); - } - rm.multpoint3d(cam_pos, cam_pos); - rm.multnorm3d(cam_U, cam_U); - rm.multnorm3d(cam_V, cam_V); - rm.multnorm3d(cam_W, cam_W); - - if (xformgradientsphere) { - rm.multnorm3d(scene_gradient, scene_gradient); - } - - if (xformlights) { - // update light directions (comparatively costly) - for (i=0; iupdate(); - hmd->rot_basis_quat(hmd_U_new, hmd_V_new, hmd_W_new, - hmd_U_orig, hmd_V_orig, hmd_W_orig); - - // We use the HMD pose quaternion to transform the standard camera - // orientation basis vectors to their new orientation, and then we - // project those onto the current view basis vector to get the - // correct final camera view vector that we pass along to OptiX - float hmdtmp[3]; - memset(hmdtmp, 0, sizeof(hmdtmp)); - vec_scaled_add(hmdtmp, hmd_U_new[0], cam_U); - vec_scaled_add(hmdtmp, hmd_U_new[1], cam_V); - vec_scaled_add(hmdtmp, hmd_U_new[2], cam_W); - vec_copy(hmd_U_new, hmdtmp); - - memset(hmdtmp, 0, sizeof(hmdtmp)); - vec_scaled_add(hmdtmp, hmd_V_new[0], cam_U); - vec_scaled_add(hmdtmp, hmd_V_new[1], cam_V); - vec_scaled_add(hmdtmp, hmd_V_new[2], cam_W); - vec_copy(hmd_V_new, hmdtmp); - - memset(hmdtmp, 0, sizeof(hmdtmp)); - vec_scaled_add(hmdtmp, hmd_W_new[0], cam_U); - vec_scaled_add(hmdtmp, hmd_W_new[1], cam_V); - vec_scaled_add(hmdtmp, hmd_W_new[2], cam_W); - vec_copy(hmd_W_new, hmdtmp); - -#if 0 - float q[4]; - hmd->get_rot_quat(q); - printf("\nQ: %f %f %f %f\n", q[0], q[1], q[2], q[3]); - printf("hmd_U: %.1f %.1f %.1f\n", hmd_U[0], hmd_U[1], hmd_U[2]); - printf("hmd_V: %.1f %.1f %.1f\n", hmd_V[0], hmd_V[1], hmd_V[2]); - printf("hmd_W: %.1f %.1f %.1f\n", hmd_W[0], hmd_W[1], hmd_W[2]); -#endif - - if (hmd && camera_projection == RT_OCULUS_RIFT) { - vec_copy(hmd_U, hmd_U_new); - vec_copy(hmd_V, hmd_V_new); - vec_copy(hmd_W, hmd_W_new); - - // when using an HMD in direct-drive mode, we have to do - // a redraw on every rendering pass. - winredraw = 1; - } - } -#endif - - -#if defined(VMDUSEEVENTIO) - // - // Handle Linux event-based input device I/O for joysticks/spaceball/etc - // - if (eviodev) { - float ax1, ay1, ax2, ay2; - int buttons; - int rc=0; - rc = evio_get_joystick_status(eviodev, &ax1, &ay1, &ax2, &ay2, &buttons); - - if (buttons) { - printf("Joystick: %5.2f %5.2f %5.2f %5.2f 0x%08x \n", - ax1, ay1, ax2, ay2, buttons); - } - - float tx = ax1 + ax2; - float ty = ay1; - float tz = ay2; - - // check for translation and handle it... - if (fabsf(tx) > 0.03 || fabsf(ty) > 0.03 || fabsf(tz) > 0.03) { - tx *= -500; - ty *= 500; - tz *= 500; - - // Re-use the HMD head pose info obtained above to apply - // head motion translations from joysticks or other controllers - float zoommod = 2.0f*cam_zoom/cam_zoom_orig; - float divlen = sqrtf(wsx*wsx + wsy*wsy) * 50; - float dU[3], dV[3], dW[3]; - vec_scale(dU, -tx * zoommod / divlen, hmd_U_new); - vec_scale(dV, -ty * zoommod / divlen, hmd_V_new); - vec_scale(dW, -tz * zoommod / divlen, hmd_W_new); - vec_add(cam_pos, cam_pos, dU); - vec_add(cam_pos, cam_pos, dV); - vec_add(cam_pos, cam_pos, dW); - winredraw = 1; - } - - } -#endif - - - // - // handle window resizing, stereoscopic mode changes, - // destroy and recreate affected OptiX buffers - // - int resize_buffers=0; - -#if defined(VMDOPTIX_USE_HMD) - // when using spheremaps, we trigger redraw ops but we do not change - // the spheremap image size - if (hmd_freerun) { - if (wsx != owsx || wsy != owsy) - winredraw=1; - } - else -#endif - { - // only process image/window resizing when not drawing spheremaps - if (wsx != width) { - width = wsx; - resize_buffers=1; - } - - if (wsy != height || (stereoon != stereoon_old)) { - if (stereoon) { - if (height != wsy * 2) { - height = wsy * 2; - resize_buffers=1; - } - } else { - height = wsy; - resize_buffers=1; - } - } - } - - -// XXX Prior to OptiX 3.8, we had to manually stop progressive -// mode before changing any OptiX state. -#if defined(VMDOPTIX_PROGRESSIVEAPI) && OPTIX_VERSION < 3080 - // - // Check for all conditions that would require modifying OptiX state - // and tell the VCA to stop progressive rendering before we modify - // the rendering state, - // - if (done || winredraw || resize_buffers || - (stereoon != stereoon_old) || (gl_dof_on != gl_dof_on_old)) { - // need to issue stop command before editing optix objects - if (vcarunning) { - rtContextStopProgressive(ctx); - vcarunning=0; - } - } -#endif - - // check if stereo mode or DoF mode changed, both cases - // require changing the active color accumulation ray gen program - if ((stereoon != stereoon_old) || (gl_dof_on != gl_dof_on_old)) { - // when stereo mode changes, we have to regenerate the - // the RNG, accumulation buffer, and framebuffer - if (stereoon != stereoon_old) { - resize_buffers=1; - } - - // update stereo and DoF state - stereoon_old = stereoon; - gl_dof_on_old = gl_dof_on; - - // set the active color accumulation ray gen program based on the - // camera/projection mode, stereoscopic display mode, - // and depth-of-field state - set_accum_raygen_pgm(camera_projection, stereoon, gl_dof_on); - } - - if (resize_buffers) { - framebuffer_resize(width, height); - - // when movie recording is enabled, print the window size as a guide - // since the user might want to precisely control the size or - // aspect ratio for a particular movie format, e.g. 1080p, 4:3, 16:9 - if (movie_recording_enabled) { - printf("\rOptiXRenderer) Window resize: %d x %d \n", width, height); - } - - winredraw=1; - } - - int frame_ready = 1; // Default to true for the non-VCA case - unsigned int subframe_count = 1; - if (!done) { -#if defined(VMDOPTIX_USE_HMD) - // update HMD lens distortion correction mesh and/or warp coefficients - if (hmd_warp && (winredraw || hmd_warp_coeff_update)) { - glwin_spheremap_update_hmd_warp(win, hmd_warp, wsx, wsy, 21, - width, height, hmd_warp_coeff, - hmd_warp_coeff_update); - hmd_warp_coeff_update=0; - } -#endif - - // - // If the user interacted with the window in a meaningful way, we - // need to update the OptiX rendering state, recompile and re-validate - // the context, and then re-render... - // - if (winredraw) { - // update camera parameters - RTERR( rtVariableSet1f( cam_zoom_v, cam_zoom) ); - RTERR( rtVariableSet3fv( cam_pos_v, cam_pos) ); - RTERR( rtVariableSet3fv( cam_U_v, hmd_U) ); - RTERR( rtVariableSet3fv( cam_V_v, hmd_V) ); - RTERR( rtVariableSet3fv( cam_W_v, hmd_W) ); - RTERR( rtVariableSet3fv(scene_gradient_v, scene_gradient) ); - - // update shadow state - RTERR( rtVariableSet1i(shadows_enabled_v, gl_shadows_on) ); - - // update depth cueing state - RTERR( rtVariableSet1i(fog_mode_v, - (int) (gl_fog_on) ? fog_mode : RT_FOG_NONE) ); - - // update clipping sphere state - RTERR( rtVariableSet1i(clipview_mode_v, - (int) (gl_clip_on) ? clipview_mode : RT_CLIP_NONE) ); - - // update headlight state - RTERR( rtVariableSet1i(headlight_mode_v, - (int) (gl_headlight_on) ? RT_HEADLIGHT_ON : RT_HEADLIGHT_OFF) ); - - // update/recompute DoF values - RTERR( rtVariableSet1f(cam_dof_focal_dist_v, cam_dof_focal_dist) ); - RTERR( rtVariableSet1f(cam_dof_aperture_rad_v, cam_dof_focal_dist / (2.0f * cam_zoom * cam_dof_fnumber)) ); - - // - // Update light directions in the OptiX light buffer or user object. - // Only update when xformlights is set, otherwise we take a - // speed hit when using a remote VCA cluster for rendering. - // - // We only transform directional lights, since our positional lights - // are normally affixed to the model coordinate system rather than - // the camera. - // - if (xformlights) { -#if defined(VMDOPTIX_LIGHTUSEROBJS) - DirectionalLightList dlights; - memset(&dlights, 0, sizeof(DirectionalLightList) ); - dlights.num_lights = directional_lights.num(); - int dlcount = directional_lights.num(); - dlcount = (dlcount > DISP_LIGHTS) ? DISP_LIGHTS : dlcount; - for (i=0; i 37) - samples_per_pass++; - else if (fpsexpave < 30) - samples_per_pass--; - - // clamp sample counts to a "safe" range - if (samples_per_pass > 14) - samples_per_pass=14; - if (samples_per_pass < 1) - samples_per_pass=1; - } - - // split samples per pass either among AA and AO, depending on - // whether DoF and AO are enabled or not. - if (force_ao_1) { - cur_aa_samples = samples_per_pass; - cur_ao_samples = 1; - } else if (gl_shadows_on && gl_ao_on) { - if (gl_dof_on) { - if (samples_per_pass < 4) { - cur_aa_samples=samples_per_pass; - cur_ao_samples=1; - } else { - int s = (int) sqrtf(samples_per_pass); - cur_aa_samples=s; - cur_ao_samples=s; - } - } else { - cur_aa_samples=1; - cur_ao_samples=samples_per_pass; - } - } else { - cur_aa_samples=samples_per_pass; - cur_ao_samples=0; - } - - // update the current AA/AO sample counts since they may be changing if - // FPS autotuning is enabled... - RTERR( rtVariableSet1i(aa_samples_v, cur_aa_samples) ); - - // observe latest AO enable/disable flag, and sample count - if (gl_shadows_on && gl_ao_on) { - RTERR( rtVariableSet1i(ao_samples_v, cur_ao_samples) ); - } else { - cur_ao_samples = 0; - RTERR( rtVariableSet1i(ao_samples_v, 0) ); - } - -#ifdef VMDOPTIX_PROGRESSIVEAPI - RTERR( rtVariableSet1f(accum_norm_v, 1.0f / float(cur_aa_samples)) ); -#endif - - // updated cached copy of previous window dimensions so we can - // trigger updates on HMD spheremaps and FBOs as necessary - owsx = wsx; - owsy = wsy; - } - - - // - // The non-VCA code path must handle the accumulation buffer - // for itself, correctly rescaling the accumulated samples when - // drawing to the output framebuffer. - // - // The VCA code path takes care of normalization for itself. - // -#ifndef VMDOPTIX_PROGRESSIVEAPI - // The accumulation buffer normalization factor must be updated - // to reflect the total accumulation count before the accumulation - // buffer is drawn to the output framebuffer - RTERR( rtVariableSet1f(accum_norm_v, 1.0f / float(cur_aa_samples + accum_count)) ); - - // The accumulation buffer subframe index must be updated to ensure that - // the RNGs for AA and AO get correctly re-seeded - RTERR( rtVariableSet1ui(accum_count_v, accum_count) ); - - // Force context compilation/validation - // If no state has changed, there's no need to recompile/validate. - // This call can be omitted since OptiX will do this automatically - // at the next rtContextLaunchXXX() call. -// render_compile_and_validate(); -#endif - - - // - // run the renderer - // - frame_ready = 1; // Default to true for the non-VCA case - subframe_count = 1; - if (lasterror == RT_SUCCESS) { - if (winredraw) { -#if defined(ORT_RAYSTATS) - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_CLEAR_RAYSTATS, width, height) ); - accumbufstarttime=wkf_timer_timenow(ort_timer); -#endif -#ifdef VMDOPTIX_PROGRESSIVEAPI - // start the VCA doing progressive rendering... - RTERR( rtContextLaunchProgressive2D(ctx, RT_RAY_GEN_ACCUMULATE, width, height, 0) ); -#else - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_CLEAR_ACCUMULATION_BUFFER, width, height) ); -#endif - winredraw=0; - } - -#ifdef VMDOPTIX_PROGRESSIVEAPI - // Wait for the next frame to arrive - RTERR( rtBufferGetProgressiveUpdateReady(framebuffer, &frame_ready, &subframe_count, 0) ); - if (frame_ready) - totalsamplecount = subframe_count * samples_per_pass; -#else - // iterate, adding to the accumulation buffer... - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_ACCUMULATE, width, height) ); - subframe_count++; // increment subframe index - totalsamplecount += samples_per_pass; - accum_count += cur_aa_samples; - - // copy the accumulation buffer image data to the framebuffer and - // perform type conversion and normaliztion on the image data... - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_COPY_FINISH, width, height) ); -#endif - - if (lasterror == RT_SUCCESS) { - if (frame_ready || hmd_freerun) { - double bufnewtime = wkf_timer_timenow(ort_timer); - - // if an HMD is connected and one of the panoramic image formats - // is in use, we use the appopriate OpenGL HMD viewer for the - // panoramic image format that's currently active, otherwise the - // image is displayed as-is in a window. -#if defined(VMDOPTIX_USE_HMD) - if (hmd_freerun) { - double hmdnewtime = wkf_timer_timenow(ort_timer); - double hmdframetime = (hmdnewtime-hmdoldtime) + 0.00001f; - hmdoldtime=hmdnewtime; - - // compute exponential moving average for exp(-1/10) - double hmdframefps = 1.0f/hmdframetime; - hmdfpsexpave = (hmdfpsexpave * 0.90) + (hmdframefps * 0.10); - - float hmdquat[4]; - if (hmd_no_draw == 0) { - int hmd_warp_on = (hmd_warp_drawmode!=0); - int hmd_warp_lines = (hmd_warp_drawmode==2 || hmd_warp_drawmode==4); - int hmd_chroma_on = (hmd_warp_drawmode==1 || hmd_warp_drawmode==2); - - // update when frame is ready, or when tex caching is disabled - if (frame_ready || (!hmd_tex_caching)) { - // display output image - const unsigned char * img; - rtBufferMap(framebuffer, (void **) &img); - - // minimize impact of OptiX buffer map and tex update steps - if (hmd_interleave_draws) { - // query HMD sensors immediately prior to draw... - hmd->get_rot_quat(hmdquat, 1); - if (hmd_warp && hmd_warp_drawmode != 0) { - glwin_spheremap_draw_hmd_warp(win, hmd_warp, - hmd_warp_on, hmd_warp_lines, hmd_chroma_on, - wsx, wsy, width, height, hmdquat, hmd_fov, 15.0f, hmd_spres); - } else { - glwin_spheremap_draw_tex(win, GLWIN_STEREO_OVERUNDER, width, height, hmdquat, hmd_fov, 15.0f, hmd_spres); - } - glwin_swap_buffers(win); - } - - glwin_spheremap_upload_tex_rgb3u(win, width, height, img); - - // minimize impact of OptiX buffer map and tex update steps - if (hmd_interleave_draws) { - // query HMD sensors immediately prior to draw... - hmd->get_rot_quat(hmdquat, 1); - if (hmd_warp && hmd_warp_drawmode != 0) { - glwin_spheremap_draw_hmd_warp(win, hmd_warp, - hmd_warp_on, hmd_warp_lines, hmd_chroma_on, - wsx, wsy, width, height, hmdquat, hmd_fov, 15.0f, hmd_spres); - } else { - glwin_spheremap_draw_tex(win, GLWIN_STEREO_OVERUNDER, width, height, hmdquat, hmd_fov, 15.0f, hmd_spres); - } - glwin_swap_buffers(win); - } - - rtBufferUnmap(framebuffer); - mapbuftotaltime = wkf_timer_timenow(ort_timer) - bufnewtime; - } - - // query HMD sensors immediately prior to draw... - hmd->get_rot_quat(hmdquat, 1); - if (hmd_warp && hmd_warp_drawmode != 0) { - glwin_spheremap_draw_hmd_warp(win, hmd_warp, - hmd_warp_on, hmd_warp_lines, hmd_chroma_on, - wsx, wsy, width, height, hmdquat, hmd_fov, 15.0f, hmd_spres); - } else { - glwin_spheremap_draw_tex(win, GLWIN_STEREO_OVERUNDER, width, height, hmdquat, hmd_fov, 15.0f, hmd_spres); - } - glwin_swap_buffers(win); - } - - hmdgldrawtime = wkf_timer_timenow(ort_timer) - hmdnewtime; - } else { -#endif - // display output image - const unsigned char * img; - rtBufferMap(framebuffer, (void **) &img); - -#if 0 - glwin_draw_image_tex_rgb3u(win, (stereoon!=0)*GLWIN_STEREO_OVERUNDER, width, height, img); -#else - glwin_draw_image_rgb3u(win, (stereoon!=0)*GLWIN_STEREO_OVERUNDER, width, height, img); -#endif - -#if 1 - // push latest frame into the video streaming pipeline - // and pump the event handling mechanism afterwards - if (app->uivs && app->uivs->srv_connected()) { - app->uivs->video_frame_pending(img, width, height); - app->uivs->check_event(); - } -#endif - - rtBufferUnmap(framebuffer); - mapbuftotaltime = wkf_timer_timenow(ort_timer) - bufnewtime; - -#if defined(VMDOPTIX_USE_HMD) - } -#endif - - - // if live movie recording is on, we save every displayed frame - // to a sequence sequence of image files, with each file numbered - // by its frame index, which is computed by the multiplying image - // presentation time by the image sequence fixed-rate-FPS value. - if (movie_recording_enabled && movie_recording_on) { - char moviefilename[2048]; - - // compute frame number from wall clock time and the - // current fixed-rate movie playback frame rate - double now = wkf_timer_timenow(ort_timer); - double frametime = now - movie_recording_start_time; - int fidx = frametime * movie_recording_fps; - - // always force the first recorded frame to be 0 - if (movie_framecount==0) - fidx=0; - movie_framecount++; - -#if defined(__linux) - // generate symlinks for frame indices between the last written - // frame and the current one so that video encoders such as - // ffmpeg and mencoder can be fed the contiguous frame sequence - // at a fixed frame rate, as they require - sprintf(moviefilename, movie_recording_filebase, - movie_lastframeindex); - int symidx; - for (symidx=movie_lastframeindex; symidx 0); - int gl_dof_on, gl_dof_on_old; - gl_dof_on=gl_dof_on_old=dof_enabled; - int gl_fog_on=(fog_mode != RT_FOG_NONE); - int gl_clip_on=(clipview_mode != RT_CLIP_NONE); - int gl_headlight_on=(headlight_mode != RT_HEADLIGHT_OFF); - - // Enable live recording of a session to a stream of image files indexed - // by their display presentation time, mapped to the nearest frame index - // in a fixed-frame-rate image sequence (e.g. 24, 30, or 60 FPS), - // to allow subsequent encoding into a standard movie format. - // XXX this feature is disabled by default at present, to prevent people - // from accidentally turning it on during a live demo or the like - int movie_recording_enabled = (getenv("VMDOPTIXLIVEMOVIECAPTURE") != NULL); - int movie_recording_on = 0; - double movie_recording_start_time = 0.0; - int movie_recording_fps = 30; - int movie_framecount = 0; - int movie_lastframeindex = 0; - const char *movie_recording_filebase = "vmdlivemovie.%05d.tga"; - if (getenv("VMDOPTIXLIVEMOVIECAPTUREFILEBASE")) - movie_recording_filebase = getenv("VMDOPTIXLIVEMOVIECAPTUREFILEBASE"); - - // total AA/AO sample count - int totalsamplecount=0; - - // counter for snapshots of live image... - //int snapshotcount=0; - - // flag to enable automatic AO sample count adjustment for FPS rate control -#if defined(VMDOPTIX_PROGRESSIVEAPI) -#if 1 - int autosamplecount=0; // leave disabled for now -#else - int autosamplecount=1; // works partially in current revs of progressive API -#endif -#else - int autosamplecount=1; -#endif - - // flag to enable transformation of lights and gradient sky sphere, - // so that they track camera orientation as they do in the VMD OpenGL display - int xformlights=1, xformgradientsphere=1; - - // - // allocate or reconfigure the framebuffer, accumulation buffer, - // and output streams required for progressive rendering, either - // using the new progressive APIs, or using our own code. - // - // Unless overridden by environment variables, we use the incoming - // window size parameters from VMD to initialize the RT image dimensions. - // If image size is overridden, often when using HMDs, the incoming - // dims are window dims are used to size the GL window, but the image size - // is set independently. - int wsx=width, wsy=height; - const char *imageszstr = getenv("VMDOPTIXIMAGESIZE"); - if (imageszstr) { - if (sscanf(imageszstr, "%d %d", &width, &height) != 2) { - width=wsx; - height=wsy; - } - } - - framebuffer_config(width, height, 1); - - // prepare the majority of OptiX rendering state before we go into - // the interactive rendering loop - update_rendering_state(1); - render_compile_and_validate(); - - // make a copy of state we're going to interactively manipulate, - // so that we can recover to the original state on-demand - int samples_per_pass = 1; - int force_ao_1 = 0; // whether or not to force AO count per pass to 1 - int cur_aa_samples = aa_samples; - int cur_ao_samples = ao_samples; - float cam_zoom_orig = cam_zoom; - float scene_gradient_orig[3] = {0.0f, 1.0f, 0.0f}; - vec_copy(scene_gradient_orig, scene_gradient); - - float cam_pos_orig[3] = {0.0f, 0.0f, 2.0f}; - float cam_U_orig[3] = {1.0f, 0.0f, 0.0f}; - float cam_V_orig[3] = {0.0f, 1.0f, 0.0f}; - float cam_W_orig[3] = {0.0f, 0.0f, -1.0f}; - float cam_pos[3], cam_U[3], cam_V[3], cam_W[3]; - float hmd_U[3], hmd_V[3], hmd_W[3]; - - vec_copy(cam_pos, cam_pos_orig); - vec_copy(cam_U, cam_U_orig); - vec_copy(cam_V, cam_V_orig); - vec_copy(cam_W, cam_W_orig); - - // copy light directions - DirectionalLight *cur_dlights = (DirectionalLight *) calloc(1, directional_lights.num() * sizeof(DirectionalLight)); - for (i=0; i 0) { - cur_aa_samples = 1; - cur_ao_samples = samples_per_pass; - } - - const char *statestr = "|/-\\."; - int done=0, winredraw=1; - int state=0; - //float cur_cam_zoom = cam_zoom_orig; - - double fpsexpave=0.0; - double accumbufstarttime=wkf_timer_timenow(ort_timer); - double oldtime = wkf_timer_timenow(ort_timer); - // Note: we immediately terminate the rendering loop if - // the videostream server loses its client connection(s) - while (!done && - app->uivs && app->uivs->srv_connected()) { - -#if 1 - if (app->uivs && app->uivs->srv_connected()) { - if (app->uivs->srv_check_ui_event()) { - int eventtype; - app->uivs->srv_get_last_event_type(eventtype); - switch (eventtype) { - case VideoStream::VS_EV_ROTATE_BY: - { int axis; - float angle; - app->uivs->srv_get_last_rotate_by(angle, axis); - Matrix4 rm; - - switch (axis) { - case 'x': - rm.rotate_axis(cam_U, -angle * VMD_PI/180.0f); - break; - - case 'y': - rm.rotate_axis(cam_V, -angle * VMD_PI/180.0f); - break; - - case 'z': - rm.rotate_axis(cam_W, -angle * VMD_PI/180.0f); - break; - } - rm.multpoint3d(cam_pos, cam_pos); - rm.multnorm3d(cam_U, cam_U); - rm.multnorm3d(cam_V, cam_V); - rm.multnorm3d(cam_W, cam_W); - - if (xformgradientsphere) { - rm.multnorm3d(scene_gradient, scene_gradient); - } - - if (xformlights) { - // update light directions (comparatively costly) - for (i=0; iuivs->srv_get_last_translate_by(tx, ty, tz); - vec_scale(dU, -tx, cam_U); - vec_scale(dV, -ty, cam_V); - vec_scale(dW, -tz, cam_W); - vec_add(cam_pos, cam_pos, dU); - vec_add(cam_pos, cam_pos, dV); - vec_add(cam_pos, cam_pos, dW); - winredraw = 1; - } - break; - - case VideoStream::VS_EV_SCALE_BY: - { float zoominc; - app->uivs->srv_get_last_scale_by(zoominc); - cam_zoom *= 1.0f / zoominc; - winredraw = 1; - } - break; - -#if 0 - } else if (mm == RTMM_DOF) { - cam_dof_fnumber += txdx * 20.0f; - if (cam_dof_fnumber < 1.0f) cam_dof_fnumber = 1.0f; - cam_dof_focal_dist += -txdy; - if (cam_dof_focal_dist < 0.01f) cam_dof_focal_dist = 0.01f; - winredraw = 1; - } - } -#endif - case VideoStream::VS_EV_KEYBOARD: - { int keydev, keyval, shift_state; - app->uivs->srv_get_last_keyboard(keydev, keyval, shift_state); - switch (keydev) { - case DisplayDevice::WIN_KBD: - { - switch (keyval) { - // update sample counts - case '1': autosamplecount=0; samples_per_pass=1; winredraw=1; break; - case '2': autosamplecount=0; samples_per_pass=2; winredraw=1; break; - case '3': autosamplecount=0; samples_per_pass=3; winredraw=1; break; - case '4': autosamplecount=0; samples_per_pass=4; winredraw=1; break; - case '5': autosamplecount=0; samples_per_pass=5; winredraw=1; break; - case '6': autosamplecount=0; samples_per_pass=6; winredraw=1; break; - case '7': autosamplecount=0; samples_per_pass=7; winredraw=1; break; - case '8': autosamplecount=0; samples_per_pass=8; winredraw=1; break; - case '9': autosamplecount=0; samples_per_pass=9; winredraw=1; break; - case '0': autosamplecount=0; samples_per_pass=10; winredraw=1; break; - - case '=': /* recover back to initial state */ - vec_copy(scene_gradient, scene_gradient_orig); - cam_zoom = cam_zoom_orig; - vec_copy(cam_pos, cam_pos_orig); - vec_copy(cam_U, cam_U_orig); - vec_copy(cam_V, cam_V_orig); - vec_copy(cam_W, cam_W_orig); - - // restore original light directions - for (i=0; i DISP_LIGHTS) ? DISP_LIGHTS : dlcount; - for (i=0; i 37) - samples_per_pass++; - else if (fpsexpave < 30) - samples_per_pass--; - - // clamp sample counts to a "safe" range - if (samples_per_pass > 14) - samples_per_pass=14; - if (samples_per_pass < 1) - samples_per_pass=1; - } - - // split samples per pass either among AA and AO, depending on - // whether DoF and AO are enabled or not. - if (force_ao_1) { - cur_aa_samples = samples_per_pass; - cur_ao_samples = 1; - } else if (gl_shadows_on && gl_ao_on) { - if (gl_dof_on) { - if (samples_per_pass < 4) { - cur_aa_samples=samples_per_pass; - cur_ao_samples=1; - } else { - int s = (int) sqrtf(samples_per_pass); - cur_aa_samples=s; - cur_ao_samples=s; - } - } else { - cur_aa_samples=1; - cur_ao_samples=samples_per_pass; - } - } else { - cur_aa_samples=samples_per_pass; - cur_ao_samples=0; - } - - // update the current AA/AO sample counts since they may be changing if - // FPS autotuning is enabled... - RTERR( rtVariableSet1i(aa_samples_v, cur_aa_samples) ); - - // observe latest AO enable/disable flag, and sample count - if (gl_shadows_on && gl_ao_on) { - RTERR( rtVariableSet1i(ao_samples_v, cur_ao_samples) ); - } else { - cur_ao_samples = 0; - RTERR( rtVariableSet1i(ao_samples_v, 0) ); - } - -#ifdef VMDOPTIX_PROGRESSIVEAPI - RTERR( rtVariableSet1f(accum_norm_v, 1.0f / float(cur_aa_samples)) ); -#endif - - // updated cached copy of previous window dimensions so we can - // trigger updates on HMD spheremaps and FBOs as necessary - // owsx = wsx; - // owsy = wsy; - } - - - // - // The non-VCA code path must handle the accumulation buffer - // for itself, correctly rescaling the accumulated samples when - // drawing to the output framebuffer. - // - // The VCA code path takes care of normalization for itself. - // -#ifndef VMDOPTIX_PROGRESSIVEAPI - // The accumulation buffer normalization factor must be updated - // to reflect the total accumulation count before the accumulation - // buffer is drawn to the output framebuffer - RTERR( rtVariableSet1f(accum_norm_v, 1.0f / float(cur_aa_samples + accum_count)) ); - - // The accumulation buffer subframe index must be updated to ensure that - // the RNGs for AA and AO get correctly re-seeded - RTERR( rtVariableSet1ui(accum_count_v, accum_count) ); - - // Force context compilation/validation - // If no state has changed, there's no need to recompile/validate. - // This call can be omitted since OptiX will do this automatically - // at the next rtContextLaunchXXX() call. -// render_compile_and_validate(); -#endif - - - // - // run the renderer - // - frame_ready = 1; // Default to true for the non-VCA case - subframe_count = 1; - if (lasterror == RT_SUCCESS) { - if (winredraw) { -#if defined(ORT_RAYSTATS) - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_CLEAR_RAYSTATS, width, height) ); - accumbufstarttime=wkf_timer_timenow(ort_timer); -#endif -#ifdef VMDOPTIX_PROGRESSIVEAPI - // start the VCA doing progressive rendering... - RTERR( rtContextLaunchProgressive2D(ctx, RT_RAY_GEN_ACCUMULATE, width, height, 0) ); -#else - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_CLEAR_ACCUMULATION_BUFFER, width, height) ); -#endif - winredraw=0; - } - -#ifdef VMDOPTIX_PROGRESSIVEAPI - // Wait for the next frame to arrive - RTERR( rtBufferGetProgressiveUpdateReady(framebuffer, &frame_ready, &subframe_count, 0) ); - if (frame_ready) - totalsamplecount = subframe_count * samples_per_pass; -#else - // iterate, adding to the accumulation buffer... - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_ACCUMULATE, width, height) ); - subframe_count++; // increment subframe index - totalsamplecount += samples_per_pass; - accum_count += cur_aa_samples; - - // copy the accumulation buffer image data to the framebuffer and - // perform type conversion and normaliztion on the image data... - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_COPY_FINISH, width, height) ); -#endif - - if (lasterror == RT_SUCCESS) { - if (frame_ready) { - // display output image - const unsigned char * img; - rtBufferMap(framebuffer, (void **) &img); - -#if 1 - // push latest frame into the video streaming pipeline - // and pump the event handling mechanism afterwards - if (app->uivs && app->uivs->srv_connected()) { - app->uivs->video_frame_pending(img, width, height); - app->uivs->check_event(); - } -#endif - - rtBufferUnmap(framebuffer); - - // if live movie recording is on, we save every displayed frame - // to a sequence sequence of image files, with each file numbered - // by its frame index, which is computed by the multiplying image - // presentation time by the image sequence fixed-rate-FPS value. - if (movie_recording_enabled && movie_recording_on) { - char moviefilename[2048]; - - // compute frame number from wall clock time and the - // current fixed-rate movie playback frame rate - double now = wkf_timer_timenow(ort_timer); - double frametime = now - movie_recording_start_time; - int fidx = frametime * movie_recording_fps; - - // always force the first recorded frame to be 0 - if (movie_framecount==0) - fidx=0; - movie_framecount++; - -#if defined(__linux) - // generate symlinks for frame indices between the last written - // frame and the current one so that video encoders such as - // ffmpeg and mencoder can be fed the contiguous frame sequence - // at a fixed frame rate, as they require - sprintf(moviefilename, movie_recording_filebase, - movie_lastframeindex); - int symidx; - for (symidx=movie_lastframeindex; symidxmaterialtag, - cmdList->ambient, - cmdList->diffuse, - cmdList->specular, - cmdList->shininess, - cmdList->mirror, - cmdList->opacity, - cmdList->outline, - cmdList->outlinewidth, - cmdList->transmode); -} - - -void OptiXRenderer::scene_aggregate_cmdlist(const VMDDisplayList *cmdList, - const float *colorData) { -// printf("OptiXRenderer) --> RTX RTRT Passthrough\n"); - - char *cmdptr = NULL; // ptr to current display command data - int tok; // what display command was encountered - - // early exit if any of these conditions are true. - if (!cmdList) - return; - - Stack transMat(10); - Matrix4 m; - transMat.push(m); // push on the identity matrix - (transMat.top()).multmatrix(cmdList->mat); // save transformation matrix - - // set up text matrices -// Matrix4 textMat(ogl_textMat); -// textMat.multmatrix(cmdList->mat); - -#if 0 - // enable/disable clipping planes - for (int cp=0; cpclipplanes[cp].mode) { - } - } -#endif - -#if 0 - // Compute periodic image transformation matrices - ResizeArray pbcImages; - find_pbc_images(cmdList, pbcImages); - int npbcimages = pbcImages.num(); - - // Retreive instance image transformation matrices - ResizeArray instanceImages; - find_instance_images(cmdList, instanceImages); - int ninstances = instanceImages.num(); - - for (int pbcimage = 0; pbcimage < npbcimages; pbcimage++) { - transMat.dup(); - (transMat.top()).multmatrix(pbcImages[pbcimage]); - for (int instanceimage = 0; instanceimage < ninstances; instanceimage++) { - transMat.dup(); - (transMat.top()).multmatrix(instanceImages[instanceimage]); - } - } -#endif - -#if 0 - // find previously cached display list for this object - if (ogl_cacheenabled && !ogl_cacheskip) { - ogl_cachedid = displaylistcache.markUsed(cmdList->serial); - - // add to the cache and regenerate if we didn't find it - if (ogl_cachedid == GLCACHE_FAIL) { - ogl_cachedid = glGenLists(1); - displaylistcache.encache(cmdList->serial, ogl_cachedid); - - // create the display list, and execute it. - glNewList(ogl_cachedid, GL_COMPILE_AND_EXECUTE); - ogl_cachecreated = 1; // a new display list was created - } - } - - // XXX Draw OpenGL geometry only when caching is disabled or when - // we have new geometry to cache - if ((!ogl_cacheenabled) || ogl_cacheskip || (ogl_cacheenabled && ogl_cachecreated)) { -#endif - - - // scan through the list, getting each command and executing it, until - // the end of commands token is found - int colorIndex = 0; - VMDDisplayList::VMDLinkIter cmditer; - cmdList->first(&cmditer); - while((tok = cmdList->next(&cmditer, cmdptr)) != DLASTCOMMAND) { - switch (tok) { - case DCOLORINDEX: - colorIndex = (((DispCmdColorIndex *)cmdptr)->color); - break; - - case DCYLINDER: // plot a cylinder - { - add_material_cmdlist(cmdList); - - // XXX these should be getting aggregated in a batch - - float points[6], radii[1], colors[3]; - memcpy(points, (float *)cmdptr, 3L*sizeof(float)); - memcpy(&points[3], ((float *)cmdptr) + 3, 3L*sizeof(float)); - radii[0] = ((float *)cmdptr)[6]; - int filled = ((int) ((float *) cmdptr)[8]); - memcpy(colors, &colorData[colorIndex*3L], 3L*sizeof(float)); - - float *mat = &transMat.top().mat[0]; - float scaleFactor = - (sqrtf(mat[0]*mat[0] + mat[4]*mat[4] + mat[ 8]*mat[ 8]) + - sqrtf(mat[1]*mat[1] + mat[5]*mat[5] + mat[ 9]*mat[ 9]) + - sqrtf(mat[2]*mat[2] + mat[6]*mat[6] + mat[10]*mat[10])) / 3.0f; - - // Submit all geometry in one buffer - cylinder_array_color(&transMat.top(), scaleFactor, - 1, points, radii, colors, - cmdList->materialtag); - - // XXX no filled cylinder caps yet - - } - break; - - case DCYLINDERARRAY: - { - add_material_cmdlist(cmdList); - - DispCmdCylinderArray *ca = (DispCmdCylinderArray *)cmdptr; - float *points, *radii, *colors; - ca->getpointers(points, radii, colors); - - float *mat = &transMat.top().mat[0]; - float scaleFactor = - (sqrtf(mat[0]*mat[0] + mat[4]*mat[4] + mat[ 8]*mat[ 8]) + - sqrtf(mat[1]*mat[1] + mat[5]*mat[5] + mat[ 9]*mat[ 9]) + - sqrtf(mat[2]*mat[2] + mat[6]*mat[6] + mat[10]*mat[10])) / 3.0f; - - // Submit all geometry in one buffer - cylinder_array_color(&transMat.top(), scaleFactor, - ca->numcylinders, points, radii, colors, - cmdList->materialtag); - } - break; - - case DSPHERE: - { - add_material_cmdlist(cmdList); - - // XXX these should be getting aggregated in a batch - - float centers[3], radii[1], color[3]; - memcpy(centers, (float *)cmdptr, 3L*sizeof(float)); - radii[0] = ((float *)cmdptr)[3]; - - float *mat = &transMat.top().mat[0]; - float scaleFactor = - (sqrtf(mat[0]*mat[0] + mat[4]*mat[4] + mat[ 8]*mat[ 8]) + - sqrtf(mat[1]*mat[1] + mat[5]*mat[5] + mat[ 9]*mat[ 9]) + - sqrtf(mat[2]*mat[2] + mat[6]*mat[6] + mat[10]*mat[10])) / 3.0f; - - // Submit all geometry in one buffer - sphere_array_color(transMat.top(), scaleFactor, - 1, centers, radii, &colorData[colorIndex*3L], - cmdList->materialtag); - } - break; - - case DSPHEREARRAY: - { - add_material_cmdlist(cmdList); - - DispCmdSphereArray *sa = (DispCmdSphereArray *)cmdptr; - float *centers, *radii, *colors; - sa->getpointers(centers, radii, colors); - - float *mat = &transMat.top().mat[0]; - float scaleFactor = - (sqrtf(mat[0]*mat[0] + mat[4]*mat[4] + mat[ 8]*mat[ 8]) + - sqrtf(mat[1]*mat[1] + mat[5]*mat[5] + mat[ 9]*mat[ 9]) + - sqrtf(mat[2]*mat[2] + mat[6]*mat[6] + mat[10]*mat[10])) / 3.0f; - - // Submit all geometry in one buffer - sphere_array_color(transMat.top(), scaleFactor, - sa->numspheres, centers, radii, colors, - cmdList->materialtag); - } - break; - - case DTRIMESH_C3F_N3F_V3F: // draw a triangle mesh - { - add_material_cmdlist(cmdList); - - DispCmdTriMesh *cmd = (DispCmdTriMesh *) cmdptr; - float *c=NULL, *n=NULL, *v=NULL; - - if (cmd->pervertexcolors) { - cmd->getpointers(c, n, v); -#if 1 - printf("Dropped trimesh_c3f_n3f_v3f()\n"); -#else - // XXX unimplemented - trimesh_c3f_n3f_v3f(transMat.top(), c, n, v, cmd->numfacets, - cmdList->materialtag); -#endif - } else if (cmd->pervertexnormals) { - cmd->getpointers(n, v); - trimesh_n3f_v3f(transMat.top(), &colorData[colorIndex * 3], - n, v, cmd->numfacets, cmdList->materialtag); - } else { - cmd->getpointers(n, v); - trimesh_v3f(transMat.top(), &colorData[colorIndex * 3], - v, cmd->numfacets, cmdList->materialtag); - } - } - break; - - case DTRIMESH_C4F_N3F_V3F: - { - add_material_cmdlist(cmdList); - - // draw a triangle mesh - DispCmdTriMesh *cmd = (DispCmdTriMesh *) cmdptr; - int ind = cmd->numfacets * 3; - float *cnv; - int *f; - cmd->getpointers(cnv, f); - trimesh_c4n3v3(transMat.top(), cmd->numverts, cnv, cmd->numfacets, f, - cmdList->materialtag); - } - break; - - case DTRIMESH_C4U_N3B_V3F: // draw a triangle mesh - { - add_material_cmdlist(cmdList); - - DispCmdTriMesh *cmd = (DispCmdTriMesh *) cmdptr; - unsigned char *c=NULL; - signed char *n=NULL; - float *v=NULL; - - if (cmd->pervertexcolors) { - cmd->getpointers(c, n, v); - trimesh_c4u_n3b_v3f(transMat.top(), c, n, v, cmd->numfacets, - cmdList->materialtag); - } else { - cmd->getpointers(n, v); - trimesh_n3b_v3f(transMat.top(), &colorData[colorIndex * 3], - n, v, cmd->numfacets, cmdList->materialtag); - } - } - break; - - case DTRISTRIP: // draw a triangle strip - { - add_material_cmdlist(cmdList); - - DispCmdTriStrips *cmd = (DispCmdTriStrips *) cmdptr; - float *cnv=NULL; - int *f=NULL; - int *vertsperstrip; - cmd->getpointers(cnv, f, vertsperstrip); - tristrip(transMat.top(), cmd->numverts, cnv, cmd->numstrips, - vertsperstrip, f, cmdList->materialtag); - } - break; - - -#if 0 - default: - // msgErr << "OpenGLRenderer: Unknown drawing token " << tok - // << " encountered ... Skipping this command." << sendmsg; - break; -#endif - } - } -} - - -/// finalize scene and be prepared to render it... -void OptiXRenderer::scene_aggregation_complete() { - update_rendering_state(0); - render_compile_and_validate(); -} - - -// launch rendering pass(es) -void OptiXRenderer::render_current_scene() { - if (lasterror == RT_SUCCESS) { - // clear the accumulation buffer - RTERR( rtContextLaunch2D(ctx, RT_RAY_GEN_CLEAR_ACCUMULATION_BUFFER, width, height) ); - - // Render to the accumulation buffer for the required number of passes - if (getenv("VMDOPTIXNORENDER") == NULL) { - int accum_sample; - for (accum_sample=0; accum_sample= ORTMTABSZ) { - specialized_material_index &= (ORTMTABSZ - 1); - } -#endif - - material = material_special[specialized_material_index]; - - // increment material usage counter - material_special_counts[specialized_material_index]++; - } -#endif - - RTERR( rtGeometryInstanceSetMaterialCount(instance, 1) ); - RTERR( rtGeometryInstanceSetMaterial(instance, 0, material) ); - - if (uniform_color != NULL) { - RTERR( rtGeometryInstanceDeclareVariable(instance, "uniform_color", &uniform_col) ); - RTERR( rtVariableSet3fv(uniform_col, uniform_color) ); - } - - RTERR( rtGeometryInstanceDeclareVariable(instance, "Ka", &ka) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "Kd", &kd) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "Ks", &ks) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "phong_exp", &phongexp) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "Krefl", &krefl) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "opacity", &opacity) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "outline", &outline) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "outlinewidth", &outlinewidth) ); - RTERR( rtGeometryInstanceDeclareVariable(instance, "transmode", &transmode) ); - - RTERR( rtVariableSet1f(ka, materialcache[matindex].ambient) ); - RTERR( rtVariableSet1f(kd, materialcache[matindex].diffuse) ); - RTERR( rtVariableSet1f(ks, materialcache[matindex].specular) ); - RTERR( rtVariableSet1f(phongexp, materialcache[matindex].shininess) ); - RTERR( rtVariableSet1f(krefl, materialcache[matindex].reflectivity) ); - RTERR( rtVariableSet1f(opacity, materialcache[matindex].opacity) ); - RTERR( rtVariableSet1f(outline, materialcache[matindex].outline) ); - RTERR( rtVariableSet1f(outlinewidth, materialcache[matindex].outlinewidth) ); - RTERR( rtVariableSet1i(transmode, materialcache[matindex].transmode) ); -} - - -void OptiXRenderer::add_directional_light(const float *dir, const float *color) { - ort_directional_light l; - vec_copy(l.dir, dir); - vec_copy(l.color, color); - - directional_lights.append(l); -} - - -void OptiXRenderer::add_positional_light(const float *pos, const float *color) { - ort_positional_light l; - vec_copy(l.pos, pos); - vec_copy(l.color, color); - - positional_lights.append(l); -} - - -/// Compute uniform scaling factor for cone/cylinder/sphere primitives -/// if/when flattening the scene graph for best interactive performance. -float OptiXRenderer::calc_matrix_scale_factor(const float *mat) { - float scaleFactor = - (sqrtf(mat[0]*mat[0] + mat[4]*mat[4] + mat[ 8]*mat[ 8]) + - sqrtf(mat[1]*mat[1] + mat[5]*mat[5] + mat[ 9]*mat[ 9]) + - sqrtf(mat[2]*mat[2] + mat[6]*mat[6] + mat[10]*mat[10])) / 3.0f; - - return scaleFactor; -} - - -void OptiXRenderer::cylinder_array(Matrix4 *wtrans, float radius, - const float *uniform_color, - int cylnum, const float *points, - int matindex) { - if (!context_created) return; - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) creating cylinder array: %d...\n", cylnum); - cylinder_array_cnt += cylnum; - - int i, ind; - RTbuffer buf; - RTgeometry geom; - RTgeometryinstance instance; - vmd_cylinder *cyldata; - - // create and fill the OptiX cylinder array memory buffer - rtBufferCreate(ctx, RT_BUFFER_INPUT, &buf); - rtBufferSetFormat(buf, RT_FORMAT_USER); - rtBufferSetElementSize(buf, sizeof(vmd_cylinder)); - rtBufferSetSize1D(buf, cylnum); - // rtBufferValidate(buf); - rtBufferMap(buf, (void **) &cyldata); // map buffer for writing by host - - if (wtrans == NULL) { - for (i=0,ind=0; imultpoint3d(&points[ind], (float*) &cyldata[i].start); - cyldata[i].radius = radius; - float ctmp[3]; - wtrans->multpoint3d(&points[ind+3], ctmp); - vec_sub((float*) &cyldata[i].axis, ctmp, &points[ind]); - } - } - rtBufferUnmap(buf); // cylinder array is complete, unmap buffer - - RTERR( rtGeometryCreate(ctx, &geom) ); - RTERR( rtGeometrySetPrimitiveCount(geom, cylnum) ); - RTERR( rtGeometrySetBoundingBoxProgram(geom, cylinder_array_bbox_pgm) ); - RTERR( rtGeometrySetIntersectionProgram(geom, cylinder_array_isct_pgm) ); - - // this cyl buffer is associated only with this particular geometry node - RTvariable buf_v; - RTERR( rtGeometryDeclareVariable(geom, "cylinder_buffer", &buf_v) ); - RTERR( rtVariableSetObject(buf_v, buf) ); - - // create a geometry instance node and bind materials to this geometry - RTERR( rtGeometryInstanceCreate(ctx, &instance) ); - RTERR( rtGeometryInstanceSetGeometry(instance, geom) ); - - set_material(instance, matindex, uniform_color); - - append_objects(buf, geom, instance); -} - - -void OptiXRenderer::cylinder_array_color(Matrix4 *wtrans, float rscale, - int cylnum, const float *points, - const float *radii, - const float *colors, int matindex) { - if (!context_created) return; - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) creating cylinder color array: %d...\n", cylnum); - cylinder_array_color_cnt += cylnum; - - int i, ind; - RTbuffer buf; - RTgeometry geom; - RTgeometryinstance instance; - vmd_cylinder_color *cyldata; - - // create and fill the OptiX cylinder array memory buffer - rtBufferCreate(ctx, RT_BUFFER_INPUT, &buf); - rtBufferSetFormat(buf, RT_FORMAT_USER); - rtBufferSetElementSize(buf, sizeof(vmd_cylinder_color)); - rtBufferSetSize1D(buf, cylnum); - // rtBufferValidate(buf); - rtBufferMap(buf, (void **) &cyldata); // map buffer for writing by host - - if (wtrans == NULL) { - // already transformed to eye coordinates - if (radii == NULL) { - for (i=0,ind=0; imultpoint3d(&points[ind], (float*) &cyldata[i].start); - cyldata[i].radius = rscale; - float ctmp[3]; - wtrans->multpoint3d(&points[ind+3], ctmp); - vec_sub((float*) &cyldata[i].axis, ctmp, (float*) &cyldata[i].start); - vec_copy((float*) &cyldata[i].color, &colors[i*3]); - } - } else { - for (i=0,ind=0; imultpoint3d(&points[ind], (float*) &cyldata[i].start); - cyldata[i].radius = rscale * radii[i]; - float ctmp[3]; - wtrans->multpoint3d(&points[ind+3], ctmp); - vec_sub((float*) &cyldata[i].axis, ctmp, (float*) &cyldata[i].start); - vec_copy((float*) &cyldata[i].color, &colors[i*3]); - } - } - } - rtBufferUnmap(buf); // cylinder array is complete, unmap buffer - - RTERR( rtGeometryCreate(ctx, &geom) ); - RTERR( rtGeometrySetPrimitiveCount(geom, cylnum) ); - RTERR( rtGeometrySetBoundingBoxProgram(geom, cylinder_array_color_bbox_pgm) ); - RTERR( rtGeometrySetIntersectionProgram(geom, cylinder_array_color_isct_pgm) ); - - // this cyl buffer is associated only with this particular geometry node - RTvariable buf_v; - RTERR( rtGeometryDeclareVariable(geom, "cylinder_color_buffer", &buf_v) ); - RTERR( rtVariableSetObject(buf_v, buf) ); - - // create a geometry instance node and bind materials to this geometry - RTERR( rtGeometryInstanceCreate(ctx, &instance) ); - RTERR( rtGeometryInstanceSetGeometry(instance, geom) ); - - set_material(instance, matindex, NULL); - - append_objects(buf, geom, instance); -} - - -void OptiXRenderer::ring_array_color(Matrix4 & wtrans, float rscale, - int rnum, const float *centers, - const float *norms, const float *radii, - const float *colors, int matindex) { - if (!context_created) return; - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) creating ring array color: %d...\n", rnum); - ring_array_color_cnt += rnum; - - int i, ind; - RTbuffer buf; - RTgeometry geom; - RTgeometryinstance instance; - vmd_ring_color *rdata; - - // create and fill the OptiX ring array memory buffer - rtBufferCreate(ctx, RT_BUFFER_INPUT, &buf); - rtBufferSetFormat(buf, RT_FORMAT_USER); - rtBufferSetElementSize(buf, sizeof(vmd_ring_color)); - rtBufferSetSize1D(buf, rnum); - // rtBufferValidate(buf); - rtBufferMap(buf, (void **) &rdata); // map buffer for writing by host - - for (i=0,ind=0; imultpoint3d(¢ers[ind], (float*) &spdata[i].center); - spdata[i].radius = rscale; // use "rscale" as radius... - } - } else { - for (i=0,ind=0; imultpoint3d(¢ers[ind], (float*) &spdata[i].center); - spdata[i].radius = rscale * radii[i]; - } - } - } - rtBufferUnmap(buf); // sphere array is complete, unmap buffer - - RTERR( rtGeometryCreate(ctx, &geom) ); - RTERR( rtGeometrySetPrimitiveCount(geom, spnum) ); - RTERR( rtGeometrySetBoundingBoxProgram(geom, sphere_array_bbox_pgm) ); - RTERR( rtGeometrySetIntersectionProgram(geom, sphere_array_isct_pgm) ); - - // this sphere buffer is associated only with this particular geometry node - RTvariable buf_v; - RTERR( rtGeometryDeclareVariable(geom, "sphere_buffer", &buf_v) ); - RTERR( rtVariableSetObject(buf_v, buf) ); - - // create a geometry instance node and bind materials to this geometry - RTERR( rtGeometryInstanceCreate(ctx, &instance) ); - RTERR( rtGeometryInstanceSetGeometry(instance, geom) ); - - set_material(instance, matindex, uniform_color); - - append_objects(buf, geom, instance); -} - - -void OptiXRenderer::sphere_array_color(Matrix4 & wtrans, float rscale, - int spnum, const float *centers, - const float *radii, const float *colors, - int matindex) { - if (!context_created) return; - if (verbose == RT_VERB_DEBUG) printf("OptiXRenderer) creating sphere array color: %d...\n", spnum); - sphere_array_color_cnt += spnum; - - int i, ind; - RTbuffer buf; - RTgeometry geom; - RTgeometryinstance instance; - vmd_sphere_color *spdata; - - // create and fill the OptiX sphere array memory buffer - rtBufferCreate(ctx, RT_BUFFER_INPUT, &buf); - rtBufferSetFormat(buf, RT_FORMAT_USER); - rtBufferSetElementSize(buf, sizeof(vmd_sphere_color)); - rtBufferSetSize1D(buf, spnum); - // rtBufferValidate(buf); - rtBufferMap(buf, (void **) &spdata); // map buffer for writing by host - - for (i=0,ind=0; iconfigure.options")) { - print STDERR "** Cannot save parameters to configure.options: $!\n"; + print STDERR "** Cannot save parameters to configure.options: $!\n"; } else { - print OUTFILE "$config_string\n"; - close(OUTFILE); + print OUTFILE "$config_string\n"; + close(OUTFILE); } # This is where 'vmd_LINUXAMD64' or 'vmd_SOLARIS2' gets created @@ -423,7 +424,7 @@ $config_progname = "vmd_${config_arch}"; # Tcl and Python expects shared libraries to be named like this. if ($config_shared) { - $config_progname = "vmd.so"; + $config_progname = "vmd.so"; } @@ -445,7 +446,7 @@ $def_title="ON"; $def_imageviewer="display %s"; # program version number -$progversion="1.9.4a55"; +$progversion="1.9.4a57"; # text prompt string $promptstring="vmd > "; @@ -510,15 +511,19 @@ $arch_cc = "cc"; $arch_ccpp = "CC"; $arch_nvcc = "/usr/local/cuda/bin/nvcc"; $arch_nvccflags = "-lineinfo --ptxas-options=-v " . - "-gencode arch=compute_52,code=sm_52 " . - "-gencode arch=compute_60,code=compute_60 " . - "-gencode arch=compute_60,code=sm_60 " . - "-gencode arch=compute_70,code=compute_70 " . - "-gencode arch=compute_70,code=sm_70 " . - "-gencode arch=compute_75,code=sm_75 " . - "-gencode arch=compute_80,code=sm_80 " . - "-gencode arch=compute_86,code=sm_86 " . - "--ftz=true "; + "-gencode arch=compute_50,code=compute_50 " . + "-gencode arch=compute_50,code=sm_50 " . + "-gencode arch=compute_52,code=sm_52 " . + "-gencode arch=compute_60,code=compute_60 " . + "-gencode arch=compute_60,code=sm_60 " . + "-gencode arch=compute_70,code=compute_70 " . + "-gencode arch=compute_70,code=sm_70 " . + "-gencode arch=compute_75,code=sm_75 " . + "-gencode arch=compute_80,code=compute_80 " . + "-gencode arch=compute_80,code=sm_80 " . + "-gencode arch=compute_86,code=sm_86 " . + "-gencode arch=compute_89,code=sm_89 " . + "--ftz=true "; # "-gencode arch=compute_75,code=sm_75 " . $arch_gcc = "gcc"; $arch_gccpp = "g++"; @@ -544,7 +549,7 @@ $arch_depend_flag = ""; # used for "make depend" DO NOT SET IT HERE! $arch_no_math_float = <<'EOM'; -D"expf=exp" -D"logf=log" -D"sqrtf=sqrt" -D"cosf=cos" -D"sinf=sin" -D"fabsf=fabs" -D"acosf=acos" EOM - ; + ; # get rid of the trailing newline chop($arch_no_math_float); @@ -560,19 +565,19 @@ $plugin_defines = ""; @plugin_cu = (); @plugin_ccpp = (); @plugin_h = ('plugin.h', - 'molfile_plugin.h'); + 'molfile_plugin.h'); @plugin_extra = (); if ($config_staticplugin) { - $molfile_dir = "$plugin_dir/$config_arch/molfile"; - $plugin_include .= " -I$molfile_dir"; - $plugin_library .= " -L$molfile_dir"; - $plugin_libs .= " -lmolfile_plugin"; - $plugin_defines .= " -DVMDSTATICPLUGINS"; - @plugin_cc = (); - @plugin_cu = (); - @plugin_ccpp = (); - push (@plugin_h, 'libmolfile_plugin.h'); + $molfile_dir = "$plugin_dir/$config_arch/molfile"; + $plugin_include .= " -I$molfile_dir"; + $plugin_library .= " -L$molfile_dir"; + $plugin_libs .= " -lmolfile_plugin"; + $plugin_defines .= " -DVMDSTATICPLUGINS"; + @plugin_cc = (); + @plugin_cu = (); + @plugin_ccpp = (); + push (@plugin_h, 'libmolfile_plugin.h'); } @@ -587,9 +592,9 @@ $vulkan_defines = "-DVMDOPENGL"; @vulkan_cc = (); @vulkan_cu = (); @vulkan_ccpp = ('VulkanDisplayDevice.C', - 'VulkanRenderer.C'); + 'VulkanRenderer.C'); @vulkan_h = ('VulkanDisplayDevice.h', - 'VulkanRenderer.h'); + 'VulkanRenderer.h'); @vulkan_extra = (); @@ -603,25 +608,25 @@ $opengl_dep_dir = ""; $opengl_dep_include = ""; $opengl_dep_library = ""; if ($config_opengl_dispatch) { - # version of OpenGL libs that can do dispatch, allowing use of - # EGL for window management, but full GL or GLES etc for drawing - # as appropriate - $opengl_dep_libs = "-lOpenGL"; + # version of OpenGL libs that can do dispatch, allowing use of + # EGL for window management, but full GL or GLES etc for drawing + # as appropriate + $opengl_dep_libs = "-lOpenGL"; } else { - #$opengl_dep_libs = "-lGL -lGLU"; - $opengl_dep_libs = "-lGL"; + #$opengl_dep_libs = "-lGL -lGLU"; + $opengl_dep_libs = "-lGL"; } $opengl_dep_defines = ""; @opengl_dep_cc = (); @opengl_dep_cu = (); @opengl_dep_ccpp = ('OpenGLExtensions.C', - 'OpenGLRenderer.C', - 'OpenGLShader.C', - 'OpenGLCache.C'); + 'OpenGLRenderer.C', + 'OpenGLShader.C', + 'OpenGLCache.C'); @opengl_dep_h = ('OpenGLExtensions.h', - 'OpenGLRenderer.h', - 'OpenGLShader.h', - 'OpenGLCache.h'); + 'OpenGLRenderer.h', + 'OpenGLShader.h', + 'OpenGLCache.h'); @opengl_dep_extra = (); @@ -691,11 +696,11 @@ $sdl_dir = "$vmd_library_dir/sdl"; $sdl_include = "-I$sdl_dir/include"; $sdl_library = "-L$sdl_dir/lib_$config_arch"; if ($config_arch eq "MACOSX" || - $config_arch eq "MACOSXX86" || - $config_arch eq "MACOSXX86_64") { - $sdl_libs = "-lSDL -framework OpenGL -framework AGL"; + $config_arch eq "MACOSXX86" || + $config_arch eq "MACOSXX86_64") { + $sdl_libs = "-lSDL -framework OpenGL -framework AGL"; } else { - $sdl_libs = "-lGL -lSDL"; + $sdl_libs = "-lGL -lSDL"; } $sdl_defines = "-DVMDOPENGL -DVMDSDL"; @sdl_cc = (); @@ -711,13 +716,13 @@ $fltkopengl_dir = ""; $fltkopengl_include = ""; $fltkopengl_library = ""; if ($config_arch eq "MACOSX" || - $config_arch eq "MACOSXARM64" || - $config_arch eq "MACOSXX86" || - $config_arch eq "MACOSXX86_64") { - $fltkopengl_libs = "-lfltk_gl -framework OpenGL -framework AGL"; + $config_arch eq "MACOSXARM64" || + $config_arch eq "MACOSXX86" || + $config_arch eq "MACOSXX86_64") { + $fltkopengl_libs = "-lfltk_gl -framework OpenGL -framework AGL"; } else { # $fltkopengl_libs = "-lfltk_gl -lGL -lGLU"; - $fltkopengl_libs = "-lfltk_gl -lGL"; + $fltkopengl_libs = "-lfltk_gl -lGL"; } $fltkopengl_defines = "-DVMDOPENGL -DVMDFLTKOPENGL"; @fltkopengl_cc = (); @@ -736,34 +741,34 @@ $fltk_libs = "-lfltk -lX11"; #@fltk_cc = ('forms_ui.c'); @fltk_cu = (); @fltk_ccpp = ( 'ColorFltkMenu.C', - 'DisplayFltkMenu.C', - 'FileChooserFltkMenu.C', - 'GraphicsFltkMenu.C', - 'SelectionBuilder.C', - 'GeometryFltkMenu.C', - 'MaterialFltkMenu.C', - 'MolBrowser.C', - 'RenderFltkMenu.C', - 'SaveTrajectoryFltkMenu.C', - 'VMDFltkMenu.C', - 'MainFltkMenu.C', - 'ToolFltkMenu.C', - 'frame_selector.C'); + 'DisplayFltkMenu.C', + 'FileChooserFltkMenu.C', + 'GraphicsFltkMenu.C', + 'SelectionBuilder.C', + 'GeometryFltkMenu.C', + 'MaterialFltkMenu.C', + 'MolBrowser.C', + 'RenderFltkMenu.C', + 'SaveTrajectoryFltkMenu.C', + 'VMDFltkMenu.C', + 'MainFltkMenu.C', + 'ToolFltkMenu.C', + 'frame_selector.C'); @fltk_h = ('ColorFltkMenu.h', - 'DisplayFltkMenu.h', - 'FileChooserFltkMenu.h', - 'GeometryFltkMenu.h', - 'GraphicsFltkMenu.h', - 'GraphicsFltkReps.h', - 'SelectionBuilder.h', - 'MaterialFltkMenu.h', - 'MolBrowser.h', - 'RenderFltkMenu.h', - 'SaveTrajectoryFltkMenu.h', - 'VMDFltkMenu.h', - 'MainFltkMenu.h', - 'ToolFltkMenu.h', - 'frame_selector.h'); + 'DisplayFltkMenu.h', + 'FileChooserFltkMenu.h', + 'GeometryFltkMenu.h', + 'GraphicsFltkMenu.h', + 'GraphicsFltkReps.h', + 'SelectionBuilder.h', + 'MaterialFltkMenu.h', + 'MolBrowser.h', + 'RenderFltkMenu.h', + 'SaveTrajectoryFltkMenu.h', + 'VMDFltkMenu.h', + 'MainFltkMenu.h', + 'ToolFltkMenu.h', + 'frame_selector.h'); @fltk_extra = ('forms_ui.fd'); ################ Tcl / Tk @@ -782,7 +787,7 @@ $stock_tk_include_dir=$ENV{"TK_INCLUDE_DIR"} || "$vmd_library_dir/tk/include"; $stock_tk_library_dir=$ENV{"TK_LIBRARY_DIR"} || "$vmd_library_dir/tk/lib_$config_arch"; if ($config_tk && !$config_tcl) { - die "Error, Tk option requires Tcl\n"; + die "Error, Tk option requires Tcl\n"; } if ($config_tcl) { @@ -798,44 +803,44 @@ if ($config_tk) { $tcl_libs = "-ltk8.6 -lX11 " . $tcl_libs; } @tcl_cc = (); @tcl_cu = (); @tcl_ccpp = ('ColorInfo.C', - 'TclCommands.C', - 'TclFastPBC.C', - 'TclMDFF.C', - 'TclMeasure.C', - 'TclMolInfo.C', - 'TclTextInterp.C', - 'TclVec.C', - 'TclGraphics.C', - 'TclGraphLayout.C', - 'TclSegmentation.C', - 'TclVolMap.C', - 'TclVoltool.C', - 'cmd_animate.C', - 'cmd_collab.C', - 'cmd_color.C', - 'cmd_display.C', - 'cmd_imd.C', - 'cmd_label.C', - 'cmd_material.C', - 'cmd_menu.C', - 'cmd_mobile.C', - 'cmd_mol.C', - 'cmd_mouse.C', - 'cmd_parallel.C', - 'cmd_plugin.C', - 'cmd_profile.C', - 'cmd_render.C', - 'cmd_spaceball.C', - 'cmd_tool.C', - 'cmd_trans.C', - 'cmd_user.C', - 'cmd_util.C', - 'cmd_videostream.C', - 'cmd_vmdbench.C', - 'tcl_commands.C'); + 'TclCommands.C', + 'TclFastPBC.C', + 'TclMDFF.C', + 'TclMeasure.C', + 'TclMolInfo.C', + 'TclTextInterp.C', + 'TclVec.C', + 'TclGraphics.C', + 'TclGraphLayout.C', + 'TclSegmentation.C', + 'TclVolMap.C', + 'TclVoltool.C', + 'cmd_animate.C', + 'cmd_collab.C', + 'cmd_color.C', + 'cmd_display.C', + 'cmd_imd.C', + 'cmd_label.C', + 'cmd_material.C', + 'cmd_menu.C', + 'cmd_mobile.C', + 'cmd_mol.C', + 'cmd_mouse.C', + 'cmd_parallel.C', + 'cmd_plugin.C', + 'cmd_profile.C', + 'cmd_render.C', + 'cmd_spaceball.C', + 'cmd_tool.C', + 'cmd_trans.C', + 'cmd_user.C', + 'cmd_util.C', + 'cmd_videostream.C', + 'cmd_vmdbench.C', + 'tcl_commands.C'); @tcl_h = ('TclCommands.h', - 'TclTextInterp.h', - 'tcl_commands.h'); + 'TclTextInterp.h', + 'tcl_commands.h'); @tcl_extra = (); } # 'cmd_volgradient.C', @@ -852,9 +857,9 @@ if ($config_tcl) { # This redirects all console output to log all output to a tk # text windget (ideally tkcon) if it is available. if ($config_tkcon) { - $tcl_defines .= " -DVMDTKCON"; - push (@tk_cc, 'vmdconsole.c'); - push (@tk_h, 'vmdconsole.h'); + $tcl_defines .= " -DVMDTKCON"; + push (@tk_cc, 'vmdconsole.c'); + push (@tk_h, 'vmdconsole.h'); } @@ -863,17 +868,17 @@ if ($config_tkcon) { # This allows VMD to execute functions from the colvars module # http://colvars.github.io/ if ($config_colvars) { - if (!$config_tcl) { - die "Error, COLVARS option requires Tcl\n"; - } + if (!$config_tcl) { + die "Error, COLVARS option requires Tcl\n"; + } - our ( $colvars_defines ); - our ( @colvars_cc ); - our ( @colvars_cu ); - our ( @colvars_ccpp ); - our ( @colvars_h ); + our ( $colvars_defines ); + our ( @colvars_cc ); + our ( @colvars_cu ); + our ( @colvars_ccpp ); + our ( @colvars_h ); - require "./src/colvars_files.pl"; + require "./src/colvars_files.pl"; } @@ -887,30 +892,30 @@ $imd_defines = "-DVMDIMD"; @imd_cu = (); if ($config_pthreads) { @imd_ccpp = ('IMDMgr.C', - 'IMDSim.C', - 'IMDSimThread.C', - 'CmdIMD.C', - 'imd.C' - ); + 'IMDSim.C', + 'IMDSimThread.C', + 'CmdIMD.C', + 'imd.C' + ); @imd_h = ('imd.h', - 'IMDMgr.h', - 'IMDSim.h', - 'IMDSimThread.h', - 'CmdIMD.h' - ); + 'IMDMgr.h', + 'IMDSim.h', + 'IMDSimThread.h', + 'CmdIMD.h' + ); } else { @imd_ccpp = ('IMDMgr.C', - 'IMDSim.C', - 'IMDSimBlocking.C', - 'CmdIMD.C', - 'imd.C' - ); + 'IMDSim.C', + 'IMDSimBlocking.C', + 'CmdIMD.C', + 'imd.C' + ); @imd_h = ('imd.h', - 'IMDMgr.h', - 'IMDSim.h', - 'IMDSimBlocking.h', - 'CmdIMD.h' - ); + 'IMDMgr.h', + 'IMDSim.h', + 'IMDSimBlocking.h', + 'CmdIMD.h' + ); } @@ -922,11 +927,11 @@ $system_dir = ""; $system_include = "-I."; $system_library = ""; if ( $config_gcc ) { - ## Note: some old commercial versions of Unix require -ll for lex internals - ## now that we've been using flex for years, -ll should be moot. - $system_libs = "-lm"; + ## Note: some old commercial versions of Unix require -ll for lex internals + ## now that we've been using flex for years, -ll should be moot. + $system_libs = "-lm"; } else { - $system_libs = "-lm"; + $system_libs = "-lm"; } @system_cc = (); @system_cu = (); @@ -973,39 +978,39 @@ $cpudispatch_libs = ""; if ($config_arch eq "LINUXARM64" || $config_arch eq "MACOSXARM64") { - # ARM NEON - $cpudispatch_defines = "-DVMDCPUDISPATCH -DVMDUSENEON"; - @cpudispatch_ccpp_neon = ( - 'Orbital_NEON.C', - 'QuickSurf_NEON.C', - 'util_simd_NEON.C', - ); - - # ARM SVE -# XXX currently requires ARM HPC toolkit/compilers, -# not found within normal tools yet -# if ($config_arch eq "LINUXARM64") { -# @cpudispatch_ccpp_sve .= ( -# 'Orbital_SVE.C', -# ); -# } + # ARM NEON + $cpudispatch_defines = "-DVMDCPUDISPATCH -DVMDUSENEON"; + @cpudispatch_ccpp_neon = ( + 'Orbital_NEON.C', + 'QuickSurf_NEON.C', + 'util_simd_NEON.C', + ); + + # ARM SVE + if ($config_arch eq "LINUXARM64") { + @cpudispatch_ccpp_sve = ( + 'Orbital_SVE.C', + 'util_simd_SVE.C', + ); + } + } elsif ($config_arch eq "LINUXAMD64" || $config_arch eq "WIN64" || $config_arch eq "MACOSXX86_64") { - # Intel x86, AVX, AVX2, AVX-512 - $cpudispatch_defines = "-DVMDCPUDISPATCH -DVMDUSEAVX -DVMDUSEAVX2 -DVMDUSEAVX512"; - @cpudispatch_ccpp_avx = ( - 'util_simd_AVX.C', - ); - @cpudispatch_ccpp_avx2 = ( - 'Orbital_AVX2.C', - 'QuickSurf_AVX2.C', - 'util_simd_AVX2.C', - ); - @cpudispatch_ccpp_avx512 = ( - 'Orbital_AVX512.C', - ); - @cpudispatch_ccpp_avx512er = ( - 'Orbital_AVX512ER.C', - ); + # Intel x86, AVX, AVX2, AVX-512 + $cpudispatch_defines = "-DVMDCPUDISPATCH -DVMDUSEAVX -DVMDUSEAVX2 -DVMDUSEAVX512"; + @cpudispatch_ccpp_avx = ( + 'util_simd_AVX.C', + ); + @cpudispatch_ccpp_avx2 = ( + 'Orbital_AVX2.C', + 'QuickSurf_AVX2.C', + 'util_simd_AVX2.C', + ); + @cpudispatch_ccpp_avx512 = ( + 'Orbital_AVX512.C', + ); + @cpudispatch_ccpp_avx512er = ( + 'Orbital_AVX512ER.C', + ); } @@ -1021,28 +1026,28 @@ $cuda_library = "-L$cuda_dir/lib64"; $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart_static -lrt"; @cuda_cc = (); @cuda_cu = ('msmpot_cuda.cu', - 'msmpot_cuda_latcut.cu', - 'msmpot_cuda_shortrng.cu', - 'CUDABench.cu', - 'CUDAClearDevice.cu', - 'CUDADispCmds.cu', - 'CUDAFastPBC.cu', - 'CUDAGaussianBlur.cu', - 'CUDAMarchingCubes.cu', - 'CUDAMDFF.cu', - 'CUDAMeasureRDF.cu', - 'CUDAMeasureQCP.cu', - 'CUDAWrapNVML.cu', - 'CUDAOrbital.cu', - 'CUDAParPrefixOps.cu', - 'CUDAQuickSurf.cu', - 'CUDASegmentation.cu', - 'CUDASpatialSearch.cu', - 'CUDASort.cu', - 'CUDAUtil.cu', - 'CUDAVolCPotential.cu', - 'CUDAVolMapCreateILS.cu', - 'CUDAWatershed.cu'); + 'msmpot_cuda_latcut.cu', + 'msmpot_cuda_shortrng.cu', + 'CUDABench.cu', + 'CUDAClearDevice.cu', + 'CUDADispCmds.cu', + 'CUDAFastPBC.cu', + 'CUDAGaussianBlur.cu', + 'CUDAMarchingCubes.cu', + 'CUDAMDFF.cu', + 'CUDAMeasureRDF.cu', + 'CUDAMeasureQCP.cu', + 'CUDAWrapNVML.cu', + 'CUDAOrbital.cu', + 'CUDAParPrefixOps.cu', + 'CUDAQuickSurf.cu', + 'CUDASegmentation.cu', + 'CUDASpatialSearch.cu', + 'CUDASort.cu', + 'CUDAUtil.cu', + 'CUDAVolCPotential.cu', + 'CUDAVolMapCreateILS.cu', + 'CUDAWatershed.cu'); @cuda_ccpp = (); @cuda_h = ('CUDAKernels.h'); @cuda_extra = (); @@ -1062,8 +1067,8 @@ $opencl_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lOpenCL"; @opencl_cc = (); @opencl_cu = (); @opencl_ccpp = ('OpenCLUtils.C', - 'OpenCLOrbital.C', - 'OpenCLVolCPotential.C'); + 'OpenCLOrbital.C', + 'OpenCLVolCPotential.C'); @opencl_h = ('OpenCLKernels.h'); @opencl_extra = (); @@ -1149,42 +1154,42 @@ $nvtx_libs = ""; # CUDA >= 10 have NVTX V3, no -lnvToolsExt # OPTIONAL COMPONENT: Khronos ANARI acclerated sci-vis rendering support # This may be commented out if not required. if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - $libanari_defines = "-DVMDLIBANARI "; # XXX batch RT only at present + $libanari_defines = "-DVMDLIBANARI "; # XXX batch RT only at present } else { - if ($config_opengl) { - $libanari_defines = "-DVMDLIBANARI -DVMDANARI_INTERACTIVE_OPENGL"; - } else { - $libanari_defines = "-DVMDLIBANARI "; - } + if ($config_opengl) { + $libanari_defines = "-DVMDLIBANARI -DVMDANARI_INTERACTIVE_OPENGL"; + } else { + $libanari_defines = "-DVMDLIBANARI "; + } } if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - $libanari_dir = "/Users/johns/vmd/lib/anari-0.0"; - $libanari_include = "-I$libanari_dir/include -I$libanari_dir/anari/include "; - $libanari_library = "-L$libanari_dir/lib64 "; - $libanari_libs = "-lanari "; + $libanari_dir = "/Users/johns/vmd/lib/anari-0.0"; + $libanari_include = "-I$libanari_dir/include -I$libanari_dir/anari/include "; + $libanari_library = "-L$libanari_dir/lib64 "; + $libanari_libs = "-lanari "; } else { - $libanari_dir = "/usr/local/anari-0.0"; - $libanari_include = "-I$libanari_dir/include -I$libanari_dir/anari/include "; - $libanari_library = "-L$libanari_dir/lib "; - $libanari_libs = "-lanari "; + $libanari_dir = "/usr/local/anari-1.0"; + $libanari_include = "-I$libanari_dir/include -I$libanari_dir/anari/include "; + $libanari_library = "-L$libanari_dir/lib64 "; + $libanari_libs = "-lanari "; } # ANARI, OptiX, and OSPRay renderers use the Tachyon glwin code, # so we have to make sure we don't build/link it twice if ($config_liboptix) { - @libanari_cc = (); + @libanari_cc = (); } else { - @libanari_cc = ('glwin.c'); + @libanari_cc = ('glwin.c'); } @libanari_cu = (); @libanari_ptx = (); @libanari_ccpp = ('ANARIDisplayDevice.C', - 'ANARIRenderer.C' - ); + 'ANARIRenderer.C' + ); @libanari_h = ('ANARIDisplayDevice.h', - 'ANARIRenderer.h', - ); + 'ANARIRenderer.h', + ); ################ LIBGELATO @@ -1200,17 +1205,17 @@ $libgelato_libs = "-lgelato"; @libgelato_cc = (); @libgelato_cu = (); @libgelato_ccpp = ('LibGelatoDisplayDevice.C' - ); + ); @libgelato_h = ('LibGelatoDisplayDevice.h', - ); + ); ################ LIBOPTIX # OPTIONAL COMPONENT: Built-in NVIDIA OptiX rendering support # This may be commented out if not required. if ($config_opengl) { - $liboptix_defines = "-DVMDLIBOPTIX -DVMDOPTIX_INTERACTIVE_OPENGL -DVMDOPTIXRTRT"; + $liboptix_defines = "-DVMDLIBOPTIX -DVMDOPTIX_INTERACTIVE_OPENGL -DVMDOPTIXRTRT"; } else { - $liboptix_defines = "-DVMDLIBOPTIX "; + $liboptix_defines = "-DVMDLIBOPTIX "; } # Standard builds @@ -1252,109 +1257,109 @@ $liboptix_include = "-I$liboptix_dir/include -I$cuda_dir/include"; $liboptix_library = "-L$liboptix_dir/lib64"; $liboptix_libs = "-loptixu -loptix"; if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - @liboptix_cc = (); # XXX batch RT only at present + @liboptix_cc = (); # XXX batch RT only at present } else { - @liboptix_cc = ('glwin.c'); + @liboptix_cc = ('glwin.c'); } @liboptix_cu = (); @liboptix_ptx = ('OptiXShaders.ptx', - ); + ); @liboptix_ccpp = ('OptiXDisplayDevice.C', - 'OptiXRenderer.C' - ); + 'OptiXRenderer.C' + ); @liboptix_h = ('OptiXDisplayDevice.h', - 'OptiXRenderer.h', - ); + 'OptiXRenderer.h', + ); ################ LIBOSPRAY # OPTIONAL COMPONENT: Built-in Intel OSPRay 1.x rendering support # This may be commented out if not required. if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - $libospray_defines = "-DVMDLIBOSPRAY "; # XXX batch RT only at present + $libospray_defines = "-DVMDLIBOSPRAY "; # XXX batch RT only at present } else { - if ($config_opengl) { - $libospray_defines = "-DVMDLIBOSPRAY -DVMDOSPRAY_INTERACTIVE_OPENGL"; - } else { - $libospray_defines = "-DVMDLIBOSPRAY "; - } + if ($config_opengl) { + $libospray_defines = "-DVMDLIBOSPRAY -DVMDOSPRAY_INTERACTIVE_OPENGL"; + } else { + $libospray_defines = "-DVMDLIBOSPRAY "; + } } if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - $libospray_dir = "/Users/johns/vmd/lib/ospray-1.8.5.x86_64.macosx"; - $libospray_include = "-I$libospray_dir/include -I$libospray_dir/ospray/include "; - $libospray_library = "-L$libospray_dir/lib "; - $libospray_libs = "-lospray -lospray_common -lembree3.3 -ltbb -ltbbmalloc "; + $libospray_dir = "/Users/johns/vmd/lib/ospray-1.8.5.x86_64.macosx"; + $libospray_include = "-I$libospray_dir/include -I$libospray_dir/ospray/include "; + $libospray_library = "-L$libospray_dir/lib "; + $libospray_libs = "-lospray -lospray_common -lembree3.3 -ltbb -ltbbmalloc "; } else { # $libospray_dir = "/usr/local/ospray-1.7.0.x86_64.linux"; - $libospray_dir = "/usr/local/ospray-1.8.5.x86_64.linux"; - $libospray_include = "-I$libospray_dir/include -I$libospray_dir/ospray/include "; - $libospray_library = "-L$libospray_dir/lib "; - $libospray_libs = "-lospray -lospray_common -lembree -ltbb -ltbbmalloc "; + $libospray_dir = "/usr/local/ospray-1.8.5.x86_64.linux"; + $libospray_include = "-I$libospray_dir/include -I$libospray_dir/ospray/include "; + $libospray_library = "-L$libospray_dir/lib "; + $libospray_libs = "-lospray -lospray_common -lembree -ltbb -ltbbmalloc "; } # Both OptiX and OSPRay renderers use the Tachyon glwin code, # so we have to make sure we don't build/link it twice if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - @libospray_cc = (); # XXX batch RT only at present + @libospray_cc = (); # XXX batch RT only at present } else { - if ($config_liboptix) { - @libospray_cc = (); - } else { - @libospray_cc = ('glwin.c'); - } + if ($config_liboptix) { + @libospray_cc = (); + } else { + @libospray_cc = ('glwin.c'); + } } @libospray_cu = (); @libospray_ptx = (); @libospray_ccpp = ('OSPRayDisplayDevice.C', - 'OSPRayRenderer.C' - ); + 'OSPRayRenderer.C' + ); @libospray_h = ('OSPRayDisplayDevice.h', - 'OSPRayRenderer.h', - ); + 'OSPRayRenderer.h', + ); ################ LIBOSPRAY2 # OPTIONAL COMPONENT: Built-in Intel OSPRay 2.x rendering support # This may be commented out if not required. if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - $libospray2_defines = "-DVMDLIBOSPRAY "; # XXX batch RT only at present + $libospray2_defines = "-DVMDLIBOSPRAY "; # XXX batch RT only at present } else { - if ($config_opengl) { - $libospray2_defines = "-DVMDLIBOSPRAY2 -DVMDOSPRAY_INTERACTIVE_OPENGL"; - } else { - $libospray2_defines = "-DVMDLIBOSPRAY2 "; - } + if ($config_opengl) { + $libospray2_defines = "-DVMDLIBOSPRAY2 -DVMDOSPRAY_INTERACTIVE_OPENGL"; + } else { + $libospray2_defines = "-DVMDLIBOSPRAY2 "; + } } if ($config_arch eq "MACOSXARM64" || $config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - $libospray2_dir = "/Users/johns/vmd/lib/ospray-2.5.0.x86_64.macosx"; - $libospray2_include = "-I$libospray2_dir/include -I$libospray2_dir/ospray/include "; - $libospray2_library = "-L$libospray2_dir/lib "; - $libospray2_libs = "-lospray -lospcommon -lembree3.3 -ltbb -ltbbmalloc "; + $libospray2_dir = "/Users/johns/vmd/lib/ospray-2.8.0.x86_64.macosx"; + $libospray2_include = "-I$libospray2_dir/include -I$libospray2_dir/ospray/include "; + $libospray2_library = "-L$libospray2_dir/lib "; + $libospray2_libs = "-lospray -lospcommon -lembree3.3 -ltbb -ltbbmalloc "; } else { - $libospray2_dir = "/usr/local/ospray-2.5.0.x86_64.linux"; - $libospray2_include = "-I$libospray2_dir/include -I$libospray2_dir/ospray/include "; - $libospray2_library = "-L$libospray2_dir/lib "; - $libospray2_libs = "-lospray -lospcommon -lembree3 -ltbb -ltbbmalloc "; + $libospray2_dir = "/usr/local/ospray-2.8.0.x86_64.linux"; + $libospray2_include = "-I$libospray2_dir/include -I$libospray2_dir/ospray/include "; + $libospray2_library = "-L$libospray2_dir/lib "; + $libospray2_libs = "-lospray -lospcommon -lembree3 -ltbb -ltbbmalloc "; } # Both OptiX and OSPRay renderers use the Tachyon glwin code, # so we have to make sure we don't build/link it twice if ($config_liboptix) { - @libospray2_cc = (); + @libospray2_cc = (); } else { - @libospray2_cc = ('glwin.c'); + @libospray2_cc = ('glwin.c'); } @libospray2_cu = (); @libospray2_ptx = (); @libospray2_ccpp = ('OSPRay2DisplayDevice.C', - 'OSPRay2Renderer.C' - ); + 'OSPRay2Renderer.C' + ); @libospray2_h = ('OSPRay2DisplayDevice.h', - 'OSPRay2Renderer.h', - ); + 'OSPRay2Renderer.h', + ); ################ LIBTACHYON @@ -1368,19 +1373,19 @@ $libtachyon_libs = "-ltachyon"; @libtachyon_cc = (); @libtachyon_cu = (); @libtachyon_ccpp = ('LibTachyonDisplayDevice.C' - ); + ); @libtachyon_h = ('LibTachyonDisplayDevice.h', - ); + ); ################ LIBPNG # OPTIONAL COMPONENT: PNG image I/O # This may be commented out if not required. if ( $config_libpng && !$config_zlib) { - die "LIBPNG option requires ZLIB!"; + die "LIBPNG option requires ZLIB!"; } $libpng_defines = "-DVMDLIBPNG"; $libpng_dir = "/usr/include/libpng"; -$libpng_include = "-I$libpng_dir/include"; +$libpng_include = "-I$libpng_dir"; $libpng_library = "-L$libpng_dir/lib_$config_arch"; $libpng_libs = "-lpng16"; @libpng_cc = (); @@ -1499,13 +1504,13 @@ $vrpn_libs = "-lvrpn -lquat"; @vrpn_cc = (); @vrpn_cu = (); @vrpn_ccpp = ('P_VRPNTracker.C', - 'P_VRPNButtons.C', - 'P_VRPNFeedback.C', - 'P_RotateTool.C'); + 'P_VRPNButtons.C', + 'P_VRPNFeedback.C', + 'P_RotateTool.C'); @vrpn_h = ('P_VRPNTracker.h', - 'P_VRPNButtons.h', - 'P_VRPNFeedback.h', - 'P_RotateTool.h'); + 'P_VRPNButtons.h', + 'P_VRPNFeedback.h', + 'P_RotateTool.h'); @vrpn_extra = (); ####################### @@ -1515,7 +1520,7 @@ $vrpn_libs = "-lvrpn -lquat"; # result in unique CAVE objects being used in the program. ####################### if ( $config_cave && !$config_opengl) { - die "CAVE option requires OPENGL!"; + die "CAVE option requires OPENGL!"; } $cave_defines = "-DVMDCAVE"; $cave_dir = "$vmd_library_dir/cave"; @@ -1525,17 +1530,17 @@ $cave_libs = "-lcave"; @cave_cc = (); @cave_cu = (); @cave_ccpp = ('CaveDisplayDevice.C', - 'CaveScene.C', - 'CaveRoutines.C', - 'P_CaveTracker.C', - 'P_CaveButtons.C' - ); + 'CaveScene.C', + 'CaveRoutines.C', + 'P_CaveTracker.C', + 'P_CaveButtons.C' + ); @cave_h = ('CaveDisplayDevice.h', - 'CaveRoutines.h', - 'CaveScene.h', - 'P_CaveTracker.h', - 'P_CaveButtons.h' - ); + 'CaveRoutines.h', + 'CaveScene.h', + 'P_CaveTracker.h', + 'P_CaveButtons.h' + ); @cave_extra = (); @@ -1546,7 +1551,7 @@ $cave_libs = "-lcave"; # result in unique FreeVR objects being used in the program. ####################### if ( $config_freevr && !$config_opengl) { - die "FREEVR option requires OPENGL!"; + die "FREEVR option requires OPENGL!"; } $freevr_defines = "-DVMDFREEVR"; $freevr_dir = "$vmd_library_dir/freevr"; @@ -1558,37 +1563,37 @@ $freevr_library = "-L$freevr_library_dir"; # choose which library to link against if (($config_arch eq "LINUX") || ($config_arch eq "LINUXAMD64")) { - if ($config_pthreads) { - if ($config_lp64 || ($config_arch eq "LINUXAMD64")) { - $freevr_libs = "-lfreevr_64 -lXi"; - } else { - $freevr_libs = "-lfreevr_32 -lXi"; - } - } else { - if ($config_lp64 || ($config_arch eq "LINUXAMD64")) { - $freevr_libs = "-lfreevr_64 -lXi"; - } else { - $freevr_libs = "-lfreevr_32 -lXi"; - } - } + if ($config_pthreads) { + if ($config_lp64 || ($config_arch eq "LINUXAMD64")) { + $freevr_libs = "-lfreevr_64 -lXi"; + } else { + $freevr_libs = "-lfreevr_32 -lXi"; + } + } else { + if ($config_lp64 || ($config_arch eq "LINUXAMD64")) { + $freevr_libs = "-lfreevr_64 -lXi"; + } else { + $freevr_libs = "-lfreevr_32 -lXi"; + } + } } else { - $freevr_libs = "-lfreevr -lXi"; + $freevr_libs = "-lfreevr -lXi"; } @freevr_cc = (); @freevr_cu = (); @freevr_ccpp = ('FreeVRDisplayDevice.C', - 'FreeVRScene.C', - 'FreeVRRoutines.C', - 'P_FreeVRTracker.C', - 'P_FreeVRButtons.C' - ); + 'FreeVRScene.C', + 'FreeVRRoutines.C', + 'P_FreeVRTracker.C', + 'P_FreeVRButtons.C' + ); @freevr_h = ('FreeVRDisplayDevice.h', - 'FreeVRRoutines.h', - 'FreeVRScene.h', - 'P_FreeVRTracker.h', - 'P_FreeVRButtons.h' - ); + 'FreeVRRoutines.h', + 'FreeVRScene.h', + 'P_FreeVRTracker.h', + 'P_FreeVRButtons.h' + ); @freevr_extra = (); @@ -1665,55 +1670,55 @@ $pthreads_libs = "-lpthread"; # location of Python library and include file. # If left blank, standard system directories will be searched. if ($ENV{_CONDA_ROOT}) { - $conda_root=$ENV{"_CONDA_ROOT"}; - print "using _CONDA_ROOT for Python 3.7: $conda_root\n"; - $stock_python_include_dir=$ENV{"PYTHON_INCLUDE_DIR"} || "$conda_root/include/python3.7m"; - $stock_python_library_dir=$ENV{"PYTHON_LIBRARY_DIR"} || "$conda_root/lib/python3.7/config-3.7m-x86_64-linux-gnu"; - $stock_numpy_include_dir=$ENV{"NUMPY_INCLUDE_DIR"} || "$conda_root/lib/python3.7/site-packages/numpy/core/include/numpy"; - $stock_numpy_library_dir=$ENV{"NUMPY_LIBRARY_DIR"} || "$conda_root/lib/python-3.7/site-packages/numpy/core/include"; - $python_libs = "-fno-lto -lpython3.7m -lpthread"; + $conda_root=$ENV{"_CONDA_ROOT"}; + print "using _CONDA_ROOT for Python 3.7: $conda_root\n"; + $stock_python_include_dir=$ENV{"PYTHON_INCLUDE_DIR"} || "$conda_root/include/python3.7m"; + $stock_python_library_dir=$ENV{"PYTHON_LIBRARY_DIR"} || "$conda_root/lib/python3.7/config-3.7m-x86_64-linux-gnu"; + $stock_numpy_include_dir=$ENV{"NUMPY_INCLUDE_DIR"} || "$conda_root/lib/python3.7/site-packages/numpy/core/include/numpy"; + $stock_numpy_library_dir=$ENV{"NUMPY_LIBRARY_DIR"} || "$conda_root/lib/python-3.7/site-packages/numpy/core/include"; + $python_libs = "-fno-lto -lpython3.7m -lpthread"; } else { # $stock_python_include_dir=$ENV{"PYTHON_INCLUDE_DIR"} || "/usr/local/include"; # $stock_python_library_dir=$ENV{"PYTHON_LIBRARY_DIR"} || "/usr/local/lib"; - $stock_python_include_dir=$ENV{"PYTHON_INCLUDE_DIR"} || "$vmd_library_dir/python/lib_$config_arch/include/python2.5"; - $stock_python_library_dir=$ENV{"PYTHON_LIBRARY_DIR"} || "$vmd_library_dir/python/lib_$config_arch/lib/python2.5/config"; + $stock_python_include_dir=$ENV{"PYTHON_INCLUDE_DIR"} || "$vmd_library_dir/python/lib_$config_arch/include/python2.5"; + $stock_python_library_dir=$ENV{"PYTHON_LIBRARY_DIR"} || "$vmd_library_dir/python/lib_$config_arch/lib/python2.5/config"; # $stock_numpy_include_dir=$ENV{"NUMPY_INCLUDE_DIR"} || "/usr/local/include"; # $stock_numpy_library_dir=$ENV{"NUMPY_LIBRARY_DIR"} || "/usr/local/lib"; - $stock_numpy_include_dir=$ENV{"NUMPY_INCLUDE_DIR"} || "$vmd_library_dir/numpy/lib_$config_arch/include"; - $stock_numpy_library_dir=$ENV{"NUMPY_LIBRARY_DIR"} || "$vmd_library_dir/python/lib_$config_arch/lib/python2.5/site-packages/numpy/core/include"; - $python_libs = "-lpython3.8 -lpthread"; + $stock_numpy_include_dir=$ENV{"NUMPY_INCLUDE_DIR"} || "$vmd_library_dir/numpy/lib_$config_arch/include"; + $stock_numpy_library_dir=$ENV{"NUMPY_LIBRARY_DIR"} || "$vmd_library_dir/python/lib_$config_arch/lib/python2.5/site-packages/numpy/core/include"; + $python_libs = "-lpython3.10 -lpthread"; } $python_defines = "-DVMDPYTHON"; $python_include = "-I$stock_python_include_dir -I$stock_numpy_include_dir -I$stock_numpy_library_dir"; $python_library = "-L$stock_python_library_dir"; @python_h = ('PythonTextInterp.h', - 'VMDTkinterMenu.h', - 'py_commands.h', - 'py_molecule.h'); + 'VMDTkinterMenu.h', + 'py_commands.h', + 'py_molecule.h'); @python_ccpp = ('PythonTextInterp.C', - 'VMDTkinterMenu.C', - 'py_animate.C', - 'py_atomsel.C', - 'py_selection.C', - 'py_axes.C', - 'py_color.C', - 'py_commands.C', - 'py_display.C', - 'py_graphics.C', - 'py_imd.C', - 'py_label.C', - 'py_material.C', - 'py_measure.C', - 'py_menu.C', - 'py_molecule.C', - 'py_molrep.C', - 'py_mouse.C', - 'py_render.C', - 'py_topo.C', - 'py_trans.C', - 'py_vmd.C'); + 'VMDTkinterMenu.C', + 'py_animate.C', + 'py_atomsel.C', + 'py_selection.C', + 'py_axes.C', + 'py_color.C', + 'py_commands.C', + 'py_display.C', + 'py_graphics.C', + 'py_imd.C', + 'py_label.C', + 'py_material.C', + 'py_measure.C', + 'py_menu.C', + 'py_molecule.C', + 'py_molrep.C', + 'py_mouse.C', + 'py_render.C', + 'py_topo.C', + 'py_trans.C', + 'py_vmd.C'); ################### @@ -1722,7 +1727,7 @@ $python_library = "-L$stock_python_library_dir"; # Numeric requires Python if ( $config_numeric && !$config_python) { - die "NUMPY option requires PYTHON!"; + die "NUMPY option requires PYTHON!"; } $numeric_defines = "-DVMDNUMPY"; $numeric_include = ""; @@ -1738,7 +1743,7 @@ $numeric_libs = ""; # allow passing build flags from rpmbuild $rpm_optflags = ""; if ( $config_rpm ) { - $rpm_optflags = "$ENV{RPM_OPT_FLAGS}"; + $rpm_optflags = "$ENV{RPM_OPT_FLAGS}"; } ################### standard sources @@ -1747,342 +1752,343 @@ $vmd_include = "$tcl_include"; $vmd_library = "$tcl_library"; $vmd_libs = "$tcl_libs"; -@vmd_cc = ('hash.c', - 'inthash.c', - 'intstack.c', - 'ptrstack.c', - 'msmpot.c', - 'msmpot_compute.c', - 'msmpot_cubic.c', - 'msmpot_setup.c', - 'vmdsock.c', - 'vmddlopen.c', - 'vmdfsinfo.c', - 'pcre.c', - 'fitrms.c', - @tcl_cc, - @tk_cc); +@vmd_cc = ('c_compiler.c', + 'hash.c', + 'inthash.c', + 'intstack.c', + 'ptrstack.c', + 'msmpot.c', + 'msmpot_compute.c', + 'msmpot_cubic.c', + 'msmpot_setup.c', + 'vmdsock.c', + 'vmddlopen.c', + 'vmdfsinfo.c', + 'pcre.c', + 'fitrms.c', + @tcl_cc, + @tk_cc); @vmd_ccpp = ( - 'androidvmdstart.C', - 'Animation.C', - 'ArtDisplayDevice.C', - 'AtomColor.C', - 'AtomParser.C', - 'AtomLexer.C', - 'AtomRep.C', - 'AtomSel.C', - 'Axes.C', - 'BaseMolecule.C', - 'Benchmark.C', - 'BondSearch.C', - 'CmdAnimate.C', - 'CmdColor.C', - 'CmdDisplay.C', - 'CmdLabel.C', - 'CmdMaterial.C', - 'CmdMenu.C', - 'CmdMol.C', - 'CmdRender.C', - 'CmdTrans.C', - 'CommandQueue.C', - 'CoorPluginData.C', - 'CUDAAccel.C', - 'DisplayDevice.C', - 'Displayable.C', - 'DisplayRocker.C', - 'DispCmds.C', - 'DrawMolecule.C', - 'DrawMolItem.C', - 'DrawMolItem2.C', - 'DrawMolItemRibbons.C', - 'DrawMolItemMSMS.C', - 'DrawMolItemNanoShaper.C', - 'DrawMolItemRings.C', - 'DrawMolItemOrbital.C', - 'DrawMolItemQuickSurf.C', - 'DrawMolItemSurface.C', - 'DrawMolItemVolume.C', - 'DrawForce.C', - 'DrawRingsUtils.C', - 'FastPBC.C', - 'FileRenderList.C', - 'FileRenderer.C', - 'FPS.C', - 'GaussianBlur.C', - 'GelatoDisplayDevice.C', - 'GeometryAngle.C', - 'GeometryAtom.C', - 'GeometryBond.C', - 'GeometryDihedral.C', - 'GeometryList.C', - 'GeometryMol.C', - 'GeometrySpring.C', - 'GraphLayout.C', - 'Hershey.C', - 'HMDMgr.C', - 'Inform.C', - 'ImageIO.C', - 'Isosurface.C', - 'JRegex.C', - 'JString.C', - 'macosxvmdstart.C', - 'MaterialList.C', - 'Matrix4.C', - 'MayaDisplayDevice.C', - 'MDFF.C', - 'Measure.C', - 'MeasureCluster.C', - 'MeasurePBC.C', - 'MeasureRDF.C', - 'MeasureQCP.C', - 'MeasureSurface.C', - 'MeasureSymmetry.C', - 'MeasureVolInterior.C', - 'MobileInterface.C', - 'MobileButtons.C', - 'MobileTracker.C', - 'Molecule.C', - 'MoleculeList.C', - 'MoleculeGraphics.C', - 'MolFilePlugin.C', - 'Mouse.C', - 'MSMSInterface.C', - 'NanoShaperInterface.C', - 'Orbital.C', - 'OrbitalJIT.C', - 'PeriodicTable.C', - 'P_JoystickTool.C', - 'P_TugTool.C', - 'P_GrabTool.C', - 'P_PrintTool.C', - 'P_PinchTool.C', - 'P_UIVR.C', - 'P_Buttons.C', - 'P_Tracker.C', - 'P_Tool.C', - 'P_CmdTool.C', - 'P_SensorConfig.C', - 'ParseTree.C', - 'PickList.C', - 'PickModeAddBond.C', - 'PickModeCenter.C', - 'PickModeForce.C', - 'PickModeList.C', - 'PickModeMolLabel.C', - 'PickModeMove.C', - 'PickModeUser.C', - 'PlainTextInterp.C', - 'PluginMgr.C', - 'POV3DisplayDevice.C', - 'PSDisplayDevice.C', - 'QMData.C', - 'QMTimestep.C', - 'QuickSurf.C', - 'RadianceDisplayDevice.C', - 'RayShadeDisplayDevice.C', - 'R3dDisplayDevice.C', - 'RenderManDisplayDevice.C', - 'Scene.C', - 'ScaleSpaceFilter.C', - 'Segmentation.C', - 'SnapshotDisplayDevice.C', - 'Spaceball.C', - 'SpaceballButtons.C', - 'SpaceballTracker.C', - 'SpatialSearch.C', - 'SpringTool.C', - 'Stage.C', - 'STLDisplayDevice.C', - 'Stride.C', - 'Surf.C', - 'SymbolTable.C', - 'TachyonDisplayDevice.C', - 'Timestep.C', - 'UIObject.C', - 'UIText.C', - 'VideoStream.C', - 'VMDApp.C', - 'VMDCollab.C', - 'VMDDir.C', - 'VMDDisplayList.C', - 'VMDMenu.C', - 'VMDQuat.C', - 'VMDTitle.C', - 'VolCPotential.C', - 'VolMapCreate.C', - 'VolMapCreateILS.C', - 'VolumetricData.C', - 'VolumeTexture.C', - 'Voltool.C', - 'VrmlDisplayDevice.C', - 'Vrml2DisplayDevice.C', - 'Watershed.C', - 'WavefrontDisplayDevice.C', - 'WKFThreads.C', - 'WKFUtils.C', - 'utilities.C', - 'util_simd.C', - 'vmd.C', - 'vmdmain.C', - 'X3DDisplayDevice.C', - @tcl_ccpp, - @tk_ccpp - ); + 'androidvmdstart.C', + 'Animation.C', + 'ArtDisplayDevice.C', + 'AtomColor.C', + 'AtomParser.C', + 'AtomLexer.C', + 'AtomRep.C', + 'AtomSel.C', + 'Axes.C', + 'BaseMolecule.C', + 'Benchmark.C', + 'BondSearch.C', + 'CmdAnimate.C', + 'CmdColor.C', + 'CmdDisplay.C', + 'CmdLabel.C', + 'CmdMaterial.C', + 'CmdMenu.C', + 'CmdMol.C', + 'CmdRender.C', + 'CmdTrans.C', + 'CommandQueue.C', + 'CoorPluginData.C', + 'CUDAAccel.C', + 'DisplayDevice.C', + 'Displayable.C', + 'DisplayRocker.C', + 'DispCmds.C', + 'DrawMolecule.C', + 'DrawMolItem.C', + 'DrawMolItem2.C', + 'DrawMolItemRibbons.C', + 'DrawMolItemMSMS.C', + 'DrawMolItemNanoShaper.C', + 'DrawMolItemRings.C', + 'DrawMolItemOrbital.C', + 'DrawMolItemQuickSurf.C', + 'DrawMolItemSurface.C', + 'DrawMolItemVolume.C', + 'DrawForce.C', + 'DrawRingsUtils.C', + 'FastPBC.C', + 'FileRenderList.C', + 'FileRenderer.C', + 'FPS.C', + 'GaussianBlur.C', + 'GelatoDisplayDevice.C', + 'GeometryAngle.C', + 'GeometryAtom.C', + 'GeometryBond.C', + 'GeometryDihedral.C', + 'GeometryList.C', + 'GeometryMol.C', + 'GeometrySpring.C', + 'GraphLayout.C', + 'Hershey.C', + 'HMDMgr.C', + 'Inform.C', + 'ImageIO.C', + 'Isosurface.C', + 'JRegex.C', + 'JString.C', + 'macosxvmdstart.C', + 'MaterialList.C', + 'Matrix4.C', + 'MayaDisplayDevice.C', + 'MDFF.C', + 'Measure.C', + 'MeasureCluster.C', + 'MeasurePBC.C', + 'MeasureRDF.C', + 'MeasureQCP.C', + 'MeasureSurface.C', + 'MeasureSymmetry.C', + 'MeasureVolInterior.C', + 'MobileInterface.C', + 'MobileButtons.C', + 'MobileTracker.C', + 'Molecule.C', + 'MoleculeList.C', + 'MoleculeGraphics.C', + 'MolFilePlugin.C', + 'Mouse.C', + 'MSMSInterface.C', + 'NanoShaperInterface.C', + 'Orbital.C', + 'OrbitalJIT.C', + 'PeriodicTable.C', + 'P_JoystickTool.C', + 'P_TugTool.C', + 'P_GrabTool.C', + 'P_PrintTool.C', + 'P_PinchTool.C', + 'P_UIVR.C', + 'P_Buttons.C', + 'P_Tracker.C', + 'P_Tool.C', + 'P_CmdTool.C', + 'P_SensorConfig.C', + 'ParseTree.C', + 'PickList.C', + 'PickModeAddBond.C', + 'PickModeCenter.C', + 'PickModeForce.C', + 'PickModeList.C', + 'PickModeMolLabel.C', + 'PickModeMove.C', + 'PickModeUser.C', + 'PlainTextInterp.C', + 'PluginMgr.C', + 'POV3DisplayDevice.C', + 'PSDisplayDevice.C', + 'QMData.C', + 'QMTimestep.C', + 'QuickSurf.C', + 'RadianceDisplayDevice.C', + 'RayShadeDisplayDevice.C', + 'R3dDisplayDevice.C', + 'RenderManDisplayDevice.C', + 'Scene.C', + 'ScaleSpaceFilter.C', + 'Segmentation.C', + 'SnapshotDisplayDevice.C', + 'Spaceball.C', + 'SpaceballButtons.C', + 'SpaceballTracker.C', + 'SpatialSearch.C', + 'SpringTool.C', + 'Stage.C', + 'STLDisplayDevice.C', + 'Stride.C', + 'Surf.C', + 'SymbolTable.C', + 'TachyonDisplayDevice.C', + 'Timestep.C', + 'UIObject.C', + 'UIText.C', + 'VideoStream.C', + 'VMDApp.C', + 'VMDCollab.C', + 'VMDDir.C', + 'VMDDisplayList.C', + 'VMDMenu.C', + 'VMDQuat.C', + 'VMDTitle.C', + 'VolCPotential.C', + 'VolMapCreate.C', + 'VolMapCreateILS.C', + 'VolumetricData.C', + 'VolumeTexture.C', + 'Voltool.C', + 'VrmlDisplayDevice.C', + 'Vrml2DisplayDevice.C', + 'Watershed.C', + 'WavefrontDisplayDevice.C', + 'WKFThreads.C', + 'WKFUtils.C', + 'utilities.C', + 'util_simd.C', + 'vmd.C', + 'vmdmain.C', + 'X3DDisplayDevice.C', + @tcl_ccpp, + @tk_ccpp + ); ################### standard headers # VMD header files @vmd_h = ( - 'Animation.h', - 'ArtDisplayDevice.h', - 'Atom.h', - 'AtomColor.h', - 'AtomParser.h', - 'AtomRep.h', - 'AtomSel.h', - 'Axes.h', - 'BaseMolecule.h', - 'Benchmark.h', - 'BondSearch.h', - 'CmdAnimate.h', - 'CmdColor.h', - 'CmdDisplay.h', - 'CmdLabel.h', - 'CmdMaterial.h', - 'CmdMenu.h', - 'CmdMol.h', - 'CmdRender.h', - 'CmdTrans.h', - 'Command.h', - 'CommandQueue.h', - 'CoorData.h', - 'CUDAAccel.h', - 'CoorPluginData.h', - 'DepthSortObj.h', - 'DispCmds.h', - 'DisplayDevice.h', - 'Displayable.h', - 'DisplayRocker.h', - 'DrawMolecule.h', - 'DrawMolItem.h', - 'DrawMolItemSolventPoints.data', - 'DrawForce.h', - 'GelatoDisplayDevice.h', - 'FPS.h', - 'FileRenderList.h', - 'FileRenderer.h', - 'Fragment.h', - 'GeometryAngle.h', - 'GeometryAtom.h', - 'GeometryBond.h', - 'GeometryDihedral.h', - 'GeometryList.h', - 'GeometryMol.h', - 'GeometrySpring.h', - 'Hershey.h', - 'Inform.h', - 'ImageIO.h', - 'Isosurface.h', - 'JRegex.h', - 'JString.h', - 'macosxvmdstart.h', - 'MaterialList.h', - 'Matrix4.h', - 'MayaDisplayDevice.h', - 'Measure.h', - 'MeasureSymmetry.h', - 'Molecule.h', - 'MoleculeGraphics.h', - 'MoleculeList.h', - 'MolFilePlugin.h', - 'Mouse.h', - 'MSMSInterface.h', - 'NameList.h', - 'NanoShaperInterface.h', - 'PeriodicTable.h', - 'Orbital.h', - 'P_JoystickTool.h', - 'P_TugTool.h', - 'P_PinchToo.h', - 'P_GrabTool.h', - 'P_PrintTool.h', - 'P_Feedback.h', - 'P_UIVR.h', - 'P_Buttons.h', - 'P_Tracker.h', - 'P_CmdTool.h', - 'P_SensorConfig.h', - 'P_Tool.h', - 'ParseTree.h', - 'PickList.h', - 'PickMode.h', - 'PickModeAddBond.h', - 'PickModeCenter.h', - 'PickModeForce.h', - 'PickModeList.h', - 'PickModeMolLabel.h', - 'PickModeMove.h', - 'Pickable.h', - 'PlainTextInterp.h', - 'PluginMgr.h', - 'PointerTool.h', - 'POV3DisplayDevice.h', - 'PSDisplayDevice.h', - 'QMData.h', - 'QMTimestep.h', - 'RadianceDisplayDevice.h', - 'RayShadeDisplayDevice.h', - 'R3dDisplayDevice.h', - 'ResizeArray.h', - 'RenderManDisplayDevice.h', - 'Residue.h', - 'Scene.h', - 'SnapshotDisplayDevice.h', - 'SortableArray.h', - 'Spaceball.h', - 'SpaceballButtons.h', - 'SpaceballTracker.h', - 'SpatialSearch.h', - 'SpringTool.h', - 'Stack.h', - 'Stage.h', - 'STLDisplayDevice.h', - 'Stride.h', - 'Surf.h', - 'SymbolTable.h', - 'TachyonDisplayDevice.h', - 'TextEvent.h', - 'TextInterp.h', - 'Timestep.h', - 'UIObject.h', - 'UIText.h', - 'VideoStream.h', - 'VMDApp.h', - 'VMDDir.h', - 'VMDDisplayList.h', - 'VMDMenu.h', - 'VMDQuat.h', - 'VMDTitle.h', - 'VolCPotential.h', - 'VolMapCreate.h', - 'VolumetricData.h', - 'VolumeTexture.h', - 'Voltool.h', - 'VrmlDisplayDevice.h', - 'Vrml2DisplayDevice.h', - 'Watershed.h', - 'WavefrontDisplayDevice.h', - 'X3DDisplayDevice.h', - 'utilities.h', - 'pcre.h', - 'pcreinternal.h', - 'pcretables.h', - 'vmdsock.h', - 'fitrms.h', - @tcl_h, - @tk_h - ); + 'Animation.h', + 'ArtDisplayDevice.h', + 'Atom.h', + 'AtomColor.h', + 'AtomParser.h', + 'AtomRep.h', + 'AtomSel.h', + 'Axes.h', + 'BaseMolecule.h', + 'Benchmark.h', + 'BondSearch.h', + 'CmdAnimate.h', + 'CmdColor.h', + 'CmdDisplay.h', + 'CmdLabel.h', + 'CmdMaterial.h', + 'CmdMenu.h', + 'CmdMol.h', + 'CmdRender.h', + 'CmdTrans.h', + 'Command.h', + 'CommandQueue.h', + 'CoorData.h', + 'CUDAAccel.h', + 'CoorPluginData.h', + 'DepthSortObj.h', + 'DispCmds.h', + 'DisplayDevice.h', + 'Displayable.h', + 'DisplayRocker.h', + 'DrawMolecule.h', + 'DrawMolItem.h', + 'DrawMolItemSolventPoints.data', + 'DrawForce.h', + 'GelatoDisplayDevice.h', + 'FPS.h', + 'FileRenderList.h', + 'FileRenderer.h', + 'Fragment.h', + 'GeometryAngle.h', + 'GeometryAtom.h', + 'GeometryBond.h', + 'GeometryDihedral.h', + 'GeometryList.h', + 'GeometryMol.h', + 'GeometrySpring.h', + 'Hershey.h', + 'Inform.h', + 'ImageIO.h', + 'Isosurface.h', + 'JRegex.h', + 'JString.h', + 'macosxvmdstart.h', + 'MaterialList.h', + 'Matrix4.h', + 'MayaDisplayDevice.h', + 'Measure.h', + 'MeasureSymmetry.h', + 'Molecule.h', + 'MoleculeGraphics.h', + 'MoleculeList.h', + 'MolFilePlugin.h', + 'Mouse.h', + 'MSMSInterface.h', + 'NameList.h', + 'NanoShaperInterface.h', + 'PeriodicTable.h', + 'Orbital.h', + 'P_JoystickTool.h', + 'P_TugTool.h', + 'P_PinchToo.h', + 'P_GrabTool.h', + 'P_PrintTool.h', + 'P_Feedback.h', + 'P_UIVR.h', + 'P_Buttons.h', + 'P_Tracker.h', + 'P_CmdTool.h', + 'P_SensorConfig.h', + 'P_Tool.h', + 'ParseTree.h', + 'PickList.h', + 'PickMode.h', + 'PickModeAddBond.h', + 'PickModeCenter.h', + 'PickModeForce.h', + 'PickModeList.h', + 'PickModeMolLabel.h', + 'PickModeMove.h', + 'Pickable.h', + 'PlainTextInterp.h', + 'PluginMgr.h', + 'PointerTool.h', + 'POV3DisplayDevice.h', + 'PSDisplayDevice.h', + 'QMData.h', + 'QMTimestep.h', + 'RadianceDisplayDevice.h', + 'RayShadeDisplayDevice.h', + 'R3dDisplayDevice.h', + 'ResizeArray.h', + 'RenderManDisplayDevice.h', + 'Residue.h', + 'Scene.h', + 'SnapshotDisplayDevice.h', + 'SortableArray.h', + 'Spaceball.h', + 'SpaceballButtons.h', + 'SpaceballTracker.h', + 'SpatialSearch.h', + 'SpringTool.h', + 'Stack.h', + 'Stage.h', + 'STLDisplayDevice.h', + 'Stride.h', + 'Surf.h', + 'SymbolTable.h', + 'TachyonDisplayDevice.h', + 'TextEvent.h', + 'TextInterp.h', + 'Timestep.h', + 'UIObject.h', + 'UIText.h', + 'VideoStream.h', + 'VMDApp.h', + 'VMDDir.h', + 'VMDDisplayList.h', + 'VMDMenu.h', + 'VMDQuat.h', + 'VMDTitle.h', + 'VolCPotential.h', + 'VolMapCreate.h', + 'VolumetricData.h', + 'VolumeTexture.h', + 'Voltool.h', + 'VrmlDisplayDevice.h', + 'Vrml2DisplayDevice.h', + 'Watershed.h', + 'WavefrontDisplayDevice.h', + 'X3DDisplayDevice.h', + 'utilities.h', + 'pcre.h', + 'pcreinternal.h', + 'pcretables.h', + 'vmdsock.h', + 'fitrms.h', + @tcl_h, + @tk_h + ); # VMD yacc and lex files. There is only one of each, # and they are used for the atom selection parser @@ -2097,18 +2103,18 @@ $vmd_libs = "$tcl_libs"; # directory. @vmd_data = ('.vmdsensors', '.vmdrc'); - + $vmd_bin_csh = "vmd.csh"; $vmd_bin_sh = "vmd.sh"; @vmd_extra = (@tcl_extra); @vmd_other_exe = ( - "$vmd_library_dir/stride/stride_$config_arch", - "$vmd_library_dir/surf/surf_$config_arch", - "$vmd_library_dir/tachyon/tachyon_$config_arch" - ); - + "$vmd_library_dir/stride/stride_$config_arch", + "$vmd_library_dir/surf/surf_$config_arch", + "$vmd_library_dir/tachyon/tachyon_$config_arch" + ); + @vmd_other_names = ("stride_$config_arch"); @vmd_main_dir_files = ('Announcement', 'FEEDBACK', 'LICENSE', @@ -2117,84 +2123,84 @@ $vmd_bin_sh = "vmd.sh"; ################## ARCHITECTURE-SPECIFIC VERSIONS ############### if ($config_arch eq "AIX6_64") { - if ($config_lp64) { - # -64 64-bit mode - print "Configured for -64 64-bit build.\n"; - $arch_cc = "xlc"; - $arch_ccpp = "xlC"; - $arch_copts = "-O -q64 -qarch=com -qtune=pwr5"; - $arch_opt_flag = "-O -q64 -qarch=com -qtune=pwr5"; - $arch_cppopts = "-D_H_ACCESS=1"; - } + if ($config_lp64) { + # -64 64-bit mode + print "Configured for -64 64-bit build.\n"; + $arch_cc = "xlc"; + $arch_ccpp = "xlC"; + $arch_copts = "-O -q64 -qarch=com -qtune=pwr5"; + $arch_opt_flag = "-O -q64 -qarch=com -qtune=pwr5"; + $arch_cppopts = "-D_H_ACCESS=1"; + } - $opengl_dep_libs = "-lGL -lX11 -lXext"; - $mesa_libs = "-lMesaGL -lXext"; + $opengl_dep_libs = "-lGL -lX11 -lXext"; + $mesa_libs = "-lMesaGL -lXext"; - $arch_lex = "flex"; # has problems with the vendor lex... + $arch_lex = "flex"; # has problems with the vendor lex... - # needed for plugins - $arch_lopts = "-ldl"; + # needed for plugins + $arch_lopts = "-ldl"; - # On systems that have libperfstat installed, use perfstat APIs for - # memory queries - $arch_cppopts .= " -DAIXUSEPERFSTAT"; - $arch_lopts .= " -lperfstat"; + # On systems that have libperfstat installed, use perfstat APIs for + # memory queries + $arch_cppopts .= " -DAIXUSEPERFSTAT"; + $arch_lopts .= " -lperfstat"; } if ($config_arch eq "ANDROIDARMV7A") { - $pthreads_libs = ""; - ## - ## Android NDK notes: - ## NDK version r8b works well on RHEL 4.x hosts, but r8d has glibc issues - ## NDK version r9 seems to work fine on RHEL 5.5 hosts, but has not yet - ## been fully tested with VMD. - ## - $androidbins = "/Projects/collaboratory/kvandivo/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/"; - $androidincs = "-DANDROID -I/home/kvandivo/Proj/android-ndk-r8b/sources/cxx-stl/stlport/stlport -I/home/kvandivo/Proj/android-ndk-r8b/sources/cxx-stl/system/include -I/home/kvandivo/Proj/android-ndk-r8b/platforms/android-14/arch-arm/usr/include"; - $androidlibs = "-L/home/kvandivo/Proj/android-ndk-r8b/platforms/android-14/arch-arm/usr/lib -L/home/kvandivo/Proj/android-ndk-r8b/sources/cxx-stl/stlport/libs/armeabi-v7a/"; - $androidsysroot = "--sysroot=/home/kvandivo/Proj/android-ndk-r8b/platforms/android-14/arch-arm"; - $androidabi = "arm-linux-androideabi-"; - $arch_cc = $androidbins . $androidabi . "gcc"; - $arch_ccpp = $androidbins . $androidabi . "g++"; - $arch_copts = "-Wall -Wno-unknown-pragmas -Wno-psabi -MMD -MP -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv7-a -msoft-float -mfpu=vfp -fno-exceptions -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstac"; - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -Wno-psabi -MMD -MP -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv7-a -msoft-float -mfpu=vfp -fno-exceptions -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstac"; - $arch_copts = $androidincs; - $arch_cppopts = $androidincs; - $arch_lex = "flex"; - - # needed for plugins - $arch_lopts = "-Wl,-soname,libjniWrapper.so -shared " . $androidsysroot . " -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now " . $androidlibs . " -lstlport_static -lc -lm"; + $pthreads_libs = ""; + ## + ## Android NDK notes: + ## NDK version r8b works well on RHEL 4.x hosts, but r8d has glibc issues + ## NDK version r9 seems to work fine on RHEL 5.5 hosts, but has not yet + ## been fully tested with VMD. + ## + $androidbins = "/Projects/collaboratory/kvandivo/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/"; + $androidincs = "-DANDROID -I/home/kvandivo/Proj/android-ndk-r8b/sources/cxx-stl/stlport/stlport -I/home/kvandivo/Proj/android-ndk-r8b/sources/cxx-stl/system/include -I/home/kvandivo/Proj/android-ndk-r8b/platforms/android-14/arch-arm/usr/include"; + $androidlibs = "-L/home/kvandivo/Proj/android-ndk-r8b/platforms/android-14/arch-arm/usr/lib -L/home/kvandivo/Proj/android-ndk-r8b/sources/cxx-stl/stlport/libs/armeabi-v7a/"; + $androidsysroot = "--sysroot=/home/kvandivo/Proj/android-ndk-r8b/platforms/android-14/arch-arm"; + $androidabi = "arm-linux-androideabi-"; + $arch_cc = $androidbins . $androidabi . "gcc"; + $arch_ccpp = $androidbins . $androidabi . "g++"; + $arch_copts = "-Wall -Wno-unknown-pragmas -Wno-psabi -MMD -MP -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv7-a -msoft-float -mfpu=vfp -fno-exceptions -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstac"; + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -Wno-psabi -MMD -MP -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv7-a -msoft-float -mfpu=vfp -fno-exceptions -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstac"; + $arch_copts = $androidincs; + $arch_cppopts = $androidincs; + $arch_lex = "flex"; + + # needed for plugins + $arch_lopts = "-Wl,-soname,libjniWrapper.so -shared " . $androidsysroot . " -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now " . $androidlibs . " -lstlport_static -lc -lm"; } # IBM Blue Gene/Q if ($config_arch eq "BLUEGENEQ") { - # -64 64-bit mode - print "Configured for -64 64-bit build.\n"; - $arch_cc = "mpixlc "; - $arch_ccpp = "mpixlcxx_r "; - $arch_copts = "-O -q64 -qarch=qp -qtune=qp $ENV{CPPFLAGS}"; - $arch_opt_flag = "-O -q64 -qarch=qp -qtune=qp $ENV{CPPFLAGS}"; + # -64 64-bit mode + print "Configured for -64 64-bit build.\n"; + $arch_cc = "mpixlc "; + $arch_ccpp = "mpixlcxx_r "; + $arch_copts = "-O -q64 -qarch=qp -qtune=qp $ENV{CPPFLAGS}"; + $arch_opt_flag = "-O -q64 -qarch=qp -qtune=qp $ENV{CPPFLAGS}"; # $arch_cppopts = "-D_H_ACCESS=1" . $arch_no_math_float; - $arch_cppopts = "-D_H_ACCESS=1 "; + $arch_cppopts = "-D_H_ACCESS=1 "; - $opengl_dep_libs = "-lGL -lX11 -lXext"; - $mesa_libs = "-lMesaGL -lXext"; + $opengl_dep_libs = "-lGL -lX11 -lXext"; + $mesa_libs = "-lMesaGL -lXext"; - $arch_lex = "flex"; # has problems with the vendor lex... + $arch_lex = "flex"; # has problems with the vendor lex... - # needed for plugins - $arch_lopts = "-ldl $ENV{LDFLAGS}"; + # needed for plugins + $arch_lopts = "-ldl $ENV{LDFLAGS}"; - if ($config_mpi) { - $arch_copts .= " -DUSE_MPI_IN_PLACE"; - $arch_opt_flag .= " -DUSE_MPI_IN_PLACE"; - $mpi_libs = ""; - } + if ($config_mpi) { + $arch_copts .= " -DUSE_MPI_IN_PLACE"; + $arch_opt_flag .= " -DUSE_MPI_IN_PLACE"; + $mpi_libs = ""; + } - # On systems that have libperfstat installed, use perfstat APIs for - # memory queries + # On systems that have libperfstat installed, use perfstat APIs for + # memory queries # $arch_cppopts .= " -DAIXUSEPERFSTAT"; # $arch_lopts .= " -lperfstat"; } @@ -2202,50 +2208,50 @@ if ($config_arch eq "BLUEGENEQ") { if ($config_arch eq "BLUEWATERS" || - $config_arch eq "CRAY_XC" || $config_arch eq "CRAY_XK") { - # -64 64-bit mode - print "Configured for -64 64-bit build.\n"; - - if ($config_icc) { - # for compiling with Intel C/C++: - $arch_cc = "cc"; - $arch_ccpp = "CC"; - $arch_copts = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; - - if ($config_static) { - # link everything statically (this won't work due to libGL issues) - $arch_lopts = "-static"; - } else { - # link the Intel compiler libraries statically, and use the GCC C++ libs - # $arch_lopts = "-static-libcxa -cxxlib-gcc"; - # dynamically link all libs, and use Intel libs where possible - $arch_lopts = "-rdynamic "; - } - $arch_lopts .= "-static-intel "; - } else { - # Assume GCC - $arch_cc = "cc"; - $arch_ccpp = "CC"; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O6 -ffast-math"; - $arch_opt_flag = "-m64 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O6 -ffast-math"; - } - - if ($config_mpi) { - $arch_copts .= " -DUSE_MPI_IN_PLACE"; - $arch_opt_flag .= " -DUSE_MPI_IN_PLACE"; - $mpi_libs = ""; - } - - $opengl_dep_libs = "-lGL -lX11 -lXext"; - $mesa_libs = "-lMesaGL -lXext"; - - $arch_lex = "flex"; # has problems with the vendor lex... - - # also needed for plugins - $system_libs .= " -ldl"; - - if ($config_cuda) { + $config_arch eq "CRAY_XC" || $config_arch eq "CRAY_XK") { + # -64 64-bit mode + print "Configured for -64 64-bit build.\n"; + + if ($config_icc) { + # for compiling with Intel C/C++: + $arch_cc = "cc"; + $arch_ccpp = "CC"; + $arch_copts = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; + + if ($config_static) { + # link everything statically (this won't work due to libGL issues) + $arch_lopts = "-static"; + } else { + # link the Intel compiler libraries statically, and use the GCC C++ libs + # $arch_lopts = "-static-libcxa -cxxlib-gcc"; + # dynamically link all libs, and use Intel libs where possible + $arch_lopts = "-rdynamic "; + } + $arch_lopts .= "-static-intel "; + } else { + # Assume GCC + $arch_cc = "cc"; + $arch_ccpp = "CC"; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O6 -ffast-math"; + $arch_opt_flag = "-m64 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O6 -ffast-math"; + } + + if ($config_mpi) { + $arch_copts .= " -DUSE_MPI_IN_PLACE"; + $arch_opt_flag .= " -DUSE_MPI_IN_PLACE"; + $mpi_libs = ""; + } + + $opengl_dep_libs = "-lGL -lX11 -lXext"; + $mesa_libs = "-lMesaGL -lXext"; + + $arch_lex = "flex"; # has problems with the vendor lex... + + # also needed for plugins + $system_libs .= " -ldl"; + + if ($config_cuda) { # $arch_nvcc = "/opt/nvidia/cudatoolkit/default/bin/nvcc"; # $cuda_library = "-L/opt/nvidia/cudatoolkit/default/lib64"; # @@ -2263,13 +2269,13 @@ if ($config_arch eq "BLUEWATERS" || # $arch_nvcc = "/opt/nvidia/cudatoolkit7.0/7.0.28-1.0502.10280.4.1/bin/nvcc"; # $cuda_library = "-L/opt/nvidia/cudatoolkit7.0/7.0.28-1.0502.10280.4.1/lib64"; - $arch_nvcc = "/opt/nvidia/cudatoolkit7.5/7.5.18-1.0502.10743.2.1/bin/nvcc"; - $cuda_library = "-L/opt/nvidia/cudatoolkit7.5/7.5.18-1.0502.10743.2.1/lib64"; + $arch_nvcc = "/opt/nvidia/cudatoolkit7.5/7.5.18-1.0502.10743.2.1/bin/nvcc"; + $cuda_library = "-L/opt/nvidia/cudatoolkit7.5/7.5.18-1.0502.10743.2.1/lib64"; - # Only generate code for SM 3.5 or higher on Cray machines - $arch_nvccflags = "--ptxas-options=-v " . - "-gencode arch=compute_35,code=sm_35 " . - "--ftz=true "; + # Only generate code for SM 3.5 or higher on Cray machines + $arch_nvccflags = "--ptxas-options=-v " . + "-gencode arch=compute_35,code=sm_35 " . + "--ftz=true "; # Note: CSCS 'dom' is now using CUDA 8.0 # $arch_nvcc = "/opt/nvidia/cudatoolkit8.0/8.0.34_2.2.5_g8ce7a9a-2.1/bin/nvcc"; @@ -2285,1101 +2291,1106 @@ if ($config_arch eq "BLUEWATERS" || # # Cray XC50 w/ CUDA 8.0 need "-lrt" now too... # $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart_static -lrt"; - $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; - } + $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; + } - # The OptiX toolkit version has to be compatible with the CUDA libs - # installed on the machine... We currently use OptiX 3.5.1 built against - # CUDA 5.5. - if ($config_liboptix) { - $liboptix_include = "-I$liboptix_dir/include -I$cuda_dir/include"; - $liboptix_library = "-L$liboptix_dir/lib64"; - } + # The OptiX toolkit version has to be compatible with the CUDA libs + # installed on the machine... We currently use OptiX 3.5.1 built against + # CUDA 5.5. + if ($config_liboptix) { + $liboptix_include = "-I$liboptix_dir/include -I$cuda_dir/include"; + $liboptix_library = "-L$liboptix_dir/lib64"; + } - # needed for OpenCL - $opencl_include = "-I/usr/include/CL/inc"; - $opencl_library = ""; - $opencl_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lOpenCL"; + # needed for OpenCL + $opencl_include = "-I/usr/include/CL/inc"; + $opencl_library = ""; + $opencl_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lOpenCL"; - if ($config_python) { - # this is to make python happy - $system_libs .= " -lutil"; - } - if ($config_shared) { - $arch_opt_flag .= " -fPIC"; - $arch_copts .= " -fPIC"; - $arch_nvccflags .= " -Xcompiler -fPIC"; - $arch_lopts = "-shared"; - $arch_cppopts .= " -DVMD_SHARED"; - } + if ($config_python) { + # this is to make python happy + $system_libs .= " -lutil"; + } + if ($config_shared) { + $arch_opt_flag .= " -fPIC"; + $arch_copts .= " -fPIC"; + $arch_nvccflags .= " -Xcompiler -fPIC"; + $arch_lopts = "-shared"; + $arch_cppopts .= " -DVMD_SHARED"; + } } if ($config_arch eq "FREEBSD") { - $def_imageviewer="display %s"; + $def_imageviewer="display %s"; - # XFree 4.0 Direct Rendering Interface and GLX - $opengl_dep_dir = "/usr/local"; + # XFree 4.0 Direct Rendering Interface and GLX + $opengl_dep_dir = "/usr/local"; # -DGLX_GLXEXT_LEGACY is required for patched OpenGLExtensions.C to compile. # See patched OpenGLExtensions.C for explanation. - $opengl_dep_include = "-DGLX_GLXEXT_LEGACY -I$opengl_dep_dir/include"; - $opengl_dep_library = "-L$opengl_dep_dir/lib -L/usr/local/lib"; - $opengl_dep_libs = "-lGL"; - - $arch_lex = "flex"; - $arch_yacc = "bison -b y -d "; # If standard yacc doesn't work - - $arch_cc = "gcc"; - $arch_ccpp = "g++"; - $arch_depend_flag = "-MM"; - $arch_shld = "g++ -shared"; - $arch_shlibname = "so"; - $arch_shcppopts = "-fPIC"; - $arch_shldopts = "-L/usr/local/lib"; - - $arch_opt_flag = "-m32 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O3"; - $arch_copts = "-m32 -Wall -Wno-unknown-pragmas -O3"; - - if ($config_static) { - $arch_lopts = "-static"; - $mesa_libs = "-lMesaGL -L/usr/local/lib -lXext -lX11"; - } else { - $arch_lopts = ""; - $mesa_libs = "-lGL -L/usr/local/lib -lXext -lX11"; - } - - if ($config_shared) { - $arch_lopts = "-shared"; - $arch_cppopts .= " -DVMD_SHARED"; - } - - # this is to make tcl happy, - # also needed for plugins - # $system_libs .= " -ldl"; + $opengl_dep_include = "-DGLX_GLXEXT_LEGACY -I$opengl_dep_dir/include"; + $opengl_dep_library = "-L$opengl_dep_dir/lib -L/usr/local/lib"; + $opengl_dep_libs = "-lGL"; + + $arch_lex = "flex"; + $arch_yacc = "bison -b y -d "; # If standard yacc doesn't work + + $arch_cc = "gcc"; + $arch_ccpp = "g++"; + $arch_depend_flag = "-MM"; + $arch_shld = "g++ -shared"; + $arch_shlibname = "so"; + $arch_shcppopts = "-fPIC"; + $arch_shldopts = "-L/usr/local/lib"; + + $arch_opt_flag = "-m32 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O3"; + $arch_copts = "-m32 -Wall -Wno-unknown-pragmas -O3"; + + if ($config_static) { + $arch_lopts = "-static"; + $mesa_libs = "-lMesaGL -L/usr/local/lib -lXext -lX11"; + } else { + $arch_lopts = ""; + $mesa_libs = "-lGL -L/usr/local/lib -lXext -lX11"; + } + + if ($config_shared) { + $arch_lopts = "-shared"; + $arch_cppopts .= " -DVMD_SHARED"; + } + + # this is to make tcl happy, + # also needed for plugins + # $system_libs .= " -ldl"; - if ($config_python) { - # this is to make python happy - $system_libs .= " -lutil"; - } + if ($config_python) { + # this is to make python happy + $system_libs .= " -lutil"; + } - # this is necessary for the embedded Python interpreter to dynamically - # load shared libraries. It increases the size of the binary by 200k. - $arch_lopts .= " -Xlinker -export-dynamic"; + # this is necessary for the embedded Python interpreter to dynamically + # load shared libraries. It increases the size of the binary by 200k. + $arch_lopts .= " -Xlinker -export-dynamic"; } if ($config_arch eq "FREEBSDAMD64") { - $def_imageviewer="display %s"; - if ($config_lp64) { - print "LP64 ABI is already the default on this platform.\n"; - } + $def_imageviewer="display %s"; + if ($config_lp64) { + print "LP64 ABI is already the default on this platform.\n"; + } - # XFree 4.0 Direct Rendering Interface and GLX - $opengl_dep_dir = "/usr/local"; + # XFree 4.0 Direct Rendering Interface and GLX + $opengl_dep_dir = "/usr/local"; # -DGLX_GLXEXT_LEGACY is required for patched OpenGLExtensions.C to compile. # See patched OpenGLExtensions.C for explanation. - $opengl_dep_include = "-DGLX_GLXEXT_LEGACY -I$opengl_dep_dir/include"; - $opengl_dep_library = "-L$opengl_dep_dir/lib -L/usr/local/lib"; - $opengl_dep_libs = "-lGL"; + $opengl_dep_include = "-DGLX_GLXEXT_LEGACY -I$opengl_dep_dir/include"; + $opengl_dep_library = "-L$opengl_dep_dir/lib -L/usr/local/lib"; + $opengl_dep_libs = "-lGL"; - $arch_lex = "flex"; - $arch_yacc = "bison -b y -d "; # If standard yacc doesn't work + $arch_lex = "flex"; + $arch_yacc = "bison -b y -d "; # If standard yacc doesn't work - $arch_cc = "gcc"; - $arch_ccpp = "g++"; - $arch_depend_flag = "-MM"; - $arch_shld = "ld -shared"; - $arch_shlibname = "so"; - $arch_shcppopts = "-fPIC"; - $arch_shldopts = "-L/usr/local/lib -L/usr/local/lib"; + $arch_cc = "gcc"; + $arch_ccpp = "g++"; + $arch_depend_flag = "-MM"; + $arch_shld = "ld -shared"; + $arch_shlibname = "so"; + $arch_shcppopts = "-fPIC"; + $arch_shldopts = "-L/usr/local/lib -L/usr/local/lib"; - $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; + $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; - if ($config_static) { - $arch_lopts = "-static"; - $mesa_libs = "-lMesaGL -L/usr/local/lib -lXext -lX11"; - } else { - $arch_lopts = ""; - $mesa_libs = "-lGL -L/usr/local/lib -lXext -lX11"; - } + if ($config_static) { + $arch_lopts = "-static"; + $mesa_libs = "-lMesaGL -L/usr/local/lib -lXext -lX11"; + } else { + $arch_lopts = ""; + $mesa_libs = "-lGL -L/usr/local/lib -lXext -lX11"; + } - if ($config_shared) { - $arch_lopts = "-shared"; - } + if ($config_shared) { + $arch_lopts = "-shared"; + } - # this is to make tcl happy, - # also needed for plugins - # $system_libs .= " -ldl"; + # this is to make tcl happy, + # also needed for plugins + # $system_libs .= " -ldl"; - if ($config_python) { - # this is to make python happy - $system_libs .= " -lutil"; - } + if ($config_python) { + # this is to make python happy + $system_libs .= " -lutil"; + } - # this is necessary for the embedded Python interpreter to dynamically - # load shared libraries. It increases the size of the binary by 200k. - $arch_lopts .= " -Xlinker -export-dynamic"; + # this is necessary for the embedded Python interpreter to dynamically + # load shared libraries. It increases the size of the binary by 200k. + $arch_lopts .= " -Xlinker -export-dynamic"; } if ($config_arch eq "LINUX") { - $def_imageviewer="display %s"; - if ($config_lp64) { - print "No LP64 ABI on this platform currently.\n"; - } - - $fltk_libs = "-lfltk -lX11 -lXft"; - - # XFree 4.0 Direct Rendering Interface and GLX - $opengl_dep_dir = "/usr/X11R6"; - $opengl_dep_include = "-I$opengl_dep_dir/include"; - $opengl_dep_library = "-L$opengl_dep_dir/lib"; - $opengl_dep_libs = "-lGL"; - # $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; - - if ($config_icc) { - # for compiling with Intel C/C++: + $def_imageviewer="display %s"; + if ($config_lp64) { + print "No LP64 ABI on this platform currently.\n"; + } + + $fltk_libs = "-lfltk -lX11 -lXft"; + + # XFree 4.0 Direct Rendering Interface and GLX + $opengl_dep_dir = "/usr/X11R6"; + $opengl_dep_include = "-I$opengl_dep_dir/include"; + $opengl_dep_library = "-L$opengl_dep_dir/lib"; + $opengl_dep_libs = "-lGL"; + # $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; + + if ($config_icc) { + # for compiling with Intel C/C++: # $arch_cc = "icc"; # $arch_ccpp = "icpc"; - # version supporting RHEL 4.x - $arch_cc = "/usr/local/encap/intel-cc-12.2011.2.137/bin/icc"; - $arch_ccpp = "/usr/local/encap/intel-cc-12.2011.2.137/bin/icpc"; - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m32 -msse2 -O3"; - $arch_depend_flag = "-MM"; - $arch_copts = "-Wall -Wno-unknown-pragmas -m32 -msse2 -O3"; - $arch_shlibname = "so"; - $arch_shcppopts = "-fPIC"; - $arch_shldopts = ""; - - if ($config_static) { - # link everything statically (this won't work due to libGL issues) - $arch_lopts = "-static"; - } else { - # link the Intel compiler libraries statically, and use the GCC C++ libs - # $arch_lopts = "-static-libcxa -cxxlib-gcc"; - # dynamically link all libs, and use Intel libs where possible - $arch_lopts = "-rdynamic "; - } - $arch_lopts .= "-i-static "; - } else { - # compling with GCC - $arch_cc = "gcc"; - $arch_ccpp = "g++"; - $arch_depend_flag = "-MM"; - $arch_shld = "g++ -shared"; - $arch_shlibname = "so"; - $arch_shcppopts = "-fPIC"; - $arch_shldopts = ""; - $arch_opt_flag = "-m32 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O3"; - $arch_copts = "-m32 -Wall -Wno-unknown-pragmas -O3"; - - if ($config_static) { - $arch_lopts = "-static"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; - } else { - $arch_lopts = ""; - # -rpath causes problems for people running Chromium.. - # $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; - $mesa_libs = "-lGL -L/usr/X11R6/lib -lXext -lX11"; - } - if ($config_shared) { - $arch_lopts = "-shared"; - } - } - - $arch_cppopts = ""; - if ($config_cuda) { - $arch_nvcc = "/usr/local/cuda-4.0/bin/nvcc"; - $arch_nvccflags = "--ptxas-options=-v " . - "-gencode arch=compute_13,code=sm_13 " . - "-gencode arch=compute_20,code=sm_20 " . - "-gencode arch=compute_20,code=compute_20 " . - "--ftz=true "; - $arch_nvccflags .= " --machine 32 -O3 -Xcompiler \"-m32\" $cuda_include"; - $cuda_library = "-L/usr/local/cuda-4.0/lib"; - $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart"; - } - # this is to make tcl happy - # also needed for plugins - $system_libs .= " -ldl"; - if ($config_shared) { - $arch_opt_flag .= " -fPIC"; - $arch_copts .= " -fPIC"; - $arch_nvccflags .= " -Xcompiler -fPIC"; - $arch_lopts = "-shared"; - $arch_cppopts .= " -DVMD_SHARED"; - } + # version supporting RHEL 4.x + $arch_cc = "/usr/local/encap/intel-cc-12.2011.2.137/bin/icc"; + $arch_ccpp = "/usr/local/encap/intel-cc-12.2011.2.137/bin/icpc"; + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m32 -msse2 -O3"; + $arch_depend_flag = "-MM"; + $arch_copts = "-Wall -Wno-unknown-pragmas -m32 -msse2 -O3"; + $arch_shlibname = "so"; + $arch_shcppopts = "-fPIC"; + $arch_shldopts = ""; + + if ($config_static) { + # link everything statically (this won't work due to libGL issues) + $arch_lopts = "-static"; + } else { + # link the Intel compiler libraries statically, and use the GCC C++ libs + # $arch_lopts = "-static-libcxa -cxxlib-gcc"; + # dynamically link all libs, and use Intel libs where possible + $arch_lopts = "-rdynamic "; + } + $arch_lopts .= "-i-static "; + } else { + # compling with GCC + $arch_cc = "gcc"; + $arch_ccpp = "g++"; + $arch_depend_flag = "-MM"; + $arch_shld = "g++ -shared"; + $arch_shlibname = "so"; + $arch_shcppopts = "-fPIC"; + $arch_shldopts = ""; + $arch_opt_flag = "-m32 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O3"; + $arch_copts = "-m32 -Wall -Wno-unknown-pragmas -O3"; + + if ($config_static) { + $arch_lopts = "-static"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; + } else { + $arch_lopts = ""; + # -rpath causes problems for people running Chromium.. + # $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; + $mesa_libs = "-lGL -L/usr/X11R6/lib -lXext -lX11"; + } + if ($config_shared) { + $arch_lopts = "-shared"; + } + } + + $arch_cppopts = ""; + if ($config_cuda) { + $arch_nvcc = "/usr/local/cuda-4.0/bin/nvcc"; + $arch_nvccflags = "--ptxas-options=-v " . + "-gencode arch=compute_13,code=sm_13 " . + "-gencode arch=compute_20,code=sm_20 " . + "-gencode arch=compute_20,code=compute_20 " . + "--ftz=true "; + $arch_nvccflags .= " --machine 32 -O3 -Xcompiler \"-m32\" $cuda_include"; + $cuda_library = "-L/usr/local/cuda-4.0/lib"; + $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart"; + } + # this is to make tcl happy + # also needed for plugins + $system_libs .= " -ldl"; + if ($config_shared) { + $arch_opt_flag .= " -fPIC"; + $arch_copts .= " -fPIC"; + $arch_nvccflags .= " -Xcompiler -fPIC"; + $arch_lopts = "-shared"; + $arch_cppopts .= " -DVMD_SHARED"; + } - if ($config_python) { - # this is to make python happy - $system_libs .= " -lutil"; - } + if ($config_python) { + # this is to make python happy + $system_libs .= " -lutil"; + } - # this is necessary for the embedded Python interpreter to dynamically - # load shared libraries. It increases the size of the binary by 200k. - $arch_lopts .= " -Xlinker -export-dynamic"; + # this is necessary for the embedded Python interpreter to dynamically + # load shared libraries. It increases the size of the binary by 200k. + $arch_lopts .= " -Xlinker -export-dynamic"; } if ($config_arch eq "LINUXAMD64") { - $def_imageviewer="display %s"; - if ($config_lp64) { - print "LP64 ABI is already the default on this platform.\n"; - } - - if ($config_icc) { - # for compiling with Intel C/C++: - $arch_cc = "icc"; - $arch_ccpp = "icpc"; - if ($config_avx512) { - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m64 -xMIC-AVX512 -O3"; - $arch_copts = "-Wall -Wno-unknown-pragmas -m64 -xMIC-AVX512 -O3"; - } else { - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; - $arch_copts = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; - } - $arch_depend_flag = "-MM"; - $arch_shlibname = "so"; - $arch_shcppopts = "-fPIC"; - $arch_shldopts = ""; - - if ($config_static) { - # link everything statically (this won't work due to libGL issues) - $arch_lopts = "-static"; - } else { - # link the Intel compiler libraries statically, and use the GCC C++ libs - # $arch_lopts = "-static-libcxa -cxxlib-gcc"; - # dynamically link all libs, and use Intel libs where possible - $arch_lopts = "-rdynamic "; - } - $arch_lopts .= "-static-intel "; - } elsif ($config_pgcc) { - # for compiling with Intel C/C++: - $arch_cc = "pgcc"; - $arch_ccpp = "pgc++"; - $arch_opt_flag = "-m64 "; - $arch_depend_flag = "-MM"; - $arch_copts = "-m64 "; - $arch_shlibname = "so"; - $arch_shcppopts = "-fPIC"; - $arch_shldopts = ""; - - if ($config_static) { - # link everything statically (this won't work due to libGL issues) - $arch_lopts = "-static"; - } else { - $arch_lopts = "-rdynamic "; - } - } elsif ($config_clang) { - $arch_cc = "clang"; - $arch_ccpp = "clang++"; - $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math "; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math "; - $arch_depend_flag = "-MM"; - } else { - # for compiling with g++: - $arch_cc = "gcc"; - $arch_ccpp = "g++"; - $arch_opt_flag = "-m64 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O6 -ffast-math"; - $arch_depend_flag = "-MM"; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O6 -ffast-math"; - - # so far only STATIC version tested - if ($config_static) { - $arch_lopts = "-static"; - } else { - $arch_lopts = "-rdynamic"; - } - } - - if ($config_cuda) { - $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; - $cuda_library = "-L/usr/local/cuda/lib64"; - } - - $arch_lex = "flex"; # has problems with vendor lex - - # added a test so that EGL support works for now, but these bits of - # override code probably date back to RHEL4.x or earlier, and - # they likely serve no useful purpose going forward. - if (!$config_opengl_dispatch) { - $opengl_dep_libs = "-L/usr/X11R6/lib64 -lGL -lX11"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib64 -lXext -lX11"; - } - - # this is to make tcl happy - # also needed for plugins - $system_libs .= " -ldl"; - - if ($config_python) { - # this is to make python happy - $system_libs .= " -lutil"; - } - if ($config_shared) { - $arch_opt_flag .= " -fPIC"; - $arch_copts .= " -fPIC"; - $arch_nvccflags .= " -Xcompiler -fPIC"; - $arch_lopts = "-shared"; - $arch_cppopts .= " -DVMD_SHARED"; - } + $def_imageviewer="display %s"; + if ($config_lp64) { + print "LP64 ABI is already the default on this platform.\n"; + } + + if ($config_icc) { + # for compiling with Intel C/C++: + $arch_cc = "icc"; + $arch_ccpp = "icpc"; + if ($config_avx512) { + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m64 -xMIC-AVX512 -O3"; + $arch_copts = "-Wall -Wno-unknown-pragmas -m64 -xMIC-AVX512 -O3"; + } else { + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; + $arch_copts = "-Wall -Wno-unknown-pragmas -m64 -msse2 -O3"; + } + + $arch_depend_flag = "-MM"; + $arch_shlibname = "so"; + $arch_shcppopts = "-fPIC"; + $arch_shldopts = ""; + + if ($config_static) { + # link everything statically (this won't work due to libGL issues) + $arch_lopts = "-static"; + } else { + # link the Intel compiler libraries statically, and use the GCC C++ libs + # $arch_lopts = "-static-libcxa -cxxlib-gcc"; + # dynamically link all libs, and use Intel libs where possible + $arch_lopts = "-rdynamic "; + } + $arch_lopts .= "-static-intel "; + } elsif ($config_pgcc) { + # for compiling with Intel C/C++: + $arch_cc = "pgcc"; + $arch_ccpp = "pgc++"; + $arch_opt_flag = "-m64 "; + $arch_depend_flag = "-MM"; + $arch_copts = "-m64 "; + $arch_shlibname = "so"; + $arch_shcppopts = "-fPIC"; + $arch_shldopts = ""; + + if ($config_static) { + # link everything statically (this won't work due to libGL issues) + $arch_lopts = "-static"; + } else { + $arch_lopts = "-rdynamic "; + } + } elsif ($config_clang) { + $arch_cc = "clang"; + $arch_ccpp = "clang++"; + $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math "; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math "; + $arch_depend_flag = "-MM"; + } else { + # for compiling with g++: + $arch_cc = "gcc"; + $arch_ccpp = "g++"; + $arch_opt_flag = "-m64 -fno-for-scope -Wno-deprecated -Wall -Wno-unknown-pragmas -O6 -ffast-math"; + $arch_depend_flag = "-MM"; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O6 -ffast-math"; + + # so far only STATIC version tested + if ($config_static) { + $arch_lopts = "-static"; + } else { + $arch_lopts = "-rdynamic"; + } + } + + if ($config_cxx11) { + $arch_opt_flag .= " -std=c++11" + } + + if ($config_cuda) { + $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; + $cuda_library = "-L/usr/local/cuda/lib64"; + } + + $arch_lex = "flex"; # has problems with vendor lex + + # added a test so that EGL support works for now, but these bits of + # override code probably date back to RHEL4.x or earlier, and + # they likely serve no useful purpose going forward. + if (!$config_opengl_dispatch) { + $opengl_dep_libs = "-L/usr/X11R6/lib64 -lGL -lX11"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib64 -lXext -lX11"; + } + + # this is to make tcl happy + # also needed for plugins + $system_libs .= " -ldl"; + + if ($config_python) { + # this is to make python happy + $system_libs .= " -lutil"; + } + if ($config_shared) { + $arch_opt_flag .= " -fPIC"; + $arch_copts .= " -fPIC"; + $arch_nvccflags .= " -Xcompiler -fPIC"; + $arch_lopts = "-shared"; + $arch_cppopts .= " -DVMD_SHARED"; + } } if ($config_arch eq "LINUXARM64") { - $tcl_libs = "-ltcl8.5"; - if ($config_tk) { $tcl_libs = "-ltk8.5 -lX11 " . $tcl_libs; } - $vmd_libs = "$tcl_libs -lz"; + $tcl_libs = "-ltcl8.5"; + if ($config_tk) { $tcl_libs = "-ltk8.5 -lX11 " . $tcl_libs; } + $vmd_libs = "$tcl_libs -lz"; - $arch_nvcc = "/usr/local/cuda/bin/nvcc"; - $arch_nvccflags = "--ptxas-options=-v " . - "-gencode arch=compute_30,code=compute_30 " . - "-gencode arch=compute_70,code=compute_70 " . - "--ftz=true "; - $cuda_library = "-L/usr/local/cuda/lib64"; - $arch_cc = "cc"; - $arch_ccpp = "c++"; - $arch_copts = "-Wall -Wno-unknown-pragmas -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; - $arch_lex = "flex"; + $arch_nvcc = "/usr/local/cuda/bin/nvcc"; + $arch_nvccflags = "--ptxas-options=-v " . + "-gencode arch=compute_30,code=compute_30 " . + "-gencode arch=compute_70,code=compute_70 " . + "--ftz=true "; + $cuda_library = "-L/usr/local/cuda/lib64"; + $arch_cc = "cc"; + $arch_ccpp = "c++"; + $arch_copts = "-Wall -Wno-unknown-pragmas -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; + $arch_lex = "flex"; - # needed for plugins - $arch_lopts = "-lm"; - $system_libs .= " -ldl"; + # needed for plugins + $arch_lopts = "-lm"; + $system_libs .= " -ldl"; } if ($config_arch eq "LINUXCARMA") { - # Tcl 8.6.0 is reliable on CARMA, 8.5.x is not... - $tcl_libs = "-ltcl8.6"; - if ($config_tk) { $tcl_libs = "-ltk8.6 -lX11 " . $tcl_libs; } - $vmd_libs = "$tcl_libs -lz"; - - $arch_nvcc = "/usr/local/cuda-5.5/bin/nvcc"; - $arch_nvccflags = "--ptxas-options=-v " . - "-gencode arch=compute_20,code=sm_20 " . - "-gencode arch=compute_30,code=sm_30 " . - "-gencode arch=compute_35,code=sm_35 " . - "-gencode arch=compute_20,code=compute_20 " . - "-gencode arch=compute_30,code=compute_30 " . - "--ftz=true "; - $cuda_library = "-L/usr/local/cuda/lib"; - $arch_cc = "cc"; - $arch_ccpp = "c++"; - $arch_copts = "-Wall -Wno-unknown-pragmas -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=vfpv3-d16 -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=vfpv3-d16 -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; - $arch_lex = "flex"; - - # needed for plugins - $arch_lopts = "-lm"; - $system_libs .= " -ldl"; + # Tcl 8.6.0 is reliable on CARMA, 8.5.x is not... + $tcl_libs = "-ltcl8.6"; + if ($config_tk) { $tcl_libs = "-ltk8.6 -lX11 " . $tcl_libs; } + $vmd_libs = "$tcl_libs -lz"; + + $arch_nvcc = "/usr/local/cuda-5.5/bin/nvcc"; + $arch_nvccflags = "--ptxas-options=-v " . + "-gencode arch=compute_20,code=sm_20 " . + "-gencode arch=compute_30,code=sm_30 " . + "-gencode arch=compute_35,code=sm_35 " . + "-gencode arch=compute_20,code=compute_20 " . + "-gencode arch=compute_30,code=compute_30 " . + "--ftz=true "; + $cuda_library = "-L/usr/local/cuda/lib"; + $arch_cc = "cc"; + $arch_ccpp = "c++"; + $arch_copts = "-Wall -Wno-unknown-pragmas -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=vfpv3-d16 -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=vfpv3-d16 -ffast-math -fomit-frame-pointer -fno-strict-aliasing -O3"; + $arch_lex = "flex"; + + # needed for plugins + $arch_lopts = "-lm"; + $system_libs .= " -ldl"; } if ($config_arch eq "LINUXPPC64") { - $def_imageviewer="display %s"; - if ($config_lp64) { - print "No LP64 ABI on this platform currently.\n"; - } + $def_imageviewer="display %s"; + if ($config_lp64) { + print "No LP64 ABI on this platform currently.\n"; + } - $arch_cc = "gcc"; - $arch_ccpp = "g++"; - $arch_depend_flag = "-MM"; - $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; + $arch_cc = "gcc"; + $arch_ccpp = "g++"; + $arch_depend_flag = "-MM"; + $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math"; - if ($config_static) { - $arch_lopts = "-static" - } else { - $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; - } + if ($config_static) { + $arch_lopts = "-static" + } else { + $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; + } - $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; - $arch_cppopts = ""; + $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; + $arch_cppopts = ""; - # this is to make tcl happy - # also needed for plugins - $system_libs .= " -ldl"; + # this is to make tcl happy + # also needed for plugins + $system_libs .= " -ldl"; } if ($config_arch eq "MACOSX") { - $def_imageviewer="/usr/bin/open %s"; - - if ($config_lp64) { - print "No LP64 ABI on this platform currently.\n"; - } - - $fltk_include = "-I$fltk_dir/fltk"; - $fltk_library = "-L$fltk_dir/MACOSX"; - $fltk_libs = "-lfltk -lX11"; - - # Set Python paths to use the system-provided Python rather than - # our own, since Apple MacOS X 10.4.x or newer includes Python 2.3 - # by default. - $python_include = "-F/System/Library/Frameworks"; - $python_library = ""; - $python_libs = "-framework Python -lpthread"; - - $arch_cc = "cc"; - $arch_ccpp = "c++"; - $arch_depend_flag = "-MM"; - $arch_opt_flag = "-fPIC -Os -ffast-math"; - $arch_copts = "-fPIC -Os -ffast-math"; - $arch_cppopts = ""; - - if ($config_static) { - $arch_lopts = "-static" - } else { - $arch_lopts = ""; - } - - # Mesa version uses X11 just like other Unix versions, - # but the OpenGL version uses native MacOS X, no X11. - if ($config_mesa) { - $fltk_libs = "-lfltk-x11 -lX11"; - $opengl_include = $opengl_include . " -I/usr/X11R6/include"; - $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Carbon -lXext -lX11"; - } elsif (!$config_fltkopengl) { - # OpenGL version using X11 just like other Unix versions, - # but the normal OpenGL version uses native MacOS X, no X11. - $fltk_libs = "-lfltk-x11 -lX11"; - $opengl_include = $opengl_include . " -I/usr/X11R6/include"; - $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Carbon -lXext -lX11"; - $tcl_libs = "-ltcl8.5-x11"; - if ($config_tk) { $tcl_libs = "-ltk8.5-x11 -lX11 " . $tcl_libs; } - $vmd_libs = "$tcl_libs"; - } else { - ## - ## MacOS X native builds using Tcl/Tck frameworks - ## - ## use the Tcl/Tk frameworks provided by apple, when we use their Python + $def_imageviewer="/usr/bin/open %s"; + + if ($config_lp64) { + print "No LP64 ABI on this platform currently.\n"; + } + + $fltk_include = "-I$fltk_dir/fltk"; + $fltk_library = "-L$fltk_dir/MACOSX"; + $fltk_libs = "-lfltk -lX11"; + + # Set Python paths to use the system-provided Python rather than + # our own, since Apple MacOS X 10.4.x or newer includes Python 2.3 + # by default. + $python_include = "-F/System/Library/Frameworks"; + $python_library = ""; + $python_libs = "-framework Python -lpthread"; + + $arch_cc = "cc"; + $arch_ccpp = "c++"; + $arch_depend_flag = "-MM"; + $arch_opt_flag = "-fPIC -Os -ffast-math"; + $arch_copts = "-fPIC -Os -ffast-math"; + $arch_cppopts = ""; + + if ($config_static) { + $arch_lopts = "-static" + } else { + $arch_lopts = ""; + } + + # Mesa version uses X11 just like other Unix versions, + # but the OpenGL version uses native MacOS X, no X11. + if ($config_mesa) { + $fltk_libs = "-lfltk-x11 -lX11"; + $opengl_include = $opengl_include . " -I/usr/X11R6/include"; + $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Carbon -lXext -lX11"; + } elsif (!$config_fltkopengl) { + # OpenGL version using X11 just like other Unix versions, + # but the normal OpenGL version uses native MacOS X, no X11. + $fltk_libs = "-lfltk-x11 -lX11"; + $opengl_include = $opengl_include . " -I/usr/X11R6/include"; + $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Carbon -lXext -lX11"; + $tcl_libs = "-ltcl8.5-x11"; + if ($config_tk) { $tcl_libs = "-ltk8.5-x11 -lX11 " . $tcl_libs; } + $vmd_libs = "$tcl_libs"; + } else { + ## + ## MacOS X native builds using Tcl/Tck frameworks + ## + ## use the Tcl/Tk frameworks provided by apple, when we use their Python # $tcl_include = "-F/System/Library/Frameworks"; # $tcl_library = "-F/System/Library/Frameworks"; - ## use our own Tcl/Tk framework builds when not compiling with Python, - ## as Apple's currently shipping versions are quite buggy - $tcl_include = "-I$stock_tcl_include_dir"; - if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.5/Headers"; } - $tcl_library = "-F$stock_tcl_library_dir"; - if ($config_tk) { $tcl_library .= " -F$stock_tk_library_dir"; } - $tcl_libs = "-framework Tcl"; - if ($config_tk) { $tcl_libs = "-framework Tk " . $tcl_libs; } - - $vmd_include = "$tcl_include"; - $vmd_library = "$tcl_library"; - $vmd_libs = "$tcl_libs"; - - # MacOS 10.3 stuff - $vmd_library .= " -Wl,-executable_path . -lmx"; + ## use our own Tcl/Tk framework builds when not compiling with Python, + ## as Apple's currently shipping versions are quite buggy + $tcl_include = "-I$stock_tcl_include_dir"; + if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.5/Headers"; } + $tcl_library = "-F$stock_tcl_library_dir"; + if ($config_tk) { $tcl_library .= " -F$stock_tk_library_dir"; } + $tcl_libs = "-framework Tcl"; + if ($config_tk) { $tcl_libs = "-framework Tk " . $tcl_libs; } + + $vmd_include = "$tcl_include"; + $vmd_library = "$tcl_library"; + $vmd_libs = "$tcl_libs"; + + # MacOS 10.3 stuff + $vmd_library .= " -Wl,-executable_path . -lmx"; - $fltk_libs = "-lfltk"; - $opengl_include = $opengl_include; - $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Carbon"; + $fltk_libs = "-lfltk"; + $opengl_include = $opengl_include; + $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Carbon"; # $arch_compilerc = "/Developer/Tools/Rez"; - $arch_compilerc = "/usr/bin/Rez"; - $arch_rcflags = "-t APPL -o ../MACOSX/vmd_MACOSX vmdmac.r"; - } + $arch_compilerc = "/usr/bin/Rez"; + $arch_rcflags = "-t APPL -o ../MACOSX/vmd_MACOSX vmdmac.r"; + } - $mesa_include = $mesa_include . " -I/usr/X11R6/include"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; + $mesa_include = $mesa_include . " -I/usr/X11R6/include"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; - # no libm.a on MacOS-X - $system_include = $system_include; - $system_libs = " -framework Carbon "; + # no libm.a on MacOS-X + $system_include = $system_include; + $system_libs = " -framework Carbon "; } if ($config_arch eq "MACOSXARM64") { - $def_imageviewer="/usr/bin/open %s"; - - ## XXX 64-bit MacOS X 11.x builds currently require the bleeding-edge - ## FLTK 1.4.x development branch for cocoa support - $fltk_include = "-I$fltk_dir/fltk"; - $fltk_library = "-L$fltk_dir/$config_arch"; - $fltk_libs = "-lfltk -lX11"; - - # Set Python paths to use the system-provided Python rather than - # our own, since Apple MacOS X 10.4.x or newer includes Python 2.3 - # by default. - $python_include = "-F/System/Library/Frameworks"; - $python_library = ""; - $python_libs = "-framework Python -lpthread"; - - $arch_cc = "cc"; - $arch_ccpp = "c++"; - $arch_depend_flag = "-MM"; - $arch_opt_flag = "-fPIC -Os -ffast-math"; - $arch_copts = "-fPIC -Os -ffast-math"; - $arch_cppopts = ""; - - if ($config_static) { - $arch_lopts = "-static" - } else { - $arch_lopts = ""; - } - - # Mesa version uses X11 just like other Unix versions, - # but the OpenGL version uses native MacOS X, no X11. - if ($config_mesa) { - $fltk_libs = "-lfltk-x11 -lX11"; - $opengl_include = $opengl_include . " -I/usr/X11R6/include"; - $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Cocoa -lXext -lX11"; - } elsif (!$config_fltkopengl) { - # OpenGL version using X11 just like other Unix versions, - # but the normal OpenGL version uses native MacOS X, no X11. - $arch_opt_flag .= " -DVMDNOMACBUNDLE"; - $arch_copts .= " -DVMDNOMACBUNDLE"; - $fltk_libs = "-lfltk-x11 -lX11"; - $opengl_include = $opengl_include . " -I/usr/X11R6/include"; - $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Cocoa -lXext -lX11"; - ## - ## XXX workaround a documented MacOS X linker problem when building - ## things using X11+OpenGL: - ## http://developer.apple.com/qa/qa2007/qa1567.html - ## - $opengl_dep_libs .= " -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"; - $tcl_libs = "-ltcl8.5-x11"; - if ($config_tk) { $tcl_libs = "-ltk8.5-x11 -lX11 " . $tcl_libs; } - $vmd_libs = "$tcl_libs"; - } else { - ## - ## MacOS X native builds using Tcl/Tck frameworks - ## - ## use the Tcl/Tk frameworks provided by apple, when we use their Python + $def_imageviewer="/usr/bin/open %s"; + + ## XXX 64-bit MacOS X 11.x builds currently require the bleeding-edge + ## FLTK 1.4.x development branch for cocoa support + $fltk_include = "-I$fltk_dir/fltk"; + $fltk_library = "-L$fltk_dir/$config_arch"; + $fltk_libs = "-lfltk -lX11"; + + # Set Python paths to use the system-provided Python rather than + # our own, since Apple MacOS X 10.4.x or newer includes Python 2.3 + # by default. + $python_include = "-F/System/Library/Frameworks"; + $python_library = ""; + $python_libs = "-framework Python -lpthread"; + + $arch_cc = "cc"; + $arch_ccpp = "c++"; + $arch_depend_flag = "-MM"; + $arch_opt_flag = "-fPIC -Os -ffast-math"; + $arch_copts = "-fPIC -Os -ffast-math"; + $arch_cppopts = ""; + + if ($config_static) { + $arch_lopts = "-static" + } else { + $arch_lopts = ""; + } + + # Mesa version uses X11 just like other Unix versions, + # but the OpenGL version uses native MacOS X, no X11. + if ($config_mesa) { + $fltk_libs = "-lfltk-x11 -lX11"; + $opengl_include = $opengl_include . " -I/usr/X11R6/include"; + $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Cocoa -lXext -lX11"; + } elsif (!$config_fltkopengl) { + # OpenGL version using X11 just like other Unix versions, + # but the normal OpenGL version uses native MacOS X, no X11. + $arch_opt_flag .= " -DVMDNOMACBUNDLE"; + $arch_copts .= " -DVMDNOMACBUNDLE"; + $fltk_libs = "-lfltk-x11 -lX11"; + $opengl_include = $opengl_include . " -I/usr/X11R6/include"; + $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Cocoa -lXext -lX11"; + ## + ## XXX workaround a documented MacOS X linker problem when building + ## things using X11+OpenGL: + ## http://developer.apple.com/qa/qa2007/qa1567.html + ## + $opengl_dep_libs .= " -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"; + $tcl_libs = "-ltcl8.5-x11"; + if ($config_tk) { $tcl_libs = "-ltk8.5-x11 -lX11 " . $tcl_libs; } + $vmd_libs = "$tcl_libs"; + } else { + ## + ## MacOS X native builds using Tcl/Tck frameworks + ## + ## use the Tcl/Tk frameworks provided by apple, when we use their Python # $tcl_include = "-F/System/Library/Frameworks"; # $tcl_library = "-F/System/Library/Frameworks"; - ## use our own Tcl/Tk framework builds when not compiling with Python, - ## as Apple's currently shipping versions are quite buggy - $tcl_include = "-I$stock_tcl_include_dir"; - if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.6/Headers"; } - $tcl_library = "-F$stock_tcl_library_dir"; - if ($config_tk) { $tcl_library .= " -F$stock_tk_library_dir"; } - $tcl_libs = "-framework Tcl"; - if ($config_tk) { $tcl_libs = "-framework Tk " . $tcl_libs; } - - $vmd_include = "$tcl_include"; - $vmd_library = "$tcl_library"; - $vmd_libs = "$tcl_libs"; - - # MacOS 10.3 stuff - $vmd_library .= " -Wl,-executable_path . -lmx"; + ## use our own Tcl/Tk framework builds when not compiling with Python, + ## as Apple's currently shipping versions are quite buggy + $tcl_include = "-I$stock_tcl_include_dir"; + if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.6/Headers"; } + $tcl_library = "-F$stock_tcl_library_dir"; + if ($config_tk) { $tcl_library .= " -F$stock_tk_library_dir"; } + $tcl_libs = "-framework Tcl"; + if ($config_tk) { $tcl_libs = "-framework Tk " . $tcl_libs; } + + $vmd_include = "$tcl_include"; + $vmd_library = "$tcl_library"; + $vmd_libs = "$tcl_libs"; + + # MacOS 10.3 stuff + $vmd_library .= " -Wl,-executable_path . -lmx"; - $fltk_libs = "-lfltk"; - $opengl_include = $opengl_include; - $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Cocoa"; - $arch_compilerc = "/usr/bin/Rez"; - $arch_rcflags = "-t APPL -o ../MACOSXX86_64/vmd_MACOSXX86_64 vmdmac.r"; - } + $fltk_libs = "-lfltk"; + $opengl_include = $opengl_include; + $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Cocoa"; + $arch_compilerc = "/usr/bin/Rez"; + $arch_rcflags = "-t APPL -o ../MACOSXARM64/vmd_MACOSXARM64 vmdmac.r"; + } - $mesa_include = $mesa_include . " -I/usr/X11R6/include"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; + $mesa_include = $mesa_include . " -I/usr/X11R6/include"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; - if ($config_cuda) { - # This is a hack since we don't have a unified nvcc front-end install yet - $arch_nvcc = "/usr/local/cuda-8.0/bin/nvcc"; - $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; - $cuda_dir = "/usr/local/cuda-8.0"; - $cuda_library = "-L/usr/local/cuda-8.0/lib"; - } - if ($config_opencl) { - $opencl_libs = "-framework OpenCL"; - } + if ($config_cuda) { + # This is a hack since we don't have a unified nvcc front-end install yet + $arch_nvcc = "/usr/local/cuda-8.0/bin/nvcc"; + $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; + $cuda_dir = "/usr/local/cuda-8.0"; + $cuda_library = "-L/usr/local/cuda-8.0/lib"; + } + if ($config_opencl) { + $opencl_libs = "-framework OpenCL"; + } - # no libm.a on MacOS-X - $system_include = $system_include; - $system_libs = " -framework Cocoa "; + # no libm.a on MacOS-X + $system_include = $system_include; + $system_libs = " -framework Cocoa "; } if ($config_arch eq "MACOSXX86" || $config_arch eq "MACOSXX86_64") { - $def_imageviewer="/usr/bin/open %s"; - - if ($config_lp64) { - ## XXX 64-bit MacOS X 10.15 builds currently require the bleeding-edge - ## FLTK 1.4.x developmental branch for stable cocoa support - $fltk_include = "-I$fltk_dir/fltk"; - } else { - $fltk_include = "-I$fltk_dir/fltk"; - } - $fltk_library = "-L$fltk_dir/$config_arch"; - $fltk_libs = "-lfltk -lX11"; - - # Set Python paths to use the system-provided Python rather than our own - $python_include = "-F/System/Library/Frameworks"; - $python_library = ""; - $python_libs = "-framework Python -lpthread"; - - if ($config_lp64) { - $arch_cc = "cc"; - $arch_ccpp = "c++"; - $arch_depend_flag = "-MM"; - $arch_opt_flag = "-m64 -fPIC -Os -ffast-math"; - $arch_copts = "-m64 -fPIC -Os -ffast-math"; - } else { - $arch_cc = "cc"; - $arch_ccpp = "c++"; - $arch_depend_flag = "-MM"; - $arch_opt_flag = "-m32 -fPIC -Os -ffast-math"; - $arch_copts = "-m32 -fPIC -Os -ffast-math"; - } - $arch_cppopts = ""; - - if ($config_static) { - $arch_lopts = "-static" - } else { - $arch_lopts = ""; - } - - # Mesa version uses X11 just like other Unix versions, - # but the OpenGL version uses native MacOS X, no X11. - if ($config_mesa) { - $fltk_libs = "-lfltk-x11 -lX11"; - $opengl_include = $opengl_include . " -I/usr/X11R6/include"; - if ($config_lp64) { - $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Cocoa -lXext -lX11"; - } else { - $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Carbon -lXext -lX11"; - } - } elsif (!$config_fltkopengl) { - # OpenGL version using X11 just like other Unix versions, - # but the normal OpenGL version uses native MacOS X, no X11. - $arch_opt_flag .= " -DVMDNOMACBUNDLE"; - $arch_copts .= " -DVMDNOMACBUNDLE"; - $fltk_libs = "-lfltk-x11 -lX11"; - $opengl_include = $opengl_include . " -I/usr/X11R6/include"; - if ($config_lp64) { - $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Cocoa -lXext -lX11"; - } else { - $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Carbon -lXext -lX11"; - } - ## - ## XXX workaround a documented MacOS X linker problem when building - ## things using X11+OpenGL: - ## http://developer.apple.com/qa/qa2007/qa1567.html - ## - $opengl_dep_libs .= " -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"; - $tcl_libs = "-ltcl8.5-x11"; - if ($config_tk) { $tcl_libs = "-ltk8.5-x11 -lX11 " . $tcl_libs; } - $vmd_libs = "$tcl_libs"; - } else { - ## - ## MacOS X native builds using Tcl/Tck frameworks - ## - ## use the Tcl/Tk frameworks provided by apple, when we use their Python + $def_imageviewer="/usr/bin/open %s"; + + if ($config_lp64) { + ## XXX 64-bit MacOS X 10.15 builds currently require the bleeding-edge + ## FLTK 1.4.x developmental branch for stable cocoa support + $fltk_include = "-I$fltk_dir/fltk"; + } else { + $fltk_include = "-I$fltk_dir/fltk"; + } + $fltk_library = "-L$fltk_dir/$config_arch"; + $fltk_libs = "-lfltk -lX11"; + + # Set Python paths to use the system-provided Python rather than our own + $python_include = "-F/System/Library/Frameworks"; + $python_library = ""; + $python_libs = "-framework Python -lpthread"; + + if ($config_lp64) { + $arch_cc = "cc"; + $arch_ccpp = "c++"; + $arch_depend_flag = "-MM"; + $arch_opt_flag = "-m64 -fPIC -Os -ffast-math"; + $arch_copts = "-m64 -fPIC -Os -ffast-math"; + } else { + $arch_cc = "cc"; + $arch_ccpp = "c++"; + $arch_depend_flag = "-MM"; + $arch_opt_flag = "-m32 -fPIC -Os -ffast-math"; + $arch_copts = "-m32 -fPIC -Os -ffast-math"; + } + $arch_cppopts = ""; + + if ($config_static) { + $arch_lopts = "-static" + } else { + $arch_lopts = ""; + } + + # Mesa version uses X11 just like other Unix versions, + # but the OpenGL version uses native MacOS X, no X11. + if ($config_mesa) { + $fltk_libs = "-lfltk-x11 -lX11"; + $opengl_include = $opengl_include . " -I/usr/X11R6/include"; + if ($config_lp64) { + $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Cocoa -lXext -lX11"; + } else { + $opengl_dep_libs = "-L/usr/X11R6/lib -framework OpenGL -framework AGL -framework Carbon -lXext -lX11"; + } + } elsif (!$config_fltkopengl) { + # OpenGL version using X11 just like other Unix versions, + # but the normal OpenGL version uses native MacOS X, no X11. + $arch_opt_flag .= " -DVMDNOMACBUNDLE"; + $arch_copts .= " -DVMDNOMACBUNDLE"; + $fltk_libs = "-lfltk-x11 -lX11"; + $opengl_include = $opengl_include . " -I/usr/X11R6/include"; + if ($config_lp64) { + $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Cocoa -lXext -lX11"; + } else { + $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -framework Carbon -lXext -lX11"; + } + ## + ## XXX workaround a documented MacOS X linker problem when building + ## things using X11+OpenGL: + ## http://developer.apple.com/qa/qa2007/qa1567.html + ## + $opengl_dep_libs .= " -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"; + $tcl_libs = "-ltcl8.5-x11"; + if ($config_tk) { $tcl_libs = "-ltk8.5-x11 -lX11 " . $tcl_libs; } + $vmd_libs = "$tcl_libs"; + } else { + ## + ## MacOS X native builds using Tcl/Tck frameworks + ## + ## use the Tcl/Tk frameworks provided by apple, when we use their Python # $tcl_include = "-F/System/Library/Frameworks"; # $tcl_library = "-F/System/Library/Frameworks"; - ## use our own Tcl/Tk framework builds when not compiling with Python, - ## as Apple's currently shipping versions are quite buggy - $tcl_include = "-I$stock_tcl_include_dir"; - if ($config_lp64) { - # 64-bit MacOS X builds (10.15 or 11.0) require Tcl/Tk 8.6 or later - if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.6/Headers"; } - } else { - if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.5/Headers"; } - } - $tcl_library = "-F$stock_tcl_library_dir"; - if ($config_tk) { $tcl_library .= " -F$stock_tk_library_dir"; } - $tcl_libs = "-framework Tcl"; - if ($config_tk) { $tcl_libs = "-framework Tk " . $tcl_libs; } - - $vmd_include = "$tcl_include"; - $vmd_library = "$tcl_library"; - $vmd_libs = "$tcl_libs"; - - # MacOS 10.3 stuff - $vmd_library .= " -Wl,-executable_path . -lmx"; + ## use our own Tcl/Tk framework builds when not compiling with Python, + ## as Apple's currently shipping versions are quite buggy + $tcl_include = "-I$stock_tcl_include_dir"; + if ($config_lp64) { + # 64-bit MacOS X builds (10.15 or 11.0) require Tcl/Tk 8.6 or later + if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.6/Headers"; } + } else { + if ($config_tk) { $tcl_include .= " -I$stock_tk_library_dir/Tk.framework/Versions/8.5/Headers"; } + } + $tcl_library = "-F$stock_tcl_library_dir"; + if ($config_tk) { $tcl_library .= " -F$stock_tk_library_dir"; } + $tcl_libs = "-framework Tcl"; + if ($config_tk) { $tcl_libs = "-framework Tk " . $tcl_libs; } + + $vmd_include = "$tcl_include"; + $vmd_library = "$tcl_library"; + $vmd_libs = "$tcl_libs"; + + # MacOS 10.3 stuff + $vmd_library .= " -Wl,-executable_path . -lmx"; - $fltk_libs = "-lfltk"; - $opengl_include = $opengl_include; - if ($config_lp64) { - # 64-bit MacOS X builds use Cocoa rather than Carbon APIs - $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Cocoa"; - } else { - $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Carbon"; - } - if ($config_lp64) { - $arch_compilerc = "/usr/bin/Rez"; - $arch_rcflags = "-t APPL -o ../MACOSXX86_64/vmd_MACOSXX86_64 vmdmac.r"; - } else { + $fltk_libs = "-lfltk"; + $opengl_include = $opengl_include; + if ($config_lp64) { + # 64-bit MacOS X builds use Cocoa rather than Carbon APIs + $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Cocoa"; + } else { + $opengl_dep_libs = "-framework OpenGL -framework AGL -framework Carbon"; + } + if ($config_lp64) { + $arch_compilerc = "/usr/bin/Rez"; + $arch_rcflags = "-t APPL -o ../MACOSXX86_64/vmd_MACOSXX86_64 vmdmac.r"; + } else { # $arch_compilerc = "/Developer/Tools/Rez"; - $arch_compilerc = "/usr/bin/Rez"; - $arch_rcflags = "-t APPL -o ../MACOSXX86/vmd_MACOSXX86 vmdmac.r"; - } - } - - $mesa_include = $mesa_include . " -I/usr/X11R6/include"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; - - if ($config_cuda) { - # This is a hack since we don't have a unified nvcc front-end install yet - if ($config_lp64) { - $arch_nvcc = "/usr/local/cuda-8.0/bin/nvcc"; - $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; - $cuda_dir = "/usr/local/cuda-8.0"; - $cuda_library = "-L/usr/local/cuda-8.0/lib"; - } else { - $arch_nvcc = "/usr/local/cuda/bin/nvcc"; - $arch_nvccflags .= " --machine 32 -O3 $cuda_include"; - $cuda_library = "-L/usr/local/cuda/lib"; - } - } - if ($config_opencl) { - $opencl_libs = "-framework OpenCL"; - } - - # no libm.a on MacOS-X - $system_include = $system_include; - if ($config_lp64) { - $system_libs = " -framework Cocoa "; - } else { - $system_libs = " -framework Carbon "; - } + $arch_compilerc = "/usr/bin/Rez"; + $arch_rcflags = "-t APPL -o ../MACOSXX86/vmd_MACOSXX86 vmdmac.r"; + } + } + + $mesa_include = $mesa_include . " -I/usr/X11R6/include"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; + + if ($config_cuda) { + # This is a hack since we don't have a unified nvcc front-end install yet + if ($config_lp64) { + $arch_nvcc = "/usr/local/cuda-8.0/bin/nvcc"; + $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; + $cuda_dir = "/usr/local/cuda-8.0"; + $cuda_library = "-L/usr/local/cuda-8.0/lib"; + } else { + $arch_nvcc = "/usr/local/cuda/bin/nvcc"; + $arch_nvccflags .= " --machine 32 -O3 $cuda_include"; + $cuda_library = "-L/usr/local/cuda/lib"; + } + } + if ($config_opencl) { + $opencl_libs = "-framework OpenCL"; + } + + # no libm.a on MacOS-X + $system_include = $system_include; + if ($config_lp64) { + $system_libs = " -framework Cocoa "; + } else { + $system_libs = " -framework Carbon "; + } } if ($config_arch eq "SUMMIT") { - $def_imageviewer="display %s"; - - # XXX currently the Summit EGL/GL install is broken, so we use hacks... - $egl_pbuffer_dir = ""; - $egl_pbuffer_library = "-L/usr/lib64/nvidia"; - $egl_pbuffer_include = "-I/usr/include/nvidia"; - $egl_pbuffer_libs = "-lEGL"; - - if ($config_xlc) { - $arch_cc = "xlc"; - $arch_ccpp = "xlC"; - $arch_copts = "-O4 -qsuppress=1500-036 -q64 -qarch=pwr9 -qtune=pwr9 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; - $arch_opt_flag = "-O4 -qsuppress=1500-036 -q64 -qarch=pwr9 -qtune=pwr9 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; + $def_imageviewer="display %s"; + + # XXX currently the Summit EGL/GL install is broken, so we use hacks... + $egl_pbuffer_dir = ""; + $egl_pbuffer_library = "-L/usr/lib64/nvidia"; + $egl_pbuffer_include = "-I/usr/include/nvidia"; + $egl_pbuffer_libs = "-lEGL"; + + if ($config_xlc) { + $arch_cc = "xlc"; + $arch_ccpp = "xlC"; + $arch_copts = "-O4 -qsuppress=1500-036 -q64 -qarch=pwr9 -qtune=pwr9 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; + $arch_opt_flag = "-O4 -qsuppress=1500-036 -q64 -qarch=pwr9 -qtune=pwr9 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; # $arch_cppopts = "-D_H_ACCESS=1"; - $arch_depend_flag = "-MM"; - } elsif ($config_gcc) { - $arch_cc = "gcc"; - $arch_ccpp = "g++"; - $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; - $arch_depend_flag = "-MM"; - } elsif ($config_clang) { - $arch_cc = "clang"; - $arch_ccpp = "clang++"; - $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power9"; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power9"; - $arch_depend_flag = "-MM"; - } - - if ($config_static) { - $arch_lopts = "-static" - } else { - $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; - } - - # added a test so that EGL support works for now, but these bits of - # override code probably date back to RHEL4.x or earlier, and - # they likely serve no useful purpose going forward. - if (!$config_opengl_dispatch) { - $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; - } - - $arch_cppopts = ""; - - # this is to make tcl happy - # also needed for plugins - $system_libs .= " -ldl"; - - if ($config_cuda) { + $arch_depend_flag = "-MM"; + } elsif ($config_gcc) { + $arch_cc = "gcc"; + $arch_ccpp = "g++"; + $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; + $arch_depend_flag = "-MM"; + } elsif ($config_clang) { + $arch_cc = "clang"; + $arch_ccpp = "clang++"; + $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power9"; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power9"; + $arch_depend_flag = "-MM"; + } + + if ($config_static) { + $arch_lopts = "-static" + } else { + $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; + } + + # added a test so that EGL support works for now, but these bits of + # override code probably date back to RHEL4.x or earlier, and + # they likely serve no useful purpose going forward. + if (!$config_opengl_dispatch) { + $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; + } + + $arch_cppopts = ""; + + # this is to make tcl happy + # also needed for plugins + $system_libs .= " -ldl"; + + if ($config_cuda) { # $arch_nvcc = "/sw/summit/cuda/9.2.64/bin/nvcc"; # $cuda_include = "-I/sw/summit/cuda/9.2.64/include"; # $cuda_library = "-L/sw/summit/cuda/9.2.64/lib64"; # $arch_nvcc = "/sw/summit/cuda/9.2.148/bin/nvcc"; # $cuda_include = "-I/sw/summit/cuda/9.2.148/include"; # $cuda_library = "-L/sw/summit/cuda/9.2.148/lib64"; - $arch_nvcc = "/sw/summit/cuda/11.0.3/bin/nvcc"; - $cuda_include = "-I/sw/summit/cuda/11.0.3/include"; - $cuda_library = "-L/sw/summit/cuda/11.0.3/lib64"; - $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart_static -lrt"; - - # Only generate code for SM 7.0 on Summit - $arch_nvccflags = "--ptxas-options=-v " . - "-gencode arch=compute_70,code=sm_70 " . - "--ftz=true "; - $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; - } - - if ($config_mpi) { - $arch_copts .= " -DUSE_MPI_IN_PLACE"; - $arch_opt_flag .= " -DUSE_MPI_IN_PLACE"; - $mpi_libs = ""; - $mpi_dir = "/sw/summit/.swci/1-compute/opt/spack/20171006/linux-rhel7-ppc64le/xl-20180223-beta/spectrum-mpi-10.2.0.0-20180110-bybgigxu6ksueoxu3tngxf7yqn7tzrz3"; - $mpi_include = "-I$mpi_dir/include"; - $mpi_library = "-L$mpi_dir/lib -L$mpi_dir/lib/pami_414"; - $mpi_libs = "-lmpi_ibm -lpami_cudahook -lpami -lhwloc -levent -levent_pthreads -lopen-rte -lopen-pal "; - } + $arch_nvcc = "/sw/summit/cuda/11.0.3/bin/nvcc"; + $cuda_include = "-I/sw/summit/cuda/11.0.3/include"; + $cuda_library = "-L/sw/summit/cuda/11.0.3/lib64"; + $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart_static -lrt"; + + # Only generate code for SM 7.0 on Summit + $arch_nvccflags = "--ptxas-options=-v " . + "-gencode arch=compute_70,code=sm_70 " . + "--ftz=true "; + $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; + } + + if ($config_mpi) { + $arch_copts .= " -DUSE_MPI_IN_PLACE"; + $arch_opt_flag .= " -DUSE_MPI_IN_PLACE"; + $mpi_libs = ""; + $mpi_dir = "/sw/summit/.swci/1-compute/opt/spack/20171006/linux-rhel7-ppc64le/xl-20180223-beta/spectrum-mpi-10.2.0.0-20180110-bybgigxu6ksueoxu3tngxf7yqn7tzrz3"; + $mpi_include = "-I$mpi_dir/include"; + $mpi_library = "-L$mpi_dir/lib -L$mpi_dir/lib/pami_414"; + $mpi_libs = "-lmpi_ibm -lpami_cudahook -lpami -lhwloc -levent -levent_pthreads -lopen-rte -lopen-pal "; + } } if ($config_arch eq "OPENPOWER" || $config_arch eq "SUMMITDEV") { - $def_imageviewer="display %s"; + $def_imageviewer="display %s"; - if ($config_xlc) { - $arch_cc = "xlc"; - $arch_ccpp = "xlC"; - $arch_copts = "-O4 -q64 -qarch=pwr8 -qtune=pwr8 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; - $arch_opt_flag = "-O4 -q64 -qarch=pwr8 -qtune=pwr8 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; + if ($config_xlc) { + $arch_cc = "xlc"; + $arch_ccpp = "xlC"; + $arch_copts = "-O4 -q64 -qarch=pwr8 -qtune=pwr8 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; + $arch_opt_flag = "-O4 -q64 -qarch=pwr8 -qtune=pwr8 -qmaxmem=-1 -qnoipa -qignerrno -qfloat=rsqrt -qnostrict"; # $arch_cppopts = "-D_H_ACCESS=1"; - $arch_depend_flag = "-MM"; - } else { - $arch_cc = "gcc"; - $arch_ccpp = "g++"; - $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; - $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; - $arch_depend_flag = "-MM"; - } - - if ($config_static) { - $arch_lopts = "-static" - } else { - $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; - } - - # added a test so that EGL support works for now, but these bits of - # override code probably date back to RHEL4.x or earlier, and - # they likely serve no useful purpose going forward. - if (!$config_opengl_dispatch) { - $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; - $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; - } - - $arch_cppopts = ""; - - # this is to make tcl happy - # also needed for plugins - $system_libs .= " -ldl"; - - if ($config_cuda) { - $arch_nvcc = "/usr/local/cuda-9.2/bin/nvcc"; - $cuda_library = "-L/usr/local/cuda-9.2/lib64"; - #$arch_nvcc = "/usr/local/cuda-8.0/bin/nvcc"; - #$cuda_library = "-L/usr/local/cuda-8.0/lib64"; - $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart_static -lrt"; + $arch_depend_flag = "-MM"; + } else { + $arch_cc = "gcc"; + $arch_ccpp = "g++"; + $arch_opt_flag = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; + $arch_copts = "-m64 -Wall -Wno-unknown-pragmas -O3 -ffast-math -mtune=power8"; + $arch_depend_flag = "-MM"; + } + + if ($config_static) { + $arch_lopts = "-static" + } else { + $arch_lopts = "-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/local/lib"; + } + + # added a test so that EGL support works for now, but these bits of + # override code probably date back to RHEL4.x or earlier, and + # they likely serve no useful purpose going forward. + if (!$config_opengl_dispatch) { + $opengl_dep_libs = "-L/usr/X11R6/lib -lGL -lXext -lX11"; + $mesa_libs = "-lMesaGL -L/usr/X11R6/lib -lXext -lX11"; + } + + $arch_cppopts = ""; + + # this is to make tcl happy + # also needed for plugins + $system_libs .= " -ldl"; + + if ($config_cuda) { + $arch_nvcc = "/usr/local/cuda-9.2/bin/nvcc"; + $cuda_library = "-L/usr/local/cuda-9.2/lib64"; + #$arch_nvcc = "/usr/local/cuda-8.0/bin/nvcc"; + #$cuda_library = "-L/usr/local/cuda-8.0/lib64"; + $cuda_libs = "-Wl,-rpath -Wl,\$\$ORIGIN/ -lcudart_static -lrt"; - # Only generate code for SM 3.5 or higher on IBM machines - $arch_nvccflags = "--ptxas-options=-v " . - "-gencode arch=compute_35,code=sm_35 " . - "-gencode arch=compute_50,code=sm_50 " . - "-gencode arch=compute_60,code=sm_60 " . - "-gencode arch=compute_70,code=sm_70 " . - "--ftz=true "; - $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; - } + # Only generate code for SM 3.5 or higher on IBM machines + $arch_nvccflags = "--ptxas-options=-v " . + "-gencode arch=compute_35,code=sm_35 " . + "-gencode arch=compute_50,code=sm_50 " . + "-gencode arch=compute_60,code=sm_60 " . + "-gencode arch=compute_70,code=sm_70 " . + "--ftz=true "; + $arch_nvccflags .= " --machine 64 -O3 $cuda_include"; + } } if ($config_arch eq "SOLARIS2" || $config_arch eq "SOLARIS2_64") { - $freevr_libs .= " -lrt"; - - if ($config_gcc) { - if ($config_lp64) { - print "GCC doesn't support LP64 ABI on this platform currently.\n"; - } - $arch_ccpp = "g++"; - $arch_cc = "gcc"; - $arch_opt_flag = "-O"; - $arch_copts = "-O"; - $arch_debug_flag = "-g"; - $arch_depend_flag = "-M"; - } else { - # Using Sun's compilers. - if ($config_lp64) { - print "Configured for a 64-bit build.\n"; - $arch_ccpp = "CC -D__EXTENSIONS__"; - $arch_cc = "cc -D__EXTENSIONS__"; - if ($config_pthreads) { - $arch_opt_flag = "-mt -fast -xO3 -native -xarch=v9a"; - $arch_copts = "-mt -fast -xO3 -native -xarch=v9a"; - } else { - $arch_opt_flag = "-fast -xO3 -native -xarch=v9a"; - $arch_copts = "-fast -xO3 -native -xarch=v9a"; - } - $arch_debug_flag = "-g"; - $arch_depend_flag = "-xM"; - } else { - print "Configured for a 32-bit build.\n"; - $arch_ccpp = "CC -D__EXTENSIONS__"; - $arch_cc = "cc -D__EXTENSIONS__"; - if ($config_pthreads) { - $arch_opt_flag = "-mt -fast -xO3 -native -xarch=v8plusa"; - $arch_copts = "-mt -fast -xO3 -native -xarch=v8plusa"; - } else { - $arch_opt_flag = "-fast -xO3 -native -xarch=v8plusa"; - $arch_copts = "-fast -xO3 -native -xarch=v8plusa"; - } - $arch_debug_flag = "-g"; - $arch_depend_flag = "-xM"; - } - } + $freevr_libs .= " -lrt"; + + if ($config_gcc) { + if ($config_lp64) { + print "GCC doesn't support LP64 ABI on this platform currently.\n"; + } + $arch_ccpp = "g++"; + $arch_cc = "gcc"; + $arch_opt_flag = "-O"; + $arch_copts = "-O"; + $arch_debug_flag = "-g"; + $arch_depend_flag = "-M"; + } else { + # Using Sun's compilers. + if ($config_lp64) { + print "Configured for a 64-bit build.\n"; + $arch_ccpp = "CC -D__EXTENSIONS__"; + $arch_cc = "cc -D__EXTENSIONS__"; + if ($config_pthreads) { + $arch_opt_flag = "-mt -fast -xO3 -native -xarch=v9a"; + $arch_copts = "-mt -fast -xO3 -native -xarch=v9a"; + } else { + $arch_opt_flag = "-fast -xO3 -native -xarch=v9a"; + $arch_copts = "-fast -xO3 -native -xarch=v9a"; + } + $arch_debug_flag = "-g"; + $arch_depend_flag = "-xM"; + } else { + print "Configured for a 32-bit build.\n"; + $arch_ccpp = "CC -D__EXTENSIONS__"; + $arch_cc = "cc -D__EXTENSIONS__"; + if ($config_pthreads) { + $arch_opt_flag = "-mt -fast -xO3 -native -xarch=v8plusa"; + $arch_copts = "-mt -fast -xO3 -native -xarch=v8plusa"; + } else { + $arch_opt_flag = "-fast -xO3 -native -xarch=v8plusa"; + $arch_copts = "-fast -xO3 -native -xarch=v8plusa"; + } + $arch_debug_flag = "-g"; + $arch_depend_flag = "-xM"; + } + } # if compiling on Solaris 10, use this setting instead. - $arch_cppopts = ""; + $arch_cppopts = ""; # $arch_cppopts = $arch_no_math_float; - if ($config_static) { - $arch_lopts = "-Bstatic -lsocket -lnsl"; - } else { - $arch_lopts = "-lsocket -lnsl -ldl"; - } + if ($config_static) { + $arch_lopts = "-Bstatic -lsocket -lnsl"; + } else { + $arch_lopts = "-lsocket -lnsl -ldl"; + } - $opengl_dep_dir = "/usr/openwin"; - $opengl_dep_include = "-I$opengl_dep_dir/include"; - if ($config_lp64) { - $opengl_dep_library = "-L$opengl_dep_dir/lib/sparcv9"; - } else { - $opengl_dep_library = "-L$opengl_dep_dir/lib"; - } - $opengl_dep_libs = "-lGL -lX11 -lXext"; + $opengl_dep_dir = "/usr/openwin"; + $opengl_dep_include = "-I$opengl_dep_dir/include"; + if ($config_lp64) { + $opengl_dep_library = "-L$opengl_dep_dir/lib/sparcv9"; + } else { + $opengl_dep_library = "-L$opengl_dep_dir/lib"; + } + $opengl_dep_libs = "-lGL -lX11 -lXext"; - $mesa_include = $mesa_include . " -I/usr/openwin/include"; - if ($config_lp64) { - $mesa_library = $mesa_library . " -L/usr/openwin/lib/sparcv9"; - $mesa_libs = "-lMesaGL -L/usr/openwin/lib/sparcv9 -lXext -lX11"; - } else { - $mesa_library = $mesa_library . " -L/usr/openwin/lib"; - $mesa_libs = "-lMesaGL -L/usr/openwin/lib -lXext -lX11"; - } + $mesa_include = $mesa_include . " -I/usr/openwin/include"; + if ($config_lp64) { + $mesa_library = $mesa_library . " -L/usr/openwin/lib/sparcv9"; + $mesa_libs = "-lMesaGL -L/usr/openwin/lib/sparcv9 -lXext -lX11"; + } else { + $mesa_library = $mesa_library . " -L/usr/openwin/lib"; + $mesa_libs = "-lMesaGL -L/usr/openwin/lib -lXext -lX11"; + } } if ($config_arch eq "SOLARISX86" || $config_arch eq "SOLARISX86_64") { - if ($config_gcc) { - if ($config_lp64) { - die "No LP64 gcc for this platform currently.\n"; - } - $arch_ccpp = "g++"; - $arch_cc = "gcc"; + if ($config_gcc) { + if ($config_lp64) { + die "No LP64 gcc for this platform currently.\n"; + } + $arch_ccpp = "g++"; + $arch_cc = "gcc"; # XXX gcc/g++ 2.95 and newer need -fpermissive since the X11 headers # on Solaris (and other systems) are broken and still assume that missing # types will default to int.... When they fix this in future revs of Solaris, # we can remove this flag. See: http://gcc.gnu.org/fom_serv/cache/25.html - $arch_opt_flag = "-Wall -Wno-unknown-pragmas -O -fpermissive"; - $arch_copts = "-Wall -Wno-unknown-pragmas -O"; - $arch_debug_flag = "-g"; - $arch_depend_flag = "-M"; - } else { - # Using Sun's compilers - if ($config_lp64) { - print "Configured for a 64-bit build.\n"; - $arch_ccpp = "CC -D__EXTENSIONS__"; - $arch_cc = "cc -D__EXTENSIONS__"; - if ($config_pthreads) { - $arch_opt_flag = "-mt -fast -xO5 -xarch=native64"; - $arch_copts = "-mt -fast -xO5 -xarch=native64"; - } else { - $arch_opt_flag = "-fast -xO5 -xarch=native64"; - $arch_copts = "-fast -xO5 -xarch=native64"; - } - $arch_debug_flag = "-g"; - $arch_depend_flag = "-xM"; - - if ($config_cuda) { - # This is a hack since we don't have a unified nvcc front-end install yet - $arch_nvcc = "/usr/local/cuda/bin/nvcc"; - $arch_nvccflags .= " -m64 -O3 -I/usr/local/cuda/include"; - $cuda_libs = "-lcudart"; - $cuda_library = "-L/usr/local/cuda/lib"; - } - } else { - print "Configured for a 32-bit build.\n"; - $arch_ccpp = "CC -D__EXTENSIONS__"; - $arch_cc = "cc -D__EXTENSIONS__"; - if ($config_pthreads) { - $arch_copts = "-mt -fast -xO3 -native"; - $arch_opt_flag = "-mt -fast -xO2 -native"; - } else { - $arch_copts = "-fast -xO3 -native"; - $arch_opt_flag = "-fast -xO2 -native"; - } - $arch_debug_flag = "-g"; - $arch_depend_flag = "-xM"; - } - } + $arch_opt_flag = "-Wall -Wno-unknown-pragmas -O -fpermissive"; + $arch_copts = "-Wall -Wno-unknown-pragmas -O"; + $arch_debug_flag = "-g"; + $arch_depend_flag = "-M"; + } else { + # Using Sun's compilers + if ($config_lp64) { + print "Configured for a 64-bit build.\n"; + $arch_ccpp = "CC -D__EXTENSIONS__"; + $arch_cc = "cc -D__EXTENSIONS__"; + if ($config_pthreads) { + $arch_opt_flag = "-mt -fast -xO5 -xarch=native64"; + $arch_copts = "-mt -fast -xO5 -xarch=native64"; + } else { + $arch_opt_flag = "-fast -xO5 -xarch=native64"; + $arch_copts = "-fast -xO5 -xarch=native64"; + } + $arch_debug_flag = "-g"; + $arch_depend_flag = "-xM"; + + if ($config_cuda) { + # This is a hack since we don't have a unified nvcc front-end install yet + $arch_nvcc = "/usr/local/cuda/bin/nvcc"; + $arch_nvccflags .= " -m64 -O3 -I/usr/local/cuda/include"; + $cuda_libs = "-lcudart"; + $cuda_library = "-L/usr/local/cuda/lib"; + } + } else { + print "Configured for a 32-bit build.\n"; + $arch_ccpp = "CC -D__EXTENSIONS__"; + $arch_cc = "cc -D__EXTENSIONS__"; + if ($config_pthreads) { + $arch_copts = "-mt -fast -xO3 -native"; + $arch_opt_flag = "-mt -fast -xO2 -native"; + } else { + $arch_copts = "-fast -xO3 -native"; + $arch_opt_flag = "-fast -xO2 -native"; + } + $arch_debug_flag = "-g"; + $arch_depend_flag = "-xM"; + } + } # if compiling on Solaris 10, use this setting instead. - $arch_cppopts = ""; + $arch_cppopts = ""; # $arch_cppopts = $arch_no_math_float; - if ($config_static) { - $arch_lopts = "-Bstatic -lsocket -lnsl"; - } else { - $arch_lopts = "-lsocket -lnsl -ldl"; - } - - $opengl_dep_dir = "/usr/openwin"; - $opengl_dep_include = "-I$opengl_dep_dir/include"; - if ($config_lp64) { - $opengl_dep_library = "-L$opengl_dep_dir/lib/amd64"; - $opengl_dep_libs = "-lGL -lX11 -lXext"; - } else { - $opengl_dep_library = "-L$opengl_dep_dir/lib"; - $opengl_dep_libs = "-lGL -lX11 -lXext"; - } - - $mesa_include = $mesa_include . " -I/usr/openwin/include"; - if ($config_lp64) { - $mesa_library = $mesa_library . " -L/usr/openwin/lib/amd64"; - $mesa_libs = "-lMesaGL -L/usr/openwin/lib/amd64 -lXext -lX11"; - } else { - $mesa_library = $mesa_library . " -L/usr/openwin/lib"; - $mesa_libs = "-lMesaGL -L/usr/openwin/lib -lXext -lX11"; - } + if ($config_static) { + $arch_lopts = "-Bstatic -lsocket -lnsl"; + } else { + $arch_lopts = "-lsocket -lnsl -ldl"; + } + + $opengl_dep_dir = "/usr/openwin"; + $opengl_dep_include = "-I$opengl_dep_dir/include"; + if ($config_lp64) { + $opengl_dep_library = "-L$opengl_dep_dir/lib/amd64"; + $opengl_dep_libs = "-lGL -lX11 -lXext"; + } else { + $opengl_dep_library = "-L$opengl_dep_dir/lib"; + $opengl_dep_libs = "-lGL -lX11 -lXext"; + } + + $mesa_include = $mesa_include . " -I/usr/openwin/include"; + if ($config_lp64) { + $mesa_library = $mesa_library . " -L/usr/openwin/lib/amd64"; + $mesa_libs = "-lMesaGL -L/usr/openwin/lib/amd64 -lXext -lX11"; + } else { + $mesa_library = $mesa_library . " -L/usr/openwin/lib"; + $mesa_libs = "-lMesaGL -L/usr/openwin/lib -lXext -lX11"; + } } if ($config_arch eq "WIN32") { - if ($config_msvc) { - $arch_ccpp = "cl.exe"; - $arch_cc = "cl.exe"; - $arch_opt_flag = "/O2 /G5 /nologo /MT /DWIN32 -Dstrcasecmp=strupcmp"; - $arch_debug_flag = "-g"; - $arch_depend_flag = "-M"; - $arch_copts = ""; - $arch_cppopts = "/TP"; - $arch_coptout = "/Fo"; - } else { - $arch_ccpp = "g++"; - $arch_cc = "gcc"; - $arch_opt_flag = "-O"; - $arch_debug_flag = "-g"; - $arch_depend_flag = "-M"; - $arch_copts = ""; - $arch_cppopts = $arch_no_math_float; - } - - $def_imageviewer="explorer %s"; - # startup command script file. Read after program initialization. - $startupfilename="vmd.rc"; - $pystartupfilename="pyvmd.rc"; + if ($config_msvc) { + $arch_ccpp = "cl.exe"; + $arch_cc = "cl.exe"; + $arch_opt_flag = "/O2 /G5 /nologo /MT /DWIN32 -Dstrcasecmp=strupcmp"; + $arch_debug_flag = "-g"; + $arch_depend_flag = "-M"; + $arch_copts = ""; + $arch_cppopts = "/TP"; + $arch_coptout = "/Fo"; + } else { + $arch_ccpp = "g++"; + $arch_cc = "gcc"; + $arch_opt_flag = "-O"; + $arch_debug_flag = "-g"; + $arch_depend_flag = "-M"; + $arch_copts = ""; + $arch_cppopts = $arch_no_math_float; + } + + $def_imageviewer="explorer %s"; + # startup command script file. Read after program initialization. + $startupfilename="vmd.rc"; + $pystartupfilename="pyvmd.rc"; } if ($config_arch eq "WIN64") { - $arch_ccpp = "g++"; - $arch_cc = "gcc"; - $arch_opt_flag = "-O"; - $arch_debug_flag = "-g"; - $arch_depend_flag = "-M"; + $arch_ccpp = "g++"; + $arch_cc = "gcc"; + $arch_opt_flag = "-O"; + $arch_debug_flag = "-g"; + $arch_depend_flag = "-M"; - $arch_copts = ""; - $arch_cppopts = $arch_no_math_float; - $def_imageviewer="explorer %s"; - # startup command script file. Read after program initialization. - $startupfilename="vmd.rc"; + $arch_copts = ""; + $arch_cppopts = $arch_no_math_float; + $def_imageviewer="explorer %s"; + # startup command script file. Read after program initialization. + $startupfilename="vmd.rc"; } @@ -3389,21 +3400,14 @@ if ($config_arch eq "WIN64") { # purify. # if ($config_ccache) { - $arch_ccpp = "ccache " . $arch_ccpp; - $arch_cc = "ccache " . $arch_cc; + $arch_ccpp = "ccache " . $arch_ccpp; + $arch_cc = "ccache " . $arch_cc; } -# -# if purify is enabled, add it before the normal command lines. -# -if ($config_purify) { - if ($config_lp64) { - $arch_ccpp = "purify -ptr64 " . $arch_ccpp; - $arch_cc = "purify -ptr64 " . $arch_cc; - } else { - $arch_ccpp = "purify " . $arch_ccpp; - $arch_cc = "purify " . $arch_cc; - } + +if ($config_sanitize && ($config_gcc || $config_clang)) { + $arch_opt_flag .= " -fsanitize=address "; + $arch_copts .= " -fsanitize=address "; } @@ -3412,20 +3416,20 @@ if ($config_purify) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $year += 1900; $config_date = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")[$mon] . - " $mday, $year"; + " $mday, $year"; $config_version_msg = - "VMD for $config_arch, version $progversion ($config_date)"; + "VMD for $config_arch, version $progversion ($config_date)"; ## Bypass making config.h if VMD_NO_CONFIG is set # This is helpful if you are debugging the configure script since # a lot of files depend on config.h, so even minimal changes # (like the date change for the version) causes a major recompile. if (!defined $ENV{'VMD_NO_CONFIG'}) { - open(OUTFILE, ">src/config.h") || + open(OUTFILE, ">src/config.h") || die "Cannot open config.h: $!\n"; - print OUTFILE <doc/vmd_version.txt") || - die "Cannot open vmd_version.txt: $!\n"; + die "Cannot open vmd_version.txt: $!\n"; print OUTFILE ("Build version: " . $progversion . "\n"); close(OUTFILE); ########################### Make vmd_version.tex #################### open(OUTFILE, ">doc/vmd_version.tex") || - die "Cannot open vmd_version.tex: $!\n"; + die "Cannot open vmd_version.tex: $!\n"; print OUTFILE ('\newcommand{\VMDNAME} {' . "vmd" . "}\n"); print OUTFILE ('\newcommand{\VMDDATE} {' . $config_date . "}\n"); print OUTFILE ('\newcommand{\VMDVER} {' . $progversion . "}\n"); @@ -3508,29 +3512,29 @@ close(OUTFILE); @VMD_PTX = (); sub create_config_option { - local($param) = $_[0]; - local($if_statement) = ''; - $if_statement =<src/$vmd_src_dir/Makefile") || - die "Cannot open $vmd_src_dir/Makefile: $!\n"; + die "Cannot open $vmd_src_dir/Makefile: $!\n"; print OUTFILE<> run_vmd_tmp ; \\ - \$(ECHO) 'defaultvmddir=/usr/lib/vmd' >> run_vmd_tmp ; \\ - \$(ECHO) 'vmdbasename=vmd' >> run_vmd_tmp ; \\ - cat $vmd_bin_sh >> run_vmd_tmp ; \\ - chmod +x run_vmd_tmp ; \\ - \$(COPY) run_vmd_tmp "$install_bin_dir"/$install_name ; \\ - \$(DELETE) run_vmd_tmp + \$(ECHO) "Info: /bin/csh shell not found, installing Bourne shell startup script instead" ; \\ + \$(ECHO) '#!/bin/sh' >> run_vmd_tmp ; \\ + \$(ECHO) 'defaultvmddir=/usr/lib/vmd' >> run_vmd_tmp ; \\ + \$(ECHO) 'vmdbasename=vmd' >> run_vmd_tmp ; \\ + cat $vmd_bin_sh >> run_vmd_tmp ; \\ + chmod +x run_vmd_tmp ; \\ + \$(COPY) run_vmd_tmp "$install_bin_dir"/$install_name ; \\ + \$(DELETE) run_vmd_tmp \$(ECHO) Make sure "$install_bin_dir"/$install_name is in your path. \$(ECHO) "VMD installation complete. Enjoy!" @@ -3873,46 +3877,46 @@ clean: veryclean: clean \$(CD) $vmd_arch_dir ; \\ - \$(DELETE) $config_progname + \$(DELETE) $config_progname \$(CD) $vmd_src_dir ; \\ - \$(DELETE) *.ptx *.o *.lst *.a *~ core; \\ - \$(DELETE) $config_progname + \$(DELETE) *.ptx *.o *.lst *.a *~ core; \\ + \$(DELETE) $config_progname \$(CD) $vmd_doc_dir ; \\ - \$(DELETE) *~ core + \$(DELETE) *~ core # The '/usr/include' stuff is to reduce checking /usr/include dates depend: y.tab.h if [ "\$(DEPEND)" != "" ]; then \\ echo "Building Makefile dependencies"; \\ - \$(ECHO) "Creating " \$(DEPENDFILE) " ..."; \\ - if [ -f \$(DEPENDFILE) ]; then \\ - \$(MOVE) -f \$(DEPENDFILE) \$(DEPENDFILE).old; \\ + \$(ECHO) "Creating " \$(DEPENDFILE) " ..."; \\ + if [ -f \$(DEPENDFILE) ]; then \\ + \$(MOVE) -f \$(DEPENDFILE) \$(DEPENDFILE).old; \\ fi; \\ - touch \$(DEPENDFILE); \\ + touch \$(DEPENDFILE); \\ for i in ZZZ \$(VMD_CCPP) ; do \\ - if [ "\$\$i" != "ZZZ" ]; then \\ - \$(ECHO) checking dependencies for \$\$i ...; \\ - \$(CCPP) \$(DEPEND) \$(CPPFLAGS) \$\$i | \\ + if [ "\$\$i" != "ZZZ" ]; then \\ + \$(ECHO) checking dependencies for \$\$i ...; \\ + \$(CCPP) \$(DEPEND) \$(CPPFLAGS) \$\$i | \\ sed -e 's/\\/usr\\/include\\/[^ ]*\\..//g' \\ - -e 's/\\.\\.\\/lib\\/.*\\/[^ ]*\\..//g' | \\ + -e 's/\\.\\.\\/lib\\/.*\\/[^ ]*\\..//g' | \\ grep -v '^ *\\\\\$\$' >> \$(DEPENDFILE) ; \\ - fi; \\ + fi; \\ done; \\ for i in ZZZ \$(VMD_CC) ; do \\ - if [ "\$\$i" != "ZZZ" ]; then \\ - \$(ECHO) checking dependencies for \$\$i ...; \\ - \$(CC) \$(DEPEND) \$(CFLAGS) \$\$i | \\ + if [ "\$\$i" != "ZZZ" ]; then \\ + \$(ECHO) checking dependencies for \$\$i ...; \\ + \$(CC) \$(DEPEND) \$(CFLAGS) \$\$i | \\ sed -e 's/\\/usr\\/include\\/[^ ]*\\..//g' \\ - -e 's/\\.\\.\\/lib\\/.*\\/[^ ]*\\..//g' | \\ + -e 's/\\.\\.\\/lib\\/.*\\/[^ ]*\\..//g' | \\ grep -v '^ *\\\\\$\$' >> \$(DEPENDFILE) ; \\ - fi; \\ + fi; \\ done; \\ \$(ECHO) ParseTree.o AtomLexer.o AtomParser.o: y.tab.h \\ - >> \$(DEPENDFILE); \\ + >> \$(DEPENDFILE); \\ \$(COPY) \$(DEPENDFILE) \$(DEPENDFILE).$config_arch ; \\ else \\ - \$(ECHO) "Cannot find dependencies; your compiler does not support dependency checking."; \\ - fi + \$(ECHO) "Cannot find dependencies; your compiler does not support dependency checking."; \\ + fi @@ -3922,10 +3926,10 @@ depend: y.tab.h include Makedata.depend EOM - ; + ; close(OUTFILE); if (! -d $config_arch) { - `mkdir $config_arch`; + `mkdir $config_arch`; }