some fixes to depth test and screen clearing in dx11, now a lot of the remaining graphic errors should be fixed

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5756 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado 2010-06-21 02:40:09 +00:00
parent a450fd45d8
commit fde15c1bc6
2 changed files with 28 additions and 28 deletions

View File

@ -484,6 +484,10 @@ void drawShadedTexQuad(ID3D11ShaderResourceView* texture,
D3D::context->Map(stqvb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
memcpy(map.pData, coords, sizeof(coords));
D3D::context->Unmap(stqvb, 0);
lastu1 = u1;
lastv1 = v1;
lastu2 = u2;
lastv2 = v2;
}
UINT stride = sizeof(STQVertex);
UINT offset = 0;
@ -501,10 +505,7 @@ void drawShadedTexQuad(ID3D11ShaderResourceView* texture,
ID3D11ShaderResourceView* texres = NULL;
context->PSSetShaderResources(0, 1, &texres); // immediately unbind the texture
lastu1 = u1;
lastv1 = v1;
lastu2 = u2;
lastv2 = v2;
}
void drawShadedTexSubQuad(ID3D11ShaderResourceView* texture,
@ -540,6 +541,14 @@ void drawShadedTexSubQuad(ID3D11ShaderResourceView* texture,
D3D::context->Map(stsqvb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
memcpy(map.pData, coords, sizeof(coords));
D3D::context->Unmap(stsqvb, 0);
lastu1 = u1;
lastv1 = v1;
lastu2 = u2;
lastv2 = v2;
lastrdest.left = rDest->left;
lastrdest.right = rDest->right;
lastrdest.top = rDest->top;
lastrdest.bottom = rDest->bottom;
}
UINT stride = sizeof(STSQVertex);
UINT offset = 0;
@ -557,20 +566,12 @@ void drawShadedTexSubQuad(ID3D11ShaderResourceView* texture,
ID3D11ShaderResourceView* texres = NULL;
context->PSSetShaderResources(0, 1, &texres); // immediately unbind the texture
lastu1 = u1;
lastv1 = v1;
lastu2 = u2;
lastv2 = v2;
lastrdest.left = rDest->left;
lastrdest.right = rDest->right;
lastrdest.top = rDest->top;
lastrdest.bottom = rDest->bottom;
}
// TODO: Check whether we're passing Color in the right order (should be RGBA)
void drawClearQuad(u32 Color, float z, ID3D11PixelShader* PShader, ID3D11VertexShader* Vshader, ID3D11InputLayout* layout)
{
static u32 lastcol = 0;
static u32 lastcol = 0x15325376;
static float lastz = -15325.376f; // random value
if (lastcol != Color || lastz != z)
@ -586,6 +587,8 @@ void drawClearQuad(u32 Color, float z, ID3D11PixelShader* PShader, ID3D11VertexS
context->Map(clearvb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
memcpy(map.pData, coords, sizeof(coords));
context->Unmap(clearvb, 0);
lastcol = Color;
lastz = z;
}
context->VSSetShader(Vshader, NULL, 0);
context->PSSetShader(PShader, NULL, 0);
@ -598,8 +601,7 @@ void drawClearQuad(u32 Color, float z, ID3D11PixelShader* PShader, ID3D11VertexS
stateman->Apply();
context->Draw(4, 0);
lastcol = Color;
lastz = z;
}

View File

@ -752,7 +752,7 @@ void UpdateViewport()
1.f); // xfregs.rawViewport[5] / 16777216.0f;
D3D::context->RSSetViewports(1, &vp);
}
//Tino: color is pased in bgra mode so need to convert it to rgba
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
{
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
@ -765,13 +765,16 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
// always set the scissor in case it was set by the game and has not been reset
D3D11_RECT sirc = CD3D11_RECT(targetRc.left, targetRc.top, targetRc.right, targetRc.bottom);
D3D::context->RSSetScissorRects(1, &sirc);
u32 rgbaColor = (color & 0xFF00FF00) | ((color >> 16) & 0xFF) | ((color << 16) & 0xFF0000);
D3D::stateman->PushDepthState(cleardepthstates[zEnable]);
D3D::stateman->PushRasterizerState(clearraststate);
D3D::drawClearQuad(color, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader(), VertexShaderCache::GetClearInputLayout());
D3D::stateman->PushBlendState(resetblendstate);
D3D::stateman->Apply();
D3D::drawClearQuad(rgbaColor, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader(), VertexShaderCache::GetClearInputLayout());
D3D::stateman->PopDepthState();
D3D::stateman->PopRasterizerState();
D3D::stateman->PopBlendState();
UpdateViewport();
SetScissorRect();
}
@ -1033,23 +1036,18 @@ void Renderer::ResetAPIState()
void Renderer::RestoreAPIState()
{
// TODO: How much of this is actually needed?
// gets us back into a more game-like state.
// TODO: check whether commenting these lines broke anything
// D3D::gfxstate->rastdesc.ScissorEnable = TRUE;
// gets us back into a more game-like state.
UpdateViewport();
SetScissorRect();
// if (bpmem.zmode.testenable) D3D::gfxstate->depthdesc.DepthEnable = TRUE;
// if (bpmem.zmode.updateenable) D3D::gfxstate->depthdesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
SetColorMask();
SetLogicOpMode();
for (;resets;--resets)
{
D3D::stateman->PopBlendState();
D3D::stateman->PopDepthState();
D3D::stateman->PopRasterizerState();
D3D::gfxstate->ApplyState();
D3D::stateman->PopRasterizerState();
}
D3D::gfxstate->ApplyState();
}
void Renderer::SetGenerationMode()
@ -1068,7 +1066,7 @@ void Renderer::SetDepthMode()
}
else
{
D3D::gfxstate->depthdesc.DepthEnable = TRUE;
D3D::gfxstate->depthdesc.DepthEnable = FALSE;
D3D::gfxstate->depthdesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
}
}