Sign in to follow this  
chiyuwang

Question about surface

Recommended Posts

Surfaces are the basic storage mechanism for pixel data in Direct3D. You can't render from them directly.

Textures are collections of 1 or more surfaces (usually in descending sizes according to mip-maps). You can render directly from these.

Render targets are just specializations of surfaces in that you're more restricted with what you can/can't do with them. Fundamentally they are the same thing behind the scenes.


hth
Jack

Share this post


Link to post
Share on other sites
offscreen surfaces are surfaces that can be used to display 2D images in 2D drawings as with the obsolete DirectDraw. But one also refers to rendering to a pixel storage that is not (yet) visible on the screen.

textures are also 2D images (well they can also be 1D or 3D) but you can glue them onto 3D objects in 3D scenes adding more detail to your objects without adding more 3D triangles to actually model all those details.

render targets are pixel storages you can render a 3D scene to. This is also called offscreen rendering because the rendered image is not immediately visible on the screen (as opposed to rendering to the original back buffer). The beauty of render targets is that you can apply post processing effects to them such as blur before showing them on the screen. You can also get a texture from a render target and glue that on your 3D objects.

Share this post


Link to post
Share on other sites
Render target surfaces must be in POOL_DEFAULT. These surfaces are the only type that allow anti-aliasing. Use StretchRect to copy the data from the AA surface to a texture surface for later use. If you're not using AA, you might be better off rendering to a texture surface directly to avoid the copy. These surfaces are the kind that are made for your device or swapchain backbuffer.

Texture surfaces cannot use AA. You can create render target textures, which are pretty much the same as render target surfaces, aside from the AA restriction. Non render target surfaces can be in the managed pool (most common case), where D3D takes care of restoring them when the device is lost. Texture surfaces can also be in the systemmem pool, where they can be used to prepare data for UpdateSurface, or UpdateTexture calls. Surfaces in the scratch pool are surfaces which the GPU cannot ever see. These don't have to follow any of the device caps restrictions, making them useful for processing without worry about hardware support.

Offscreen plain surfaces can be in pool default or scratch. Plain pool default surfaces can be locked, modified, and used in StretchRect calls.

Share this post


Link to post
Share on other sites

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