Sign in to follow this  

Alpha blending fails unless Debug mode

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

SOLVED

 

Compiling with visual studio 2010...

 

If Compiling in DEBUG mode with D3D11_CREATE_DEVICE_DEBUG set for device creation, alpha blending works fine.

If Compiling in DEBUG mode with D3D11_CREATE_DEVICE_DEBUG NOT set for device creation, alpha blending works fine.

If Compiling in RELEASE mode with D3D11_CREATE_DEVICE_DEBUG set for device creation, alpha blending works fine.

If Compiling in RELEASE mode with D3D11_CREATE_DEVICE_DEBUG NOT set for device creation, alpha blending does not work... looks like alpha testing.

D3D11_BLEND_DESC oBlendStateDesc;

oBlendStateDesc.AlphaToCoverageEnable = 0;
oBlendStateDesc.IndependentBlendEnable = 0;

for (unsigned int a = 0; a < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++a)
{
	oBlendStateDesc.RenderTarget[a].BlendEnable = 1;
	oBlendStateDesc.RenderTarget[a].SrcBlend = D3D11_BLEND_SRC_ALPHA;
	oBlendStateDesc.RenderTarget[a].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
	oBlendStateDesc.RenderTarget[a].BlendOp = D3D11_BLEND_OP_ADD;
	oBlendStateDesc.RenderTarget[a].SrcBlendAlpha = D3D11_BLEND_ONE;
	oBlendStateDesc.RenderTarget[a].DestBlendAlpha = D3D11_BLEND_ONE;
	oBlendStateDesc.RenderTarget[a].BlendOpAlpha = D3D11_BLEND_OP_ADD;
	oBlendStateDesc.RenderTarget[a].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
}

HRESULT HResult = m_poDevice->CreateBlendState(&oBlendStateDesc, &m_poBlendState); //HResult returns S_OK

Anyone have any idea what may be causing this?

 

UPDATE: Tested on two different PC's... Both windows 7 64 bit, one has a GTX 460 & the other is a GTX 580. The one with the GTX 580 does not have any problems with alpha blending.

 

SOLVED: There was an initialized variable in there somewhere and I can only assume creating in debug mode caught the error. Another difference between the two tested machines is the visual studio version. So perhaps the later version machine (gtx 580) caught the error also.

Edited by reaperrar

Share this post


Link to post
Share on other sites

 

Desc.RenderTarget[a].DestBlendAlpha = HZBLENDVALUE_ONE;

 

What's HZBLENDVALUE_ONE supposted to be?

Typo in the post, not in the code... my bad. Edited

Share this post


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