compiles on robins computer :)
This commit is contained in:
parent
db1b1a60ca
commit
c65af95a66
|
|
@ -11,3 +11,4 @@ data/
|
||||||
|
|
||||||
# Resulting images
|
# Resulting images
|
||||||
*.ppm
|
*.ppm
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ include_directories(${CMAKE_SOURCE_DIR}/include/imgui)
|
||||||
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} ${IMGUI_FILES})
|
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} ${IMGUI_FILES})
|
||||||
|
|
||||||
# CUDA has specific architectures - set it to the system's architecture if available (or 70 by default)
|
# CUDA has specific architectures - set it to the system's architecture if available (or 70 by default)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES 70)
|
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES 52)
|
||||||
set_target_properties(${PROJECT_NAME}
|
set_target_properties(${PROJECT_NAME}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
CUDA_SEPARABLE_COMPILATION ON
|
CUDA_SEPARABLE_COMPILATION ON
|
||||||
|
|
@ -59,8 +59,8 @@ find_package(CUDA REQUIRED)
|
||||||
include_directories("${CUDA_INCLUDE_DIRS}")
|
include_directories("${CUDA_INCLUDE_DIRS}")
|
||||||
|
|
||||||
# netcdf
|
# netcdf
|
||||||
find_package(netCDF REQUIRED)
|
# find_package(netCDF REQUIRED)
|
||||||
message(STATUS "Found netcdf in ${GLFW3_INCLUDE_DIR}")
|
# message(STATUS "Found netcdf in ${NETCDF_LIB}")
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND nc-config --includedir
|
COMMAND nc-config --includedir
|
||||||
|
|
@ -74,9 +74,16 @@ execute_process(
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ncxx4-config --prefix
|
||||||
|
OUTPUT_VARIABLE NETCDFCXX_PREFIX_DIR
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories(cuda-raytracer PUBLIC ${netCDF_INCLUDE_DIR})
|
target_include_directories(cuda-raytracer PUBLIC ${netCDF_INCLUDE_DIR})
|
||||||
|
|
||||||
find_library(NETCDF_LIB NAMES netcdf-cxx4 netcdf_c++4 PATHS ${NETCDFCXX_LIB_DIR} NO_DEFAULT_PATH)
|
find_library(NETCDF_LIB NAMES netcdf-cxx4 netcdf_c++4 PATHS ${NETCDFCXX_LIB_DIR} ${NETCDFCXX_PREFIX_DIR}/lib NO_DEFAULT_PATH)
|
||||||
|
message(STATUS "Found NetCDFCXX in ${NETCDF_LIB}")
|
||||||
|
|
||||||
set(LIBS ${GLFW3_LIBRARY} ${OPENGL_LIBRARY} GLAD ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${NETCDF_LIB})
|
set(LIBS ${GLFW3_LIBRARY} ${OPENGL_LIBRARY} GLAD ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${NETCDF_LIB})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
with import <nixpkgs> { config.allowUnfree = true; };
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "cuda-raytracer";
|
||||||
|
src = ./.;
|
||||||
|
nativeBuildInputs = with cudaPackages; [cmake autoAddDriverRunpath autoPatchelfHook ];
|
||||||
|
buildInputs = with pkgs; with cudaPackages; [ libGL glfw netcdf netcdfcxx4 cuda_nvcc cuda_cudart cuda_cccl libcurand];
|
||||||
|
|
||||||
|
postConfigure = ''
|
||||||
|
export netCDFCxx_DIR=${netcdfcxx4}/lib/cmake/netCDFCxx
|
||||||
|
'';
|
||||||
|
|
||||||
|
installTargets = "preinstall";
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp cuda-raytracer $out/bin
|
||||||
|
'';
|
||||||
|
|
||||||
|
LD_LIBRARY_PATH="/run/opengl-driver/lib/";
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
#include "consts.h"
|
#include "consts.h"
|
||||||
|
#include "cuda_error.h"
|
||||||
|
|
||||||
// ----------------------- Colour mapping -----------------------
|
// ----------------------- Colour mapping -----------------------
|
||||||
__constant__ ColorStop d_stopsPythonLike[5];
|
__device__ __constant__ ColorStop d_stopsPythonLike[5];
|
||||||
__constant__ ColorStop d_stopsGrayscale[2];
|
__device__ __constant__ ColorStop d_stopsGrayscale[2];
|
||||||
__constant__ ColorStop d_stopsBluePurleRed[3];
|
__device__ __constant__ ColorStop d_stopsBluePurleRed[3];
|
||||||
|
|
||||||
const ColorStop h_stopsPythonLike[] = {
|
const ColorStop h_stopsPythonLike[] = {
|
||||||
{ 0.0f, Color3::init(0.2298057f, 0.29871797f, 0.75368315f) }, // Dark Blue
|
{ 0.0f, Color3::init(0.2298057f, 0.29871797f, 0.75368315f) }, // Dark Blue
|
||||||
|
|
@ -37,8 +38,10 @@ Vec3 h_cameraUp = Vec3::init(0.0, 1.0, 0.0).normalize();
|
||||||
|
|
||||||
// Copy the above values to the device
|
// Copy the above values to the device
|
||||||
void copyConstantsToDevice() {
|
void copyConstantsToDevice() {
|
||||||
|
check_cuda_errors(cudaGetLastError());
|
||||||
// ----------------------- Colour mapping -----------------------
|
// ----------------------- Colour mapping -----------------------
|
||||||
cudaMemcpyToSymbol(d_stopsPythonLike, h_stopsPythonLike, sizeof(h_stopsPythonLike));
|
cudaMemcpyToSymbol(d_stopsPythonLike, h_stopsPythonLike, sizeof(h_stopsPythonLike));
|
||||||
|
check_cuda_errors(cudaGetLastError());
|
||||||
cudaMemcpyToSymbol(d_stopsGrayscale, h_stopsGrayscale, sizeof(h_stopsGrayscale));
|
cudaMemcpyToSymbol(d_stopsGrayscale, h_stopsGrayscale, sizeof(h_stopsGrayscale));
|
||||||
cudaMemcpyToSymbol(d_stopsBluePurleRed, h_stopsBluePurleRed, sizeof(h_stopsBluePurleRed));
|
cudaMemcpyToSymbol(d_stopsBluePurleRed, h_stopsBluePurleRed, sizeof(h_stopsBluePurleRed));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
#include "input/Widget.h"
|
#include "input/Widget.h"
|
||||||
|
#include "cuda_error.h"
|
||||||
|
|
||||||
|
|
||||||
// TODO: Delete
|
// TODO: Delete
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ void Quad::cuda_init(float* data) {
|
||||||
|
|
||||||
|
|
||||||
void Quad::render() {
|
void Quad::render() {
|
||||||
|
check_cuda_errors(cudaGetLastError());
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
this->renderer->render();
|
this->renderer->render();
|
||||||
glBindTexture(GL_TEXTURE_2D, this->tex);
|
glBindTexture(GL_TEXTURE_2D, this->tex);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ void Widget::tick(double fps) {
|
||||||
this->renderOnce = true;
|
this->renderOnce = true;
|
||||||
}
|
}
|
||||||
sprintf(this->fps, "%.3f fps\n", fps);
|
sprintf(this->fps, "%.3f fps\n", fps);
|
||||||
ImGui::Text(this->fps);
|
ImGui::Text("%s", this->fps);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
ImGui::Begin("Camera Controls");
|
ImGui::Begin("Camera Controls");
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,8 @@ Raycaster::Raycaster(cudaGraphicsResource_t resources, int w, int h, float* data
|
||||||
|
|
||||||
|
|
||||||
void Raycaster::render() {
|
void Raycaster::render() {
|
||||||
|
std::cout << "hello???\n";
|
||||||
|
check_cuda_errors(cudaGetLastError());
|
||||||
check_cuda_errors(cudaGraphicsMapResources(1, &this->resources));
|
check_cuda_errors(cudaGraphicsMapResources(1, &this->resources));
|
||||||
check_cuda_errors(cudaGraphicsResourceGetMappedPointer((void**)&(this->fb->buffer), &(this->fb->buffer_size), resources));
|
check_cuda_errors(cudaGraphicsResourceGetMappedPointer((void**)&(this->fb->buffer), &(this->fb->buffer_size), resources));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ static float* d_volume = nullptr;
|
||||||
// * time controls - arbitrary skipping to specified point (would require some changes to gpubuffer) (could have)
|
// * time controls - arbitrary skipping to specified point (would require some changes to gpubuffer) (could have)
|
||||||
|
|
||||||
void getTemperature(std::vector<float>& temperatureData, int idx = 0) {
|
void getTemperature(std::vector<float>& temperatureData, int idx = 0) {
|
||||||
std::string path = "data/trimmed";
|
std::string path = "../../../hurricane-sandy-data";
|
||||||
// std::string path = "data";
|
// std::string path = "data";
|
||||||
std::string variable = "T";
|
std::string variable = "T";
|
||||||
DataReader dataReader(path, variable);
|
DataReader dataReader(path, variable);
|
||||||
|
|
@ -31,7 +31,7 @@ void getTemperature(std::vector<float>& temperatureData, int idx = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getSpeed(std::vector<float>& speedData, int idx = 0) {
|
void getSpeed(std::vector<float>& speedData, int idx = 0) {
|
||||||
std::string path = "data/trimmed";
|
std::string path = "../../../hurricane-sandy-data";
|
||||||
// std::string path = "data";
|
// std::string path = "data";
|
||||||
std::string varU = "U";
|
std::string varU = "U";
|
||||||
std::string varV = "V";
|
std::string varV = "V";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue