- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否允许在发散流控制之后但在发散流控制之外使用 barrier()
?
在兼容 OpenGL 4.00 的计算着色器中,我正在做一些涉及发散(即非动态统一)分支语句的工作。稍后在同一个着色器中,我需要同步该工作组内所有调用的执行,以便进行内存访问。这也有利于提高效率,因为我希望它们都能彼此保持同步。然而,在查阅了 khronos.org wiki 和 refpages 后,我不清楚我想做的事情是否符合标准(无论它在实践中是否有效)。
来自this page ,我们看到:
Calls to barrier may not be placed within any control flow.
来自this page ,我们看到:
barrier()
can be called from flow-control, but it can only be called from uniform flow control. All expressions that lead to the evaluation of abarrier()
must be dynamically uniform.
首先,流量控制方面存在明显的矛盾。我假设它只是不允许的发散(工作组内)流量控制?
其次,在我看来,关于在发散流量控制之后发生的对 barrier()
的调用存在一些歧义。重要的是,请再次注意“所有导致对barrier()求值的表达式必须是动态统一的”这一断言。这是否意味着导致,或者……?一些例子可以帮助说明我的困惑。
void main() {
// ... do some work here ...
barrier(); // valid use case
// ... do some more work ...
}
void main() {
if (IS_BEST_WORK_GROUP) { // dynamically uniform within work group
// ... do some work here ...
barrier(); // valid use case
// ... do some more work ...
}
}
void main() {
if (IS_BEST_INVOCATION) { // divergent within work group
// ... do some work here ...
barrier(); // this is illegal
// ... do some more work ...
}
}
void main() {
if (IS_BEST_INVOCATION) { // divergent within work group
// ... do some work here ...
}
barrier(); // is this allowed?
// it occurs after, but outside of, a divergent branch statement
// ... do some more work ...
}
最佳答案
唯一的声明来源是 GLSL Specification .
第 8.16 节规定:
For tessellation control shaders, the barrier() function may only be placed inside the function main() of the tessellation control shader and may not be called within any control flow. [...]
For compute shaders, the barrier() function may be placed within flow control, but that flow control must be uniform flow control.
您的示例 4 非常好,因为对 barrier
的调用不在任何控制流中。只要确保所有着色器调用都到达相同的障碍,在障碍之前做什么并不重要。
关于OpenGL Barrier() 函数和发散流控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48657248/
在 Nsight Visual Studio 中,我们将有一个图表来呈现“已采取”、“未采取”和“分歧”分支的统计信息。我对“不采取”和“分歧”之间的区别感到困惑。例如 kernel() { if
在 Nsight Visual Studio 中,我们将有一个图表来呈现“已采取”、“未采取”和“分歧”分支的统计信息。我对“不采取”和“分歧”之间的区别感到困惑。例如 kernel() { if
我想提交并将其复制到我的存储库中的其他地方。 现状: A--B--C--D (branch1) \ E--F (branch2) 期望的情况: A--B--C--D--F'(bran
以下一系列 git 命令导致 repos 出现分歧。我究竟做错了什么? 来自 GitLab 的 Fork 项目 call the parent project 'upstream' 从 fork 项目
我是一名优秀的程序员,十分优秀!