1
votes

When I try to write to a float texture from a kernel, I get the error:

/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.'

However, when I go check in the documentation, that format is color-renderable and function-writeable (see table at the bottom):

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

Partial code:

// 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 ]])

Am I doing something wrong or might this be a bug?

1

1 Answers

2
votes

They are supported only from iOS 9.