http://webglstats.com/ seems to not have information on what percentage of devices/browsers support highp in the fragment shader.
Most sources report that highp won't work on older mobile hardware, and this SO post seems to indicate that most Intel GPUs (back in 2011) don't support it. I'm guessing the vast majority of hardware nowadays support it but I'm looking for some hard numbers.
Supporting highp in fragment shaders is optional in OpenGL ES 2.0, mandatory in OpenGL ES 3.0, so a quick and dirty way to be sure it to check if the device support OpenGL ES 3.0. For that reason there is still a vast amount of mid-end mobile hardware out there which doesn't support OpenGL ES 3.0 and does not implement the optional highp support (Mali-300/400/450 GPUs do not support it, for example).
Pretty much all desktop hardware can support OpenGL 4.0 so tends to have highp in fragment shaders (not aware of anything vagely recent which doesn't).
Related
I had GLSL shaders working fine with #version 150 core. The vertex shader outputted gl_PointSize to a triangle strip geometry shader, which uses this to indicate the size of generated objects.
I changed to #version 300 es and got this error
error C7548: 'gl_PointSize' requires "#extension GL_EXT_geometry_point_size : enable" before use
This is mildly surprising -- I thought extensions were normally something you needed in older versions to enable functionality which is provided in later versions. Now it seems like I need to recover something which was lost, but this table seems to say that I can still use it.
What has changed which means I can't use gl_PointSize any more?
Desktop OpenGL and OpenGL ES are not the same thing. That table references desktop OpenGLx, not OpenGL ES of any version. If you ask for GLSL 3.00 ES, you will get GLSL 3.00 ES.
Desktop GLSL 1.50 is not a lesser version of GLSL ES 3.00. Nor is it a greater version. They have no relationship to each other, except in the sense that the ES versions take stuff from the desktop versions. But even that is arbitrary, generally unrelated to version numbers.
The thing is... OpenGL ES 3.00 does include gl_PointSize. But it is only as an output variable from the VS. Assuming that's how your shader uses it, your implementation has a bug in its OpenGL ES support.
Is it possible to force a GPU to use highp floats in shaders when the OpenGL version being used is 2.0? I know that precision modifiers are basically a GLES concept, but floats do seem to use mediump by default on a desktop I was provided for testing, and it`s driving me nuts.
I`ve stumbled across that problem while running my GL project under Win10 with a GTX1070 GPU (driver version 23.21.13-9135). I don`t even have #version set in my shaders, so I expected the precision to be automatically maxed out.
AFAIK, OpenGL 2.x standard does not define any ways to hint the GPU that at least 20 of 24 mantissa bits are significant (passing integers through floats, since GL 2.0 cannot operate on integers natively), but that`s the first time in 3++ years that I`ve seen a desktop GPU do such a thing, so I`ve never even thought it possible.
Help needed.
I am developing a framework using OpenGL ES to create 3D applications.
I need to deploy the framework in both PowerVR and Mali GPUs chip-sets.
Is there any aspects to be taken care in programming OpenGL ES for different GPUs (PowerVR and Mali)?
The only significant difference is that the older Mali cores (Mali-300/400 series) only support mediump in the fragment shader, so algorithms relying on highp precision won't work there.
There are surely fine tuning differences, but hard to give a succinct answer to that one. Just focus on writing good clean GL and it should work well everywhere.
I have a simple vertex shader:
precision mediump float;
attribute vec4 position;
attribute vec4 color;
varying vec4 f_color;
uniform mat4 projection;
uniform mat4 modelView;
void main(void) {
gl_Position = projection * modelView * position;
f_color = color;
f_texCoord = texCoord;
}
This fails to compile, stating (using getShaderInfoLog()):
ERROR: 0:1: 'precision' : syntax error syntax error
It compiles fine if i remove the line with the precision specifier.
System:
OS: Mac OX 10.9.2
GPU: NVIDIA GeForce 320M 256 MB
GLSL Ver.: 1.20
Someone help me out.
You have already figured out how to solve your problem: just remove the line with the precision qualifier.
The bigger issue is that you haven't decided what version of OpenGL you are using. The GLSL sample you provided seems to be for an old version of the GLSL associated with OpenGL ES, which is designed for mobile devices. Since you are actually running on a desktop/laptop, you want "normal" OpenGL. The error you observed is a result of the differences between the two.
In general you want to go with the latest version of OpenGL that is support by the systems you are targeting. Right now that is probably OpenGL 3.3 (along with GLSL 3.3).
The precision keyword is a OpenGL/ES extension. Since you have no #version in your vertex shader, you are getting GLSL v1.1 (backwards compatible with OpenGL2.0), which doesn't support such GL/ES extensions.
Either remove the precision line (which probably does nothing on desktop GL anyways), or add a #version for some version of GLSL that supports precision.
Precision qualifiers in OpenGL 3.3 are redundant. From the OpenGL 3.3 spec, "Precision qualifiers are added for code portability with OpenGL ES, not for functionality. They have the same syntax as in OpenGL ES, as described below, but they have no semantic meaning, which includes no effect on the precision used to store or operate on variables".
Use #version 330 core for strict 3.3 with no backward compatibility. And lose the precision qualifiers if you don't need ES compatibility.
I know it is common for mobile phones to not support 'precision highp float' in fragment shaders, but are there any desktop or laptop GPUs that don't support it? In other words, if I'm only writing my shader code for use in desktop/laptop scenarios, do I really need to do this conditional stuff recommended in the OpenGL ES 2.0 book?
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
Or can I just stick with declaring it 'highp' and be done with it?
Most Intel GPUs don't support it; so that would be most of the laptop market. I don't know what the story is with AMD, and as far as NVIDIA cards go, GeForce 8 series and earlier won't work.