diff options
| author | Nolan Check <Nolan.Check@gmail.com> | 2010-10-20 03:11:22 +0000 |
|---|---|---|
| committer | Nolan Check <Nolan.Check@gmail.com> | 2010-10-20 03:11:22 +0000 |
| commit | cb453a0fb3209bc7753bc0dbbc36d4e07b7964e6 (patch) | |
| tree | 3e5307b38b72602c6f6c76f6156e7bcef18b995a /Source/Core | |
| parent | 479eea6ad248ecfef83968f84ca1c6659e37fe6b (diff) | |
DX11 plugin: Do destination-alpha in a single pass. No more drawing the same geometry twice! SMG is faster now because it uses destination-alpha extensively. This uses dual-source color blending, a DirectX 10-level feature. The equivalent OpenGL function comes from the GL_ARB_blend_func_extended extension, which was made core in OpenGL 3.3.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6294 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/Src/LinearDiskCache.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 22 |
2 files changed, 18 insertions, 6 deletions
diff --git a/Source/Core/Common/Src/LinearDiskCache.cpp b/Source/Core/Common/Src/LinearDiskCache.cpp index 37dfb8a69a..25665257ab 100644 --- a/Source/Core/Common/Src/LinearDiskCache.cpp +++ b/Source/Core/Common/Src/LinearDiskCache.cpp @@ -22,7 +22,7 @@ static const char ID[4] = {'D', 'C', 'A', 'C'}; // Update this to the current SVN revision every time you change shader generation code. // We don't automatically get this from SVN_REV because that would mean regenerating the // shader cache for every revision, graphics-related or not, which is simply annoying. -const int version = 6267; +const int version = 6294; LinearDiskCache::LinearDiskCache() : file_(NULL), num_entries_(0) { diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index e528c6a1b3..7b638a1cbd 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -521,7 +521,7 @@ const char *GeneratePixelShaderCode(bool dstAlphaEnable, API_TYPE ApiType,u32 co if(ApiType != API_D3D11) WRITE(p, " out float4 ocol0 : COLOR0,%s\n in float4 rawpos : %s,\n",DepthTextureEnable ? "\n out float depth : DEPTH," : "", ApiType == API_OPENGL ? "WPOS" : "POSITION"); else - WRITE(p, " out float4 ocol0 : SV_Target,%s\n in float4 rawpos : SV_Position,\n",DepthTextureEnable ? "\n out float depth : SV_Depth," : ""); + WRITE(p, " out float4 ocol0 : SV_Target0,\n out float4 ocol1 : SV_Target1,%s\n in float4 rawpos : SV_Position,\n",DepthTextureEnable ? "\n out float depth : SV_Depth," : ""); WRITE(p, " in float4 colors_0 : COLOR0,\n"); WRITE(p, " in float4 colors_1 : COLOR1"); @@ -544,7 +544,8 @@ const char *GeneratePixelShaderCode(bool dstAlphaEnable, API_TYPE ApiType,u32 co char* pmainstart = p; int Pretest = AlphaPreTest(); - if (dstAlphaEnable && !DepthTextureEnable && Pretest >= 0) + // TODO: Re-enable the early discard on D3D11 + if (dstAlphaEnable && !DepthTextureEnable && Pretest >= 0 && ApiType != API_D3D11) { if (!Pretest) { @@ -806,13 +807,24 @@ const char *GeneratePixelShaderCode(bool dstAlphaEnable, API_TYPE ApiType,u32 co WRITE(p, "depth = zCoord;\n"); } - if (dstAlphaEnable) + if (dstAlphaEnable && ApiType != API_D3D11) WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n"); else { WriteFog(p); WRITE(p, " ocol0 = prev;\n"); - } + } + + // On D3D11, use dual-source color blending to perform dst alpha in a + // single pass + if (ApiType == API_D3D11) + { + // Colors will be blended against the alpha from ocol1... + WRITE(p, " ocol1 = ocol0;\n"); + // ...and the alpha from ocol0 will be written to the framebuffer. + if (dstAlphaEnable) + WRITE(p, " ocol0.a = "I_ALPHA"[0].a;\n"); + } } WRITE(p, "}\n"); if (text[sizeof(text) - 1] != 0x7C) @@ -1256,7 +1268,7 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType) int Pretest = AlphaPreTest(); if(Pretest >= 0) { - return Pretest; + return Pretest != 0; } // using discard then return works the same in cg and dx9 but not in dx11 |
