Modifying ComputeBuffer using GetNativeBufferPtr from native code

Hi All,

I am having problems accessing a compute buffer in the native code in 5.5.0f3.

I have modified the latest native plugin example from Unity (https://bitbucket.org/Unity-Technologies/graphicsdemos),
which modifies the vertex buffer, to do the same with my compute buffer, but it does not work:

void* RenderAPI_D3D11::BeginModifyBuffer(void* bufferHandle, int count, int stride)
{

    ID3D11Buffer* d3dbuf = (ID3D11Buffer*)bufferHandle;
    assert(d3dbuf);

   D3D11_BUFFER_DESC desc;

        //desc is filled properly, but the usage type is D3D11_USAGE_DEFAULT (0) and the CPUAccesFlags is 0
   //in the vertex buffer case it is D3D11_USAGE_DYNAMIC (2) and CPUAccesFlags != 0
  d3dbuf->GetDesc(&desc);

    ID3D11DeviceContext* ctx = NULL;
 
  m_Device->GetImmediateContext(&ctx);
 
   D3D11_MAPPED_SUBRESOURCE mapped;
   
   //hr is  E_INVALIDARG One or more arguments are invalid.  
   HRESULT hr = ctx->Map(d3dbuf, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
   
    ctx->Release();

    //pData is null
    return mapped.pData;
}

I tried creating the buffer with different ComputeBufferType but it does not seem to change anything.

Thanks for your help

OK, I have tried exactly same things with OpenGL and it worked fine out of the box.

void* RenderAPI_OpenGLCoreES::BeginModifyBuffer(void* bufferHandle, int count, int stride)
{
    glBindBuffer(GL_ARRAY_BUFFER, (GLuint)(size_t)bufferHandle);
    GLint size = 0;
    glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);

    void* mapped = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
    return mapped;
}

Seems like a bug in Unity and Dx11?