Summary
Querying location of uniforms returns -1 on laptop Nvidia RTX 3050 dedicated GPU, while returns proper location on laptop Intel iGPU.
Steps to reproduce
- Platform: Desktop
- Framework Version: .NET 6.0 and bigger
- API: OpenGL
- API Version: OpenGL 4.5 Core and bigger
- This is the problematic shader: https://gist.github.com/bamfbamf/84ef909a0ec214002ec5bc7f03fdafd0
It's a standalone shader that will draw infinite grid. It required empty VAO without any attachments to work.
- Instead of setting location directly in
Uniform1() method, query location of NEAR_PLANE & FAR_PLANE with GetUniformLocation() and use it's value for location. Check what value it returns.
Comments
All my extension methods for my shader first query location with GetUniformLocation() and use its returned value to set uniform methods (Uniform1() etc.) location value. They will error out if location is not found (-1). And this works perfectly fine on Intel iGPU, locations are found and returned/set properly. While I force windows to use RTX, then GetUniformLocation fails with -1. Just for those two uniforms.
I tried to pack those uniforms into vec2 and set it, but this also fails. There are other float uniforms there, like gridOpacity etc. and for them GetUniformLocation() return proper locations on NVidia too.
So I made method that doesn't query location and I set NEAR_PLANE & FAR_PLANE location directly, just like layout(location = 3) and layout(location = 4) points to. And this works. Changing value of uniforms affects the shader. So the uniforms are working properly. GetUniformLocation() simply fails to get their location on NVidia.
Summary
Querying location of uniforms returns
-1onlaptop Nvidia RTX 3050dedicated GPU, while returns proper location on laptop Intel iGPU.Steps to reproduce
It's a standalone shader that will draw infinite grid. It required empty VAO without any attachments to work.
Uniform1()method, query location ofNEAR_PLANE&FAR_PLANEwithGetUniformLocation()and use it's value for location. Check what value it returns.Comments
All my extension methods for my shader first query location with
GetUniformLocation()and use its returned value to set uniform methods (Uniform1() etc.) location value. They will error out if location is not found (-1). And this works perfectly fine on Intel iGPU, locations are found and returned/set properly. While I force windows to use RTX, thenGetUniformLocationfails with-1. Just for those two uniforms.I tried to pack those uniforms into
vec2and set it, but this also fails. There are other float uniforms there, likegridOpacityetc. and for themGetUniformLocation()return proper locations onNVidiatoo.So I made method that doesn't query location and I set
NEAR_PLANE&FAR_PLANElocation directly, just likelayout(location = 3)andlayout(location = 4)points to. And this works. Changing value of uniforms affects the shader. So the uniforms are working properly.GetUniformLocation()simply fails to get their location onNVidia.