获取 MTLArgument 的函数常量索引

发布于 2025-01-14 03:32:04 字数 1185 浏览 2 评论 0原文

MTLRenderPipelineReflection 包含 MTLArgument 的列表,其中包含有关名称、索引、类型、访问等的信息,但有关函数常量绑定的任何信息除外。 有 MTLFunction 及其字典 var functionConstantsDictionary: [String : MTLFunctionConstant],由函数常量名称作为键(感觉多余,因为 MTLFunctionConstant 已经包含名称)。我没有找到任何有关使用参数的函数常量的信息。 结果应该类似于表 [FunctionArgumentName: FunctionConstant] 是否有任何有关管道的信息可以帮助计算该绑定?

UPD:

fragment float4 fragment_main(VertexOut in [[stage_in]],
                                  texture2d<float> baseColorTexture [[texture(BaseColorTexture), function_constant(hasColorTexture)]],
                                  texture2d<float> normalTexture [[texture(NormalTexture), function_constant(hasNormalTexture)]],
                                  texture2d<float> aoTexture [[texture(AOTexture), function_constant(hasAOTexture)]],
                                  texturecube<float> reflectionTextureCube [[texture(ReflectionTextureCube), function_constant(hasReflectionTextureCube)]]) {
    /// Shader code
}

换句话说,我需要从 swift 代码访问此着色器函数的 baseColorTexture 参数的函数常量名称

MTLRenderPipelineReflection contain lists of MTLArgument's that contains info about name, index, type, access, e.t.c. except any info about function constant binding.
There are MTLFunction and it's dictionary var functionConstantsDictionary: [String : MTLFunctionConstant], that keyed by function constant name(it feels excess because MTLFunctionConstant already contains name). I did not found any info about function constants that in use of argument.
As a result should be something like table [FunctionArgumentName: FunctionConstant]
Is there any info about pipeline that helps to calculate that bindings?

UPD:

fragment float4 fragment_main(VertexOut in [[stage_in]],
                                  texture2d<float> baseColorTexture [[texture(BaseColorTexture), function_constant(hasColorTexture)]],
                                  texture2d<float> normalTexture [[texture(NormalTexture), function_constant(hasNormalTexture)]],
                                  texture2d<float> aoTexture [[texture(AOTexture), function_constant(hasAOTexture)]],
                                  texturecube<float> reflectionTextureCube [[texture(ReflectionTextureCube), function_constant(hasReflectionTextureCube)]]) {
    /// Shader code
}

In other words I need to access name of function constant for baseColorTexture argument of this shader function from swift code

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文