2
\$\begingroup\$

I thought I read somewhere that one could create a 'offscreen plain surface' from an existing system memory buffer, but I cannot seem to find the reference anymore.

My use case is copying a frame from video memory to a pre-allocated buffer, and right now I perform this in two steps: copying to an 'offscreen plain surface' (GetRenderTargetData), and from that to a pre-allocated buffer. If I could create the surface from the pre-allocated buffer, it would save a copy. I am using Direct3D9Ex on Windows 7.

\$\endgroup\$
1
  • \$\begingroup\$ Perhaps you were thinking of DirectDraw? DirectDraw's surface creation methods implied you could create one with pre-allocated bits (that it would probably copy), although I've never tried it and I'm not sure it would work. \$\endgroup\$
    – user1430
    Jun 19, 2014 at 15:55

1 Answer 1

1
\$\begingroup\$

There are no overloads for CreateOffscreenPlainSurface that take a pre-allocated memory buffer.

D3D will generally want to own the memory its resources, for various reasons. Even methods that accept "user" data pointers, like DrawPrimitivesUP tend to guarantee that the data referred to by the user pointer has been "completely accessed" by the time the function returns, which allows for the API to copy the data if needed.

If there was such a method of creating a surface with a pointer to the surface bits, you wouldn't actually avoid the copy by using it. You'd just avoid having to write the copy yourself; D3D would do it internally.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .