Sign in to follow this  

how to get get backbuffer to memory?

This topic is 4245 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does GetRenderTarget work? GetRenderTarget(index,...) when I set index to 0, does it get backbuffer? if I set 1,what do I get? are there any function to get backbuffer? does GetSurfaceLevel GetRenderTarget both create a new surface? if I call GetRenderTarget ,iS new surface created?

Share this post


Link to post
Share on other sites
Quote:
Original post by derek7
Does GetRenderTarget work? GetRenderTarget(index,...) when I set index to 0, does it get backbuffer? if I set 1,what do I get?
As the name suggests, it gets you the current render target - but only a (pointer) reference to it, not the actual data. You can use it to make defensive copies or to re-use render target data. You need to call GetRenderTargetData() if you want the actual binary data.

The index is for the case where you're using MRTs - "Multiple Render Targets" (look it up in the SDK). Chances are you'll only want to use index 0 and that any other indices will cause errors.

Quote:
Original post by derek7
are there any function to get backbuffer?
GetBackBuffer() [grin]

Quote:
Original post by derek7
does GetSurfaceLevel GetRenderTarget both create a new surface?

if I call GetRenderTarget ,iS new surface created?
No, but it does increment reference counts (Be careful - these functions are easy ways of generating hard-to-find memory leaks [wink]). The SDK documentation pages will tell you what these functions do, what parameters they require etc...

As a more general tip.. if you're using Visual Studio you can use the "Find In Files" (CTRL+SHIFT+F) tool to search *all* of the SDK samples. Stick in the name of the function and it'll come back with a list of working examples that use it. You should be able to use those to work out how to implement it yourself.

hth
Jack

Share this post


Link to post
Share on other sites
thanks very much.

but

HRESULT GetRenderTargetData(
IDirect3DSurface9* pRenderTarget,
IDirect3DSurface9* pDestSurface
);


The destination surface must be either an off-screen plain surface or a level of a texture (mipmap or cube texture) created with D3DPOOL_SYSTEMMEM.

The source surface must be a regular render target or a level of a render-target texture (mipmap or cube texture) created with POOL_DEFAULT.


can I not get rendertarget to another surface?
if I get rendertarget to memory, I know it will very slow,how to speed it up?


can I read renderTarget to memory by directly reading pixel with pointer?
someting like surface->lock()

another question
what is different between rendertarget and surface?
I think surface is supperset to rendertarget. a rendertarget must be surface.

[Edited by - derek7 on April 29, 2006 11:51:54 AM]

Share this post


Link to post
Share on other sites
GetRenderTargetData is the fastest possible way. But it is still slow and that’s the reason why you should not read back data from the GPU as part of your general render strategy.

Share this post


Link to post
Share on other sites
Quote:
Original post by Demirug
GetRenderTargetData is the fastest possible way. But it is still slow and that’s the reason why you should not read back data from the GPU as part of your general render strategy.


if I want to get a list of game screen to memory (harddisk), how to make it as quickly as possible?

Share this post


Link to post
Share on other sites
Quote:
Original post by derek7
if I want to get a list of game screen to memory (harddisk), how to make it as quickly as possible?


By "list of game screen to memory", what do you mean? Just the data for a current texture/surface? If so, you're going to have to Lock/Unlock the surface, which will be quite slow (since it has to copy from GPU to CPU [and back?]), as stated above.

Share this post


Link to post
Share on other sites
Quote:
Original post by deadimp
By "list of game screen to memory", what do you mean? Just the data for a current texture/surface? If so, you're going to have to Lock/Unlock the surface, which will be quite slow (since it has to copy from GPU to CPU [and back?]), as stated above.


What was stated above was to use GetRenderTargetData, which is a lot faster than locking the render target. The slow part will be writing the data to disk.

Share this post


Link to post
Share on other sites
how to ceate a surface on d3d. I can create a texture by D3DXcreatetexture9
but where is createsurface command ?

I can not find it on google and msdn.

Share this post


Link to post
Share on other sites
Quote:
Original post by derek7
but where is createsurface command ?
IDirect3DDevice9::CreateOffscreenPlainSurface() should do the trick. There are some D3DX functions - but they're for the cases where you've already got source data or an existing surface to start with.

hth
Jack

Share this post


Link to post
Share on other sites
D3DXCreateTexture(d, 800, 600, 0, 0, D3DFMT_R8G8B8, D3DPOOL_SYSTEMMEM, &textured);

textured->GetSurfaceLevel(0,&destsurface);

D3DSURFACE_DESC desc;
destsurface->GetDesc(&desc);

desc.Height is 1024
desc.Width is 1024

why?? because of 2^n? so it must be 512x512 or 1024x1024?

could I create a 800x800 texture?

Share this post


Link to post
Share on other sites
DirectX is going to resize it to a power of 2 if it isn't already.

So, while yes you can have an 800x800 texture, as soon as you actually load it into memory - its going to become 1024 x 1024(with black pixels filling the extra area).

Share this post


Link to post
Share on other sites
Don't use the D3DX function. You can create a texture directly from the device, and it won't have this problem.

Though if you're trying to define this for using with GetRenderTargetData, just use IDirect3DDevice9::CreateOffscreenPlainSurface.

Also note that you should use the same format that the render target is in. And never use D3DFMT_R8G8B8 anywhere in your programs, because it's not supported by any card, and D3DX translates it to a usable format (probably D3DFMT_X8R8G8B8) but the device won't do that.

Share this post


Link to post
Share on other sites

This topic is 4245 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this