Different sampler types for same sample texture unit in fragment shader.
来源:互联网 发布:小米平板2怎么连接网络 编辑:程序博客网 时间:2024/06/17 03:43
这个问题是几个月前碰到的,现象是这样的,N卡和Intel核显上都正常的shader,跑到A卡上就出错了,使用了这个shader的物体不显示,并且提示Validation failed! - Different sampler types for same sample texture unit in fragment shader.在网络上搜索了一下,很多人说是纹理绑定出错了,一张纹理被绑定了多次,经过仔细的排查,我这里可以确定没有出现绑定错误。所以被这个问题卡了很久,好在影响不是很大。
今天又碰到了这个问题,多次测试发现是使用了sampler2DShadow对象之后才出现这个问题的,如果代码里同时使用了sampler2DShadow和sampler2D对象,且都没有绑定纹理的话,就会报这个错误,就算这些纹理的采样语句被跳过不执行,也是一样的报错。
猜测可能sampler2D跟sampler2DShadow对象的默认值是一样的,比如都是0,然后shader编译阶段并没有进行检查,运行时发现不同的采样器要对同一个纹理采样,于是导致了运行错误。
在CPU里面对所有sampler2DShadow对象显式的绑定一个值,有纹理的绑定对应的纹理层,没有纹理的就绑定一个不存在的纹理层,我用的是15. 问题解决,错误不再出现。
我这个shader是一个很大的shader,里面有不同的功能模块,根据需求决定是否启用,所以有些shader代码运行时会被IF跳过,被跳过的模块用到的纹理也就不会进行绑定,我觉得这种做法是很合理的,确定不会使用的纹理为什么还要去绑定一次啊?N卡和Intel核显上能正常运行,就A卡不行,所以这个问题要算是A卡驱动的Bug了。
- Different sampler types for same sample texture unit in fragment shader.
- 'Shader error in 'DX11/GreenScreenShader': Fragment program 'frag': sampler 'SampleType' has no matc
- Different types Server in Python
- 纹理过滤器 Texture Sampler
- For different transaction types,What's the meaning of fields in MTL_MATERIAL_TRANSACTIONS
- Different types of keystore in Java -- JKS
- Different types of keystore in Java -- PKCS12
- Different types of keystore in Java -- Overview
- Different Types of Switches in Networking
- random walk for different types of Drunks
- git diff same files in different branch
- unit shader
- How to create different types of thread pool in Java
- Different types of thread-safe Sets in Java
- Different ways of associating known types in wcf
- css define different link style in same page
- Different Readers for different file types(Tensorflow 的几种读取数据的方式)
- Unit 4: Sentence Types
- windows进程间各种通信方式浅谈
- HDU5769后缀数组的简单应用
- CXF与Spring框架的整合
- Android Studio入门到精通
- 题目274 正三角形的外界圆面积
- Different sampler types for same sample texture unit in fragment shader.
- caffe命令行解析
- POJ1459
- Java-可重入锁
- Python中的MD5
- iOS沙盒访问方式
- 策略模式(strategy)
- ImageView定宽,高度等比例放大
- Linux线程同步-----条件变量