diff --git a/include/neural-graphics-primitives/common.h b/include/neural-graphics-primitives/common.h index a4a2c057354621e525062c1077608d684af67c40..6e2b1e4b3c6c23603f032f5b077ca8b1be6ad881 100644 --- a/include/neural-graphics-primitives/common.h +++ b/include/neural-graphics-primitives/common.h @@ -63,6 +63,8 @@ NGP_NAMESPACE_BEGIN +bool is_wsl(); + filesystem::path get_executable_dir(); filesystem::path get_root_dir(); diff --git a/src/common.cu b/src/common.cu index 2ee41f12ecd6c6763711aa7f74fdc5b2dc7b8efd..a0b43891de843397f8f7aa86d560a79fc9033d5e 100644 --- a/src/common.cu +++ b/src/common.cu @@ -28,6 +28,21 @@ namespace fs = filesystem; NGP_NAMESPACE_BEGIN +bool is_wsl() { +#ifdef _WIN32 + return false; +#else + fs::path path = "/proc/sys/kernel/osrelease"; + if (!path.exists()) { + return false; + } + + std::ifstream f{path.str()}; + std::string content((std::istreambuf_iterator<char>(f)), (std::istreambuf_iterator<char>())); + return content.find("microsoft") != std::string::npos; +#endif +} + fs::path get_executable_dir() { #ifdef _WIN32 WCHAR path[MAX_PATH]; diff --git a/src/render_buffer.cu b/src/render_buffer.cu index 12ab7538f0ba475ec37684d1fbc85eb944ac6123..e70aae04172219c0be70591d5d78d21fd27254d0 100644 --- a/src/render_buffer.cu +++ b/src/render_buffer.cu @@ -174,20 +174,6 @@ void GLTexture::resize(const Vector2i& new_size, int n_channels, bool is_8bit) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } -static bool is_wsl() { -#ifdef _WIN32 - return false; -#else - fs::path path = "/proc/sys/kernel/osrelease"; - if (!path.exists()) { - return false; - } - - std::ifstream f{path.str()}; - std::string content((std::istreambuf_iterator<char>(f)), (std::istreambuf_iterator<char>())); - return content.find("microsoft") != std::string::npos; -#endif -} GLTexture::CUDAMapping::CUDAMapping(GLuint texture_id, const Vector2i& size) : m_size{size} { static bool s_is_cuda_interop_supported = !is_wsl(); diff --git a/src/testbed.cu b/src/testbed.cu index c50d2694355ab7f2d6ece1621b3f1c422f4b756b..119b011f2f7691188b2f30f2d6eec883c9636d7e 100644 --- a/src/testbed.cu +++ b/src/testbed.cu @@ -2892,7 +2892,7 @@ Testbed::Testbed(ETestbedMode mode) { #ifdef NGP_GUI // Ensure we're running on the GPU that'll host our GUI. To do so, try creating a dummy // OpenGL context, figure out the GPU it's running on, and then kill that context again. - if (glfwInit()) { + if (!is_wsl() && glfwInit()) { glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL); @@ -2912,11 +2912,11 @@ Testbed::Testbed(ETestbedMode mode) { glfwTerminate(); } +#endif // Reset our stream, which was allocated on the originally active device, // to make sure it corresponds to the now active device. m_stream = {}; -#endif int active_device = cuda_device(); int active_compute_capability = cuda_compute_capability();