Jump to content
  • Advertisement
Sign in to follow this  

Odd D3D9 bug

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

Hey guys, so I have a very strange bug that is driving me nuts.

Check out this shot rendered with D3D10. This is what it should look like:


Okay, now here it is in D3D9


Now, ignoring the text difference (that's a different issue), notice in D3D9 the alpha blending is not working properly. So, okay, I figured I'd track it down in Pix. But when I ran it in Pix, it looked like the D3D10 version! Which is to say, the blending worked fine. However, when I run it in the MSVC IDE or straight from the exe file, it looks like the screenshot. So Pix isn't helping me (which is what is very strange about this).

So without Pix to help me, I'm not sure where to look. Do you guys have any idea?

This is my code for blending in D3D9 (minus error checking):

//we don't have blend states in D3D9, so set render state to include an alpha blend
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_BLENDOPALPHA, D3DBLENDOP_ADD);
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_ALPHABLENDENABLE, true);

compared to what I do for D3D10:

BlendDesc.AlphaToCoverageEnable = false;
for (unsigned int i=0; i<8; i++)
BlendDesc.BlendEnable = false;
BlendDesc.RenderTargetWriteMask = D3D10_COLOR_WRITE_ENABLE_ALL;
BlendDesc.BlendEnable[0] = true;
BlendDesc.BlendOp = D3D10_BLEND_OP_ADD;
BlendDesc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
BlendDesc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA;
BlendDesc.DestBlendAlpha = D3D10_BLEND_ZERO;
BlendDesc.SrcBlend = D3D10_BLEND_SRC_ALPHA;
BlendDesc.SrcBlendAlpha = D3D10_BLEND_ONE;

static_cast<ID3D10Device1*>(Device)->CreateBlendState(&BlendDesc, reinterpret_cast<ID3D10BlendState**>(BlendState));

So, what do you think? What else should I look at here?

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!