Search code examples
openglglslglfwopengl-extensions

GLSL extension not available when it should be


I'm doing GPU computing on a Nvidia GeForce GTX 1050 in an ASUS RoG fx553 laptop, and for some reason, although the official Nvidia website lists this GPU as compatible with thread intrinsics instructions (GL_NV_shader_thread_group and the like), using #extension GL_NV_shader_thread_group : require constantly throws an error and reports the extension as not being available, even though I'm using a 4.3 context with #version 430 (I also tried 4.4 to no avail). Since I'm new to loading extensions, I don't know if I'm missing some setting up on the Glad/GLFW end.

EDIT : I downloaded the OpenGL extensions viewer, which went on and told me that my GPU supposedly supports GL_NV_shader_thread_group, even in an OpenGL 4.3 context.

OGLEV showing GL_NV_shader_thread_group as available under OpenGL 4.3


Solution

  • Since you mention that you're running on a laptop, I assume that this laptop also has an iGPU (e.g., an Intel GPU that's integrated into the CPU). The problem is most likely that your program is not running on the NVIDIA GPU but only on the iGPU. One solution would be to set up an application profile in the NVIDIA driver control panel to have it use the NVIDIA GPU for your application. There should also be an option to globally force the use of the NVIDIA GPU for everything (not recommended though). Another way (the one I usually use) is to add the following line of code to your program:

    extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 1U;
    

    This will export the corresponding symbol for a global variable that the driver checks for when loaded into your process. If the symbol exists and the variable is set to 1, then the driver will use the NVIDIA GPU for that particular process…