从也是渲染目标的纹理中采样
我知道这在技术上不受支持(据我所知,这是未定义的行为),但是从也被写入的纹理中采样真的是一件非常可怕的事情吗?
我问这个问题是因为我需要从深度纹理中读取数据,我也需要写入该深度纹理,如果我不能这样做,这意味着我将不得不复制深度纹理,如果这没什么大不了的,我就不会这样做。没有看到简单复制它的危害吗?
感谢您的帮助!
I know this technically isn't supported (and as far as I can tell it's undefined behavior) but is it really a fatally horrible thing to sample from a texture which is also being written to?
I ask because I need to read from a depth texture which I also need to write to, if I can't do this it means I will have to copy the depth texture and if it isn't that big of a deal I don't see the harm in simply copying it?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,它是致命的并会引发未定义的行为。只需制作一份副本并从副本中读取即可。
解释很简单。由于片段以未指定的顺序并行处理,因此您可能正在从已写入的纹素或原始值纹素中读取,并且无法知道您正在读取的内容。制作副本并从中读取可确保您读取到正确的值。
Yes, it's fatal and triggers undefined behaviour. Just make a copy and read from the copy.
The explanation is simple. Since fragments are processed in parallel in a unspecified order, you might be reading from already written texels or original value texels, and there is no way of knowing what you are reading. Making a copy and reading from it ensures that you will read the correct values.
马蒂亚斯和戈兹涵盖了最重要的部分。让我添加几个有趣的事实:
Matias and Goz covered the most important bits. Let me add a couple interesting facts: