gpt4 book ai didi

ios - 在 iOS Metal 中执行(支持的) float 纹理写入时出错

转载 作者:行者123 更新时间:2023-11-29 10:26:02 24 4
gpt4 key购买 nike

当我尝试从内核写入浮点纹理时,出现错误:

/SourceCache/AcceleratorKit/AcceleratorKit-17.7/ToolsLayers/Debug/MTLDebugComputeCommandEncoder.mm:596: failed assertion `Non-writable texture format MTLPixelFormatR32Float is being bound at index 2 to a shader argument with write access enabled.'

但是,当我查看文档时,该格式是可渲染的颜色和可写的函数(见底部的表格):

https://developer.apple.com/library/prerelease/ios/documentation/Metal/Reference/MetalConstants_Ref/index.html#//apple_ref/c/tdef/MTLPixelFormat

部分代码:

// texture creation
MTLTextureDescriptor *floatTextureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR32Float width:_width height:_height mipmapped:NO];
_myFloatTexture = [self.device newTextureWithDescriptor:floatTextureDescriptor];

// texture binding
[computeCommandEncoder setTexture:_myFloatTexture atIndex:2];

// texture used in the shader
void kernel myKernel(//...
texture2d<float, access::write> myFloats [[ texture(2) ]],
uint2 gid [[ thread_position_in_grid ]])

我是不是做错了什么或者这可能是一个错误?

最佳答案

只有 iOS 9 支持它们。

关于ios - 在 iOS Metal 中执行(支持的) float 纹理写入时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32259454/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com