当我尝试从内核写入浮点纹理时,我收到错误:
/SourceCache/AcceleratorKit/AcceleratorKit-17.7/ToolsLayers/Debug/MTLDebugComputeCommandEncoder.mm:596:断言失败`不可写纹理格式MTLPixelFormatR32Float在索引2处绑定到启用了写访问权限的着色器参数。'
然而,当我去检查文档时,该格式是可着色的和可写入功能的(参见底部的表格):
部分代码:
// 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 ]])
我做错了什么或者这可能是个错误?
答案 0 :(得分:2)
仅iOS 9支持它们。