Programming Vertex/IndexBuffers for DeviceLost?

I read here and there that MonoGame repairs gpu data by itself upon DeviceLost. Texture2D apparently reloads itself. Is this true even when loaded from file?

I did some digging in the VertexBuffer code, but I can’t find any code that takes a ‘copy’ of the SetData() data for DeviceLost purposes, so, is MonoGame reloading the gpu data or do I have to?

VertexBuffer also doesn’t have the ContentLost event, which seems to be a convension for the things that MonoGame can’t repair by itself?


I would say, implement it regardless for that double-edged sword scenario.

You have a point. I have added such a system in the meantime, so, great minds think alike i guess :stuck_out_tongue:

I didnt use devicelost event in the end.

Each time I draw, I just check in my Mesh class’s GetVertexBuffer() if the vertexbuffer.graphicsdevice is still same as the current one. if not I recreate and repopulate the vertexbuffer for the new graphicsdevice with the data that is kept in the Mesh anyway. (its a constantly changing procedural mesh, so i need it in ram too)

Seems waterproof to me?

1 Like

's been a standard method for many engines I have come across… that being three…