Multiple render targets

As mentioned in an earlier thread, I'm rendering the results of DrawText operations to textures, and then rendering these textures to the screen. However, I just noticed that this is causing problems when multisampling, making the text corrupted and producing this error message:

Direct3D9: (ERROR) :MultiSampleType between DepthStencil Buffer and RenderTarget must match.

First-chance exception at 0x7c81eb33 in Client.exe: Microsoft C++ exception: long at memory location 0x0012f38c..

Direct3D9: (ERROR) :Clear failed.

This happens at this line:

if( !SUCCEEDED( getDevice()->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 255, 255, 255 ), 1.0f, 0 ) ) )

Checking the Direct3D documentation, I came across this section under "Multiple Render Targets":

  • No antialiasing is supported.
  • What does that mean Can't I support multisampling at all in my application as long as I go with my current implementation of DrawText to texture rendering, or is there some way for me to get past this If so, how



    Answer this question

    Multiple render targets

    • Dirk Teufel

      Thanks! That solved my problem. :)
    • Kishore Babu Annavarapu

      This is the easiest case. Before you start to render your UI set the z buffer to NULL. After your UI is done set it back to the default Z buffer (Save it after device creation). Additional you have to remove the D3DCLEAR_ZBUFFER from your clear call.

    • Srikanth Baggu

      "Multiple Render Targets“ does not mean that you switch your render target multiple times. You have “Multiple Render Targets“ only in the case you write to more than one target at the same time. Direct3D 9 supports up to 4 targets. That is the reason why SetRenderTarget takes an index.

      Your problem is different. Your Z-Buffer and your render target don’t have the same numbers of samples per pixel. A texture always have only one sample per pixel and your default Z-Buffer have the number you have specified in your present date during device initialization.

      There is more than one solution for your problem depending on your requirements.

      Do you draw only text to this texture

      Do you need the Z-Buffer for this text or can you do it without

      Do you want draw your texture with multisampling too and than down sample it before using



    • cmn

      Yes, I only draw text to this texture.

      No, I don't need the Z-buffer for this text. In fact, I don't use the Z-buffer at all for my GUI needs.

      No, I'd rather not have any kind of multisampling in the GUI if possible, but limit it to just the game geometry.


    • Multiple render targets