I believe the main problem its here, in the mapping procedure:
Class: https://github.com/neroziros/PSDX11/blob/master/Particleclass.cpp
I hope my code can also help anyone else interested in building a million particle system based on the GPU :) Cheers
// CPU PARTICLE CREATION
// Add new particles if they were created
if (!newParticlesCreated)
{
// Map to the buffer and render the new particles to add them to the pipeline
D3D11_MAPPED_SUBRESOURCE mappedResource;
PARTICLE_VERTEX* dataPtr;
m_D3D->GetDeviceContext()->Map(g_pNewParticles, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
dataPtr = (PARTICLE_VERTEX*)mappedResource.pData;
// Copy the data into the vertex buffer.
memcpy(dataPtr, (void*)newParticlesArr, (sizeof(PARTICLE_VERTEX)* emissionRate));
// Unmap the buffer
m_D3D->GetDeviceContext()->Unmap(g_pNewParticles, 0);
// Set the buffer as the input
pBuffers[0] = g_pNewParticles;
UINT stride[1] = { sizeof(PARTICLE_VERTEX) };
UINT offset[1] = { 0 };
m_D3D->GetDeviceContext()->IASetVertexBuffers(0, 1, pBuffers, stride, offset);
m_D3D->GetDeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
// Point to the correct output buffer
pBuffers[0] = g_pParticleStreamTo;
m_D3D->GetDeviceContext()->SOSetTargets(1, pBuffers, offset);
// Draw the buffers
D3DX11_TECHNIQUE_DESC techDesc;
g_pAdvanceParticles->GetDesc(&techDesc);
for (UINT p = 0; p < techDesc.Passes; ++p)
{
g_pAdvanceParticles->GetPassByIndex(p)->Apply(0, m_D3D->GetDeviceContext());
m_D3D->GetDeviceContext()->DrawAuto();
}
// Get back to normal
pBuffers[0] = NULL;
m_D3D->GetDeviceContext()->SOSetTargets(1, pBuffers, offset);
// Free the particle array memory
delete (newParticlesArr);
// Reset variables
newParticlesCreated = false;
}