Can UBOs be stored in registers?

Greetings,

I have a GLSL shaders that uses arrays. According to the shader editor, the array entries are currently stored in sh (shared?) registers.
My question is: If I switch to UBOs that are not larger than the current arrays, will the data still be handed over via registers?

Regards

1 Like

Hi,

I tried out what you suggested using PVRShaderEditor.

the ubo version:
#version 310 es
precision mediump float;
out vec4 fragmentColor;

layout (std140) uniform ubo
{
vec4 color1;
} ubo1;

void main()
{
fragmentColor = ubo1.color1;
}

results in:
0 : mov i0.e0.e1.e2.e3, sh2
1 : f16mad(WAS:sopmad0) r1.f16.f16.e0, i0, 0.oneminus, 0.neg
f16mad(WAS:sopmad1) r1.f16.f16.e1, sh3, 0.oneminus, 0.neg
f16mad(WAS:sopmad2) r0.f16.f16.e0, sh0, 0.oneminus, 0.neg
f16mad(WAS:sopmad3) r0.f16.f16.e1, sh1, 0.oneminus, 0.neg

the uniform version:
#version 310 es
precision mediump float;
out vec4 fragmentColor;

uniform vec4 color;

void main()
{
fragmentColor = color;
}

results in:
0 : mov i0.e0.e1.e2.e3, sh2
1 : f16mad(WAS:sopmad0) r1.f16.f16.e0, i0, 0.oneminus, 0.neg
f16mad(WAS:sopmad1) r1.f16.f16.e1, sh3, 0.oneminus, 0.neg
f16mad(WAS:sopmad2) r0.f16.f16.e0, sh0, 0.oneminus, 0.neg
f16mad(WAS:sopmad3) r0.f16.f16.e1, sh1, 0.oneminus, 0.neg

as you can see the generated code is identical. I suppose the compiler will try to fit UBOs into shared registers until it has enough space.

bests,
Marton

2 Likes

It seems like with the compiler built into PVRShader editor the limit is
255 * vec4
eg.
uniform vec4 color[255];
or
layout (std140) uniform ubo
{
vec4 color1[255];
} ubo1;

1 Like

© Imagination Technologies Limited. All rights reserved.
Privacy PolicyTerms & ConditionsTrademarksCookies