Skip to content

GetUniformLocation() returns -1 on Nvidia #2153

@bamfbamf

Description

@bamfbamf

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
  1. 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.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions