This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Will data precision affect uniform block layout?

Hello,

I am using std140 for Uniform Block Layout, I defined a simple uniform block like below:

on the cpu side, I defined the structure like
MyTestStruct {
Vector4 FinalColor1;

Vector4 FinalColor2;

Vector4 ColorIndex;

Vector4 FinalColor3;

}

I tested mediump data precision in the shader and It works on my android phone with MaliG76. but I don't known if this is valid on all mali gpu.

layout(binding = 0, std140) uniform MyTestBlock {
mediump vec4 FinalColor1;
mediump vec4 FinalColor2;
mediump vec4 ColorIndex;
mediump vec4 FinalColor3;
};

Will there be a default highp->mediump conversion? If Yes, is it on every shader execution or is there a special optimization?

Thanks!

Parents
  • Hi cloud_zero, 

    The standard GLSL data types are always 32-bit in uniform/storage memory; the precision qualifier only impacts the shader interpretation of the data. Mali can convert precision on load, so there is no overhead here.

    If you always want narrower types in memory you need the following extensions:

    • GL_EXT_shader_16bit_storage
    • VK_KHR_16bit_storage (core in Vulkan 1.1)

    Cheers,
    Pete

Reply
  • Hi cloud_zero, 

    The standard GLSL data types are always 32-bit in uniform/storage memory; the precision qualifier only impacts the shader interpretation of the data. Mali can convert precision on load, so there is no overhead here.

    If you always want narrower types in memory you need the following extensions:

    • GL_EXT_shader_16bit_storage
    • VK_KHR_16bit_storage (core in Vulkan 1.1)

    Cheers,
    Pete

Children