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