Persistent SSBO strange behavior when reading

Hi, I’ve been having this weird problem for days now where I have a persistent mapped SSBO that looks completely fine in renderdoc but when I try to assign its value to a variable it just gives me garbage.
I’ve tried to see if somehow the offset is wrong by checking the resulting number in binary but the test number(15) is not even present in the result.
Has anyone had the same issue?

My vertex shader looks like this

#version 440

layout(std430,binding=0) buffer D{uint C[];};

layout(location=0) in vec2 X;
layout(location=1) in vec2 U;
layout(location=2) in ivec2 I;

out vec2 UV;
out uint T;
out vec4 col;

void main() {
  vec2 P=(X-0.5f)*2.0f;
  gl_Position=vec4(P.x,P.y*-1,0.5f,1.0f);
  UV=vec2(U.x,U.y);
  T=I.r;
}

The issue happens when I store the R component from ivec2 I into a temporal out uint T.
When I is read in renderdoc it shows the ivec2 {15, 0} but when assigned it gives me the number 1097859072 for whatever reason.

I don’t see where you’re using the SSBO, so it’s unclear how that matters. Also, using real variable names instead of inscrutable characters would be a big help for knowing what’s going on.

Thanks for the reply Alfonse, I think I’ve figured it out. The problem is the way gl reads attributes since its assuming they’re floats. So when changing them to normalized and then dividing by 0xFFFF in the shader it worked.
This was seriously driving me crazy since the identical code worked in vulkan just fine.

If you want to use integer attributes, you need to use glVertexAttribIPointer (note the extra “I”).

Originally, all attributes were floats; integer attributes were added later (in OpenGL 3.0), so they added a new function to support that. Similarly, double-precision floating-point attributes (double, dvec*) require the use of glVertexAttribLPointer.

The type and normalised parameters reflect the type of the source data. The function determines the type of the shader variable.