Sign in to follow this  
RonHiler

Odd D3D9 bug

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:

[img]http://www.rjcyberware.com/Enzyme/ScreenShots/D3D10Render.png[/img]

Okay, now here it is in D3D9

[img]http://www.rjcyberware.com/Enzyme/ScreenShots/D3D9Render.png[/img]

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):

[code]
//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);
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE,true);
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_SRCBLENDALPHA,D3DBLEND_ONE);
static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_DESTBLENDALPHA,D3DBLEND_ZERO);
[/code]

compared to what I do for D3D10:
[code]
BlendDesc.AlphaToCoverageEnable = false;
for (unsigned int i=0; i<8; i++)
{
BlendDesc.BlendEnable[i] = false;
BlendDesc.RenderTargetWriteMask[i] = 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));
[/code]

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

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