【问题标题】:How to disable Metal Compiler Warnings when calling newLibraryWithSource调用 newLibraryWithSource 时如何禁用金属编译器警告
【发布时间】:2021-11-19 12:25:44
【问题描述】:

我在 C++ 应用程序中使用 id<MTLLibrary> shaderLib = [myMetalDevice newLibraryWithSource:source options:options error:&error]; 在运行时编译金属着色器。

我在日志中收到很多关于未使用变量的类似消息:

[Metal Compiler Warning] Warning: Compilation succeeded with: 

program_source:61:14: warning: unused variable 'myVariableName'
    float4x4 myVariableName;

有没有办法抑制这些警告? 如果可能,我想忽略具有特定警告类型的消息。 禁用 Metal API ValidationDebug executable 没有帮助(即使在 Release 中)。

以下是我找到的相关线索,但没有答案:

Arkit/SceneKit on iOS 14 throws new Warning (Metal)

https://developer.apple.com/forums/thread/659856

https://developer.apple.com/documentation/metal/mtldevice/1433431-newlibrarywithsource

我目前在 macOS Big Sur 11.5 上使用 xcode 12.5。

【问题讨论】:

    标签: xcode metal


    【解决方案1】:

    启用此选项会导致忽略所有警告。 MTL_IGNORE_WARNINGS, -W

    【讨论】:

    • 这个环境变量是否只能在特定机器上的开发中工作?
    • @RamilKudashev 你能详细说明一下吗?
    • 是的,据我了解,MTL_IGNORE_WARNINGS 是我可以在构建和启动应用程序时在我的机器上设置的东西。但是,如果我在某个构建代理上构建应用程序并在其他设备上启动应用程序,我该如何设置它?还是我在着色器编译之前在运行时设置的?
    • 我在 xcode 构建设置中尝试了 MTL_IGNORE_WARNINGS, -W 作为构建设置:用户定义,但没有成功。还找到了这些文档:xcodebuildsettings.com/#category-metal-opencl
    猜你喜欢
    • 2018-08-31
    • 2023-01-24
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多