在iOS Metal中执行(支持的)浮点纹理写入时出错
当我尝试从内核写入浮点纹理时,会出现以下错误: /SourceCache/AcceleratorKit/AcceleratorKit-17.7/ToolsLayers/Debug/MTLDebugComputeCommandEncoder.mm:596:断言失败“索引2处的不可写纹理格式MTLPixelFormatR32Float正在绑定到启用写访问的着色器参数。” 但是,当我查看文档时,该格式是颜色可渲染且函数可写的(请参见底部的表格): 部分代码:在iOS Metal中执行(支持的)浮点纹理写入时出错,ios,textures,metal,Ios,Textures,Metal,当我尝试从内核写入浮点纹理时,会出现以下错误: /SourceCache/AcceleratorKit/AcceleratorKit-17.7/ToolsLayers/Debug/MTLDebugComputeCommandEncoder.mm:596:断言失败“索引2处的不可写纹理格式MTLPixelFormatR32Float正在绑定到启用写访问的着色器参数。” 但是,当我查看文档时,该格式是颜色可渲染且函数可写的(请参见底部的表格): 部分代码: // texture creation
// 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 ]])
//纹理创建
MTLTextureDescriptor*floatTextureDescriptor=[MTLTextureDescriptor Texture2dDescriptor WithPixelFormat:MTLPIXelFormatr32浮动宽度:_宽度高度:_高度mipmapped:NO];
_myFloatTexture=[self.device newTextureWithDescriptor:floatTextureDescriptor];
//纹理绑定
[ComputeCommandEncoderSetTexture:_myFloatTexture索引:2];
//着色器中使用的纹理
无效内核myKernel(//。。。
纹理2D myFloats[[纹理(2)],
uint2 gid[[螺纹位置在网格中]]
我是否做错了什么,或者这可能是一个bug?只有iOS 9才支持它们