(03-30-2012, 02:21 PM)zelin Wrote: [ -> ]Have you actually tried Zelda: Skyward Sword? Does Stereo 3d work with this game in Directx11?
I'm currently making patches for Skyward Sword because I want to finally play this game in Stereo3D (NVidia 3DTV Play 720p 16:9). The current state is: Some level parts are only rendered for the left eye.
Here are my patches so far:
1) Enable stereo handling for frame buffer elements in general for DX11.
Core/VideoCommon/Src/TextureCacheBase.cpp - TextureCache::CopyRenderTargetToTexture
unsigned int scaled_tex_w = g_ActiveConfig.bCopyEFBScaled ? Renderer::EFBToScaledX(tex_w) : tex_w;
unsigned int scaled_tex_h = g_ActiveConfig.bCopyEFBScaled ? Renderer::EFBToScaledY(tex_h) : tex_h;
+ if (tex_w < 640 || tex_h < 528 || tex_w == tex_h)
+ {
+ scaled_tex_w = Renderer::GetBackbufferWidth();
+ scaled_tex_h = Renderer::GetBackbufferHeight();
+ }
Without the above patch, many 2D stats are killing areas of stereovision on screen. Example: Mario Kart multiplayer lower-right screen, Mario Galaxy Luigi Ghost House player statistics upper left screen, etc.)
2) Bad post processing removal by replacing ugly effects with transparent texture.
Plugins/Plugin_VideoDX11/Src/TextureCache.cpp
added code:
static D3DTexture2D *transparentTexture = 0;
static void CreateTransparentTexture()
{
const int SIZE = 32;
transparentTexture = D3DTexture2D::Create(SIZE, SIZE, D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_DYNAMIC, DXGI_FORMAT_R8G8B8A8_UNORM, 1);
// Lock the surface and write the alpha values.
D3D11_MAPPED_SUBRESOURCE texmap;
HRESULT hr = D3D::context->Map(transparentTexture->GetTex(), 0, D3D11_MAP_WRITE_DISCARD, 0, &texmap);
if (FAILED(hr)) PanicAlert("Failed to map a texture at %s %d\n", __FILE__, __LINE__);
for (int y = 0; y < SIZE; y++)
{
u32* pDst32 = (u32*)((u8*)texmap.pData + y * texmap.RowPitch);
for (int x = 0; x < SIZE; x++)
{
*pDst32++ = 0x00000000;
}
}
D3D::context->Unmap(transparentTexture->GetTex(), 0);
}
void TextureCache::TCacheEntry::BindTransparent(unsigned int stage)
{
if (!transparentTexture) CreateTransparentTexture();
D3D::context->PSSetShaderResources(stage, 1, &transparentTexture->GetSRV());
}
Plugins/Plugin_VideoDX11/Src/VertexManager.cpp - VertexManager::vFlush()
add after here:
// 0s are probably for no manual wrapping needed.
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
if (tentry->IsEfbCopy())
{
// Replace alpha blend effects with transparent texture.
if (bpmem.blendmode.blendenable && (
// Zelda TP: Unknown 2D post processing resulting in blurry screen
(i == 0 && tentry->format == 0xb && tentry->native_width == 304 && tentry->native_height == 224) ||
// Metroid M: Unknown lighting effect causing extreme color flicker
(i == 0 && tentry->format == 4 && tentry->native_width == 160 && tentry->native_height == 120) ||
// Zelda SS: Unknown 2D post processing resulting in blurry screen
(i == 1 && tentry->format == 6 && tentry->native_width == 608 && tentry->native_height == 456) ||
false))
{
tentry->BindTransparent(i);
}
// Skip distorting post processing effects.
else if (!bpmem.blendmode.blendenable && (
// Metroid M: Unknown 2D post processing killing stereo in upper half of screen
(i == 0 && tentry->format == 6 && tentry->native_width == 640 && tentry->native_height == 480) ||
false))
{
goto shader_fail;
}
// Fix accumulated Z-Position.
if (// Zelda TP: Water effect.
(bpmem.blendmode.blendenable && i == 0 && tentry->format == 6 && tentry->native_width == 304 && tentry->native_height == 224) ||
false)
{
absoluteWPos = true;
}
}
3) Fix wrong sized rendertarget to texture blits
Core/VideoCommon/Src/BPFunctions.cpp - CopyEFB
// bpmem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
if (g_ActiveConfig.bEFBCopyEnable)
{
// Zelda SS: Softener effect resolution fix.
if ((dstFormat == 4 && srcRect.left == 0 && srcRect.top == 0 && srcRect.right == 554 && srcRect.bottom == 456) ||
(dstFormat == 4 && srcRect.left == 0 && srcRect.top == 0 && srcRect.right == 526 && srcRect.bottom == 456))
srcRect.right = 608;
This fixes all distortions.
Edit: Screenshot added.
[
attachment=7597]