improved cuda error checking

This commit is contained in:
djaidjai committed 2025-01-06 13:18:19 +01:00
1 parent edf4d9fd60
commit 04defb563f
5 files changed
+46 -88

No files matched your search

+1 -1
View File
@@ -119,7 +119,7 @@ void Window::tick() {
glfwSwapBuffers(this->window);
glfwPollEvents();
std::cout << "done ticking";
std::cout << "done ticking\n";
}
+7 -27
View File
@@ -1,5 +1,6 @@
#include "Quad.h"
#include "cuda_error.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "cuda_runtime.h"
@@ -71,22 +72,12 @@ void Quad::make_fbo(){
}
Quad::~Quad() {
int res = cudaGraphicsUnregisterResource(CGR);
if (res) {
std::cout << "CUDA error while deregistering the graphics resource: " << res;
cudaDeviceReset();
exit(1);
}
check_cuda_errors(cudaGraphicsUnregisterResource(CGR));
};
void Quad::cuda_init(float* data) {
int res = cudaGraphicsGLRegisterBuffer(&this->CGR, this->PBO, cudaGraphicsRegisterFlagsNone);
if (res) {
std::cout << "CUDA error while registering the graphics resource: " << res;
cudaDeviceReset();
exit(1);
}
check_cuda_errors(cudaGraphicsGLRegisterBuffer(&this->CGR, this->PBO, cudaGraphicsRegisterFlagsNone));
this->renderer = std::make_unique<Raycaster>(this->CGR, this->w, this->h, data);
};
@@ -117,21 +108,10 @@ void Quad::resize(unsigned int w, unsigned int h) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (this->renderer != nullptr) {
// TODO: probably make a function for the cuda error checking
int res = cudaGraphicsUnregisterResource(CGR);
if (res) {
std::cout << "CUDA error while deregistering the graphics resource: " << res;
cudaDeviceReset();
exit(1);
}
check_cuda_errors(cudaGraphicsUnregisterResource(CGR));
check_cuda_errors(cudaGraphicsGLRegisterBuffer(&this->CGR, this->PBO, cudaGraphicsRegisterFlagsNone));
res = cudaGraphicsGLRegisterBuffer(&this->CGR, this->PBO, cudaGraphicsRegisterFlagsNone);
if (res) {
std::cout << "CUDA error while registering the graphics resource: " << res;
cudaDeviceReset();
exit(1);
}
this->renderer->resources = this->CGR;
this->renderer->resize(w, h);
this->renderer->resources = this->CGR;
this->renderer->resize(w, h);
}
};
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.