简体   繁体   中英

Compatibility issues on GLSL fragment shaders

I have found a few times differences between GPUs handling fragment shaders. One example was doing pow(x) where x is negative. One GPU handled it well while the other one failed.

Another situation was where I rewrote if() statements with step() statement and shader worked well. I blamed this to branching limit or something.

Now I am in situation where my fragment shader works on some GPUs and on some don't. I have tried to search for GPU/shader limits and similar information but found nothing.

The very current test which works everywhere I tried except on my GTX 780 is here online(Shadertoy)

I am asking for any directions or a link to shader limitations and most common issues in compatibility.

Shader limitations and specification, are vendor-specific, and are changing along with the GPU architecture versions.

Simply put, there's no unified way to "rule them all". Certain GPUs handle branching differently, some better, some worse. Some GPUs allow negative values in math functions, some don't. It quite depends on the architecture that's been used, version of the shading language and instructions that are allowed in the compiled version of the shader.

Instead of reading and trying to learn what works on which card, it's best to try/test shader on the specific GPU. That's probably the most reasonable decision regarding the resources spent trying to "fix the issue".

To answer the question directly, there's no (easy-to-find) resource which lists entire specification of the compiler used on the specific architecture, you simply follow tips'n'trick learned along the way and apply suggestions and observations made by others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM