WARNING: Calls to any function that may require a gradient calculation inside a conditional block may return undefined results

GLES2.0:

Some device will give a warning on compling shaders(yet the compling will
succeed), and the rendering result is incorrect with blink & artifacts.

the problems is gradient
calculation(interpolation) relies on the neighbor pixels,

if the neighbor pixels are not in the same
conditional branch,  the gradient will be invalid and result may be
undifed.

I guess it is an un-defined behavior, so some devices/drivers works
good, some don‘t.


1 //like this
2 if( test )
3 color = texture2D(sampler,UV);
4 else
5 color = vec4(0,0,0,0);

One workaround is use mix() or step() instead of condition test.


1 color = mix(vec4(0,0,0,0), texture2D(...), testVal);

When using condition branch, the texture
sampling may be not actually executed, which will increase graphics
performance.

One draw back on using mix/step is that the sampling is always performed,
then interpolated/multiplied.

WARNING: Calls to any function that may require a gradient
calculation inside a conditional block may return undefined results

时间: 2024-10-18 00:55:25

WARNING: Calls to any function that may require a gradient calculation inside a conditional block may return undefined results的相关文章

warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead.

使用VS2005以上版本(VS2005.VS2008.VS2010)编译在其他编译器下正常通过的C语言程序,你可能会遇到类似如下的警告提示: 引用内容warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for det

vs的【warning C4996:'fopen': This function or variable may be unsafe】解决方案

转载自:http://my.oschina.net/liujinofhome/blog/36287 以及http://blog.sina.com.cn/s/blog_562f523f0100rezj.html 二.编译警告:warning C4996 与 Security Enhancements in the CRT 将过去的工程用VS2005打开的时候.你有可能会遇到一大堆的警告:warning C4996.比如:warning C4996: 'strcpy': This function

消除: warning C4996: 'sprintf': This function or variable may be unsafe. Consider 的方法

最简单的可以用的方法: 选项Project   |   Configuration   Properties   |   C/C++   |   Preprocessor   |   Preprocessor   Definitions     添加_CRT_SECURE_NO_DEPRECATE和_SCL_SECURE_NO_DEPRECATE 消除: warning C4996: 'sprintf': This function or variable may be unsafe. Cons

VS2012 [warning C4996]: 'sprintf': This function or variable may be unsafe.

使用VS2012编译时,会出现以下警告: warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.如图: c:\program files (x86)\microsoft visual stu

warning C4996: 'sprintf': This function or variable may be unsafe

选项Project   |   Configuration   Properties   |   C/C++   |   Preprocessor   |   Preprocessor   Definitions     添加_CRT_SECURE_NO_DEPRECATE和_SCL_SECURE_NO_DEPRECATE warning C4996: 'sprintf': This function or variable may be unsafe

【VC】warning C4996: 'XXXX': This function or variable may be unsafe.

关于VS系列使用 Unicode 格式产生以上警告: warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. MSDN Generic-Text Routine Mappings TCHAR.H

warning: control reaches end of non-void function 和 warning: implicit declaration of function 'rsgClearColor' is invalid in C99

用gcc编译一个程序的时候出现这样的警告: warning: control reaches end of non-void function 它的意思是:控制到达非void函数的结尾.就是说你的一些本应带有返回值的函数到达结尾后可能并没有返回任何值.这时候,最好检查一下是否每个控制流都会有返回值. <Android应用性能优化> p202 hellorendering.rs 文件: #pragma version(1) #pragma rs java_package_name(com.len

linux系统下,警告:warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration] 和 warning: the `gets&#39; function is dangerous and should not be used. 的由来和解决方法。

字符数组 的英文名字是 char [] gets()函数的基本用法为:char *gets(char *s); 该函数的参数是一个字符数组,该函数的返回值也是一个字符数组. linux下的代码如下: 1 #include <stdio.h> 2 3 int main() 4 { 5 char a[100] = { 0 }; 6 gets(a); 7 printf("%s\n", a); 8 return 0; 9 }-----------------------------

warning: implicit declaration of function &#39;func1&#39; [-Wimplicit-function-declaration]

warning: implicit declaration of function 'func1' [-Wimplicit-function-declaration] 这个警告是因为func1函数所在的 .h 文件没有生成对应的 .o 文件,即函数所在文件没有编译.解决办法就是加上include. 如果函数func1与主函数在同一文件下,注意函数引用与函数声明的顺序. 如图所示,加引用函数之前声明,或者直接将所调用函数直接放在引用之前都可以. warning: implicit declarat