Legacy GM Fast access to surface data possible?


Hello everyone.

I am currently attempting to write a wrapper DLL of sorts for OpenVR in order to use the HTC Vive with GameMaker.

So far I am able to push rendered data from a GameMaker surface onto the HMD by passing the color data in a u8 BGRA-formatted buffer which I can then pass into an OpenGL texture. The problem is that the only way I can see to pass this surface data into the DLL is through a buffer, and the only way to put the surface data into the buffer is by calling buffer_get_surface(). As you can imagine, copying all the data from two 1080 x 1200 surfaces into two buffers 90 times a second takes a serious toll on the CPU. I'm on a Skylake i5-6600 and it drops from several thousand FPS to about 130 FPS thanks to these two calls alone.

I admit this is not a very elegant method but I am unsure of how else I can go about this. Is there a faster way to get the raw data of a surface into the DLL? Is there any way of accessing the surface data directly? I cannot think of any, although all suggested alternatives are worth a look.

Anyway, any ideas and/or brainstorming on the issue would be greatly appreciated. Cheers.