Jump to content
  • Advertisement
Sign in to follow this  
vicviper

question about creating render targets

This topic is 4888 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

I've notice in some of the SDK samples that create render target textures, specifically the CubeMap sample, that when they create the texture, they try first with the D3DUSAGE_RENDERTARGET flag, but if it fails, it tries again with the USAGE set to 0. this is the exact line of code copied from the cubemap.cpp:

// Create the cubemap, with a format that matches the backbuffer
    if( m_d3dCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP )
    {
        if( FAILED( D3DXCreateCubeTexture( m_pd3dDevice, CUBEMAP_RESOLUTION, 1,
            D3DUSAGE_RENDERTARGET, m_d3dsdBackBuffer.Format, D3DPOOL_DEFAULT, &m_pCubeMap ) ) )
        {
            if( FAILED( D3DXCreateCubeTexture( m_pd3dDevice, CUBEMAP_RESOLUTION, 1,
                0, m_d3dsdBackBuffer.Format, D3DPOOL_DEFAULT, &m_pCubeMap ) ) )
            {
                m_pCubeMap = NULL;
            }
        }
    }



After that, I haven't noticed any difference in the rest of the code, depending in the creation method of the texture... it looks like it doesn't care at all if it was created with D3DUSAGE_RENDERTARGET or not... the only important thing looks to be that the color format must much the ones of the swap chain. On a side note, on modern video cards, it is still required that all render targets (back,depth, and textures) must match color and depth format?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Mezz
I can't find that in the SDK samples, where is it?

-Mezz



dx9sdk\Samples\C++\Direct3D\EnvMapping\CubeMap\cubemap.cpp

you'll find the piece of code arround line 580.

Also, I recall to seeing that way of creating the render targets this way in other SDK samples.

Share this post


Link to post
Share on other sites
It looks like we've not got the same version of the DirectX SDK because I don't have that sample, I'm using the DX9 December 2004 Update which doesn't contain it. It has a HDR cubemap sample but it does proper checks for D3DUSAGE_RENDERTARGET and if it's not supported then it fails, it doesn't just create it anyway.

-Mezz

Share this post


Link to post
Share on other sites
Quote:
Original post by vicviper
After that, I haven't noticed any difference in the rest of the code, depending in the creation method of the texture... it looks like it doesn't care at all if it was created with D3DUSAGE_RENDERTARGET or not... the only important thing looks to be that the color format must much the ones of the swap chain.


For some reason, the Shared Source code center is down right now. When it's working again, I'll find out exactly what is going on with the D3DUSAGE_RENDERTARGET flag.

Share this post


Link to post
Share on other sites
According to the documentation of IDirect3DDevice9::SetRenderTarget:
Quote:
The new render-target surface must have at least D3DUSAGE_RENDERTARGET specified.


Quote:
On a side note, on modern video cards, it is still required that all render targets (back,depth, and textures) must match color and depth format?

According to the same documentation page:
Quote:

Restrictions for using this method include the following:

- The multisample type must be the same for the render target and the depth stencil surface.
- The formats must be compatible for the render target and the depth stencil surface. See IDirect3D9::CheckDepthStencilMatch.
- The size of the depth stencil surface must be greater than or equal to the size of the render target.


I got this page by searching for "D3DUSAGE_RENDERTARGET" - you should really, really, really always check the documentation [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!