作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于我不需要在计算中优化浮点运算,我该如何在 swift 中将 fastMathEnabled 设置为 false?
最佳答案
如果您希望它应用于由 Xcode 编译并包含在默认库中的所有着色器,您可以将选项 -fno-fast-math 添加到 MTL_COMPILER_FLAGS(其他 Metal 编译器标志) 在 Xcode build设置中设置。来源:Apple Metal Shading Language Specification .
如果您在运行时编译着色器,则将选项传递给 MTLDevice makeLibrary function :
let device = MTLCreateSystemDefaultDevice()!
let options = MTLCompileOptions()
options.fastMathEnabled = false
try device.makeLibrary(source: source, options: options)
其中 source
是包含您要编译的着色器源代码的字符串。
关于swift - 设置 fastMathEnabled 以便在 swift 中进行精确计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51375608/
由于我不需要在计算中优化浮点运算,我该如何在 swift 中将 fastMathEnabled 设置为 false? 最佳答案 如果您希望它应用于由 Xcode 编译并包含在默认库中的所有着色器,您可
我是一名优秀的程序员,十分优秀!