Can I dereference and assign a value to a pointer in Metal Shader

234 Views Asked by At

I would like to dereference a pointer and assign it a value in a Metal Shader (Kernel), like so (simple example);

kernel void test_kernel()
{
    device uint64_t* ptr;
    *ptr = 1;
}

When I run this I get the following error;

Execution of the command buffer was aborted due to an error during execution. 
Caused GPU Hang Error (00000003:kIOGPUCommandBufferCallbackErrorHang)

This is caused by the line, *ptr = 1.

Am I missing something here? Can you dereference a device pointer in Metal Shader?

0

There are 0 best solutions below