clCreateFromD3D11BufferNV ret CL_INVALID_D3D11_RESOURCE_NV for IndirectBuffer


#1

Hi All,

I try to use OpenCL for updating indirect ID3D11buffer, but during calling clCreateFromD3D11BufferNV, i got error CL_INVALID_D3D11_RESOURCE_NV.

simple code:


D3D11_BUFFER_DESC bufDesc;
bufDesc.ByteWidth = sizeof(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS); // 20 bytes
bufDesc.Usage = D3D11_USAGE_DEFAULT;
bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_SHADER_RESOURCE;
bufDesc.MiscFlags = D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS; // Indirect Buffer
bufDesc.StructureByteStride = 0;
ID3D11Buffer* pVertexBufPtr = NULL;
HRESULT hr = hrStatus = pD3D11Device->CreateBuffer(&bufDesc, NULL, &pVertexBufPtr); // pVertexBufPtr - OK
cl_int ret = 0;
// CL_INVALID_D3D11_RESOURCE_NV
cl_mem clBuffer = clCreateFromD3D11BufferNV(context, CL_MEM_WRITE_ONLY, pVertexBufPtr, &ret);

It working fine on any AMD/Intel GPU with OpenCL 1.2 and Direct3D11 with D3D_FEATURE_LEVEL_11_X.

i attached simpe project with executable file.
https://www.dropbox.com/s/6g9gr1b0o1i0qaw/SimpleD3D11.7z?dl=0

It happens for example on nVidia GTX 760, nVidia 610

Also, i submitted this issue on nVidia forum: clCreateFromD3D11BufferNV returns CL_INVALID_D3D11_RESOURCE_NV for buffer with D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS

What do i do wrong ?


#2

Hi! I have additional Information from Direct3D11 Debug Runtime:

D3D11 ERROR: ID3D11Device::CreateBuffer: Buffers for DrawIndirect can not be created with D3D11_RESOURCE_MISC_SHARED or D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX. [ STATE_CREATION ERROR #68: CREATEBUFFER_INVALIDMISCFLAGS]
Exception thrown at 0x73C7DDC2 in SimpleDX11.exe: Microsoft C++ exception: _com_error at memory location 0x001EEA8C.
D3D11 ERROR: ID3D11Device::CreateBuffer: CreateBuffer returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #69: CREATEBUFFER_INVALIDARG_RETURN]

The new link for simple project