Skip to content

Commit

Permalink
WinRT: d3d11 blend mode bug fixes
Browse files Browse the repository at this point in the history
The destination target's alpha wasn't getting set correctly in many cases.  Among other problems, this prevented some alpha-blended textures from displaying correctly in Windows Phone 8's multitasking screen.

The d3d11 renderer now uses the same blending settings found in the d3d9 renderer.
  • Loading branch information
DavidLudwig committed Dec 30, 2013
1 parent 910c1cd commit 44b0e90
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/render/direct3d11/SDL_render_d3d11.cpp
Expand Up @@ -663,6 +663,8 @@ D3D11_CreateBlendMode(SDL_Renderer * renderer,
BOOL enableBlending,
D3D11_BLEND srcBlend,
D3D11_BLEND destBlend,
D3D11_BLEND srcBlendAlpha,
D3D11_BLEND destBlendAlpha,
ID3D11BlendState ** blendStateOutput)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
Expand All @@ -676,8 +678,8 @@ D3D11_CreateBlendMode(SDL_Renderer * renderer,
blendDesc.RenderTarget[0].SrcBlend = srcBlend;
blendDesc.RenderTarget[0].DestBlend = destBlend;
blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
blendDesc.RenderTarget[0].SrcBlendAlpha = srcBlendAlpha;
blendDesc.RenderTarget[0].DestBlendAlpha = destBlendAlpha;
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
result = data->d3dDevice->CreateBlendState(&blendDesc, blendStateOutput);
Expand Down Expand Up @@ -934,8 +936,10 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
result = D3D11_CreateBlendMode(
renderer,
TRUE,
D3D11_BLEND_SRC_ALPHA,
D3D11_BLEND_INV_SRC_ALPHA,
D3D11_BLEND_SRC_ALPHA, /* srcBlend */
D3D11_BLEND_INV_SRC_ALPHA, /* destBlend */
D3D11_BLEND_ONE, /* srcBlendAlpha */
D3D11_BLEND_INV_SRC_ALPHA, /* destBlendAlpha */
&data->blendModeBlend);
if (FAILED(result)) {
// D3D11_CreateBlendMode will set the SDL error, if it fails
Expand All @@ -945,8 +949,10 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
result = D3D11_CreateBlendMode(
renderer,
TRUE,
D3D11_BLEND_SRC_ALPHA,
D3D11_BLEND_ONE,
D3D11_BLEND_SRC_ALPHA, /* srcBlend */
D3D11_BLEND_ONE, /* destBlend */
D3D11_BLEND_ZERO, /* srcBlendAlpha */
D3D11_BLEND_ONE, /* destBlendAlpha */
&data->blendModeAdd);
if (FAILED(result)) {
// D3D11_CreateBlendMode will set the SDL error, if it fails
Expand All @@ -956,8 +962,10 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
result = D3D11_CreateBlendMode(
renderer,
TRUE,
D3D11_BLEND_ZERO,
D3D11_BLEND_SRC_COLOR,
D3D11_BLEND_ZERO, /* srcBlend */
D3D11_BLEND_SRC_COLOR, /* destBlend */
D3D11_BLEND_ZERO, /* srcBlendAlpha */
D3D11_BLEND_ONE, /* destBlendAlpha */
&data->blendModeMod);
if (FAILED(result)) {
// D3D11_CreateBlendMode will set the SDL error, if it fails
Expand Down

0 comments on commit 44b0e90

Please sign in to comment.