1

Now I can get backbuffer pointer called pBackBuffer by

m_pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, 
    IREF_GETPPTR(pBackBuffer,IDirect3DSurface9));

And then create a surface called pSurfTemp in syetem memory by

m_pDevice->CreateOffscreenPlainSurface(
    g_Proc.m_Stats.m_SizeWnd.cx, g_Proc.m_Stats.m_SizeWnd.cy, 
    s_bbFormat, D3DPOOL_SYSTEMMEM, 
    IREF_GETPPTR(pSurfTemp,IDirect3DSurface9), NULL );

Then I get the back buffer data by

m_pDevice->GetRenderTargetData(pBackBuffer, pSurfTemp);

Data seems transforming like this: videoMemory->systemMemory

Since next step is to operate the data in video memory again, it will copy it from system memory back into video memory. It wastes time.

I want to copy the data inside video memory, How can I do it?

feserr
  • 97
  • 1
  • 7
XLinC
  • 23
  • 5

1 Answers1

1

If I understood right, you will want to CreateOffscreenPlainSurface() with D3DPOOL_DEFAULT flag, so driver will choose appropriate memory location automatically. But it never guaranteed that it always will be videocard's on-board memory.

By the way, premature optimization is the root of all evil. =)

Edit: Another option is to switch API from DirectX 9 (which is obsolete) to DirectX 11, which allows much more precise resources manipulations. Also, OpenGL goes somewhere in between. Both, is a huge code rewrite.

Community
  • 1
  • 1
Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61
  • Yeah...I have tried it. Since [GetRenderTargetData](http://msdn.microsoft.com/en-us/library/windows/desktop/bb174405(v=vs.85).aspx) can not take a Surface created with [D3DPOOL_DEFAULT](http://msdn.microsoft.com/en-us/library/windows/desktop/bb172584%28v=vs.85%29.aspx), I used LoadSurfaceFromSurface instead. But it was even Slower. Dont know why. – XLinC Sep 14 '13 at 02:21