Merge pull request #3361 from stenzek/d3d-vectored-efb-pokes

D3D: Implement vectored efb pokes
This commit is contained in:
Markus Wick
2015-12-30 15:27:24 +01:00
11 changed files with 140 additions and 61 deletions

View File

@ -475,55 +475,45 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
else if (alpha_read_mode.ReadMode == 1) return (ret | 0xFF000000); // GX_READ_FF
else /*if(alpha_read_mode.ReadMode == 0)*/ return (ret & 0x00FFFFFF); // GX_READ_00
}
else if (type == POKE_COLOR)
return 0;
}
void Renderer::PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points)
{
ResetAPIState();
if (type == POKE_COLOR)
{
u32 rgbaColor = (poke_data & 0xFF00FF00) | ((poke_data >> 16) & 0xFF) | ((poke_data << 16) & 0xFF0000);
// TODO: The first five PE registers may change behavior of EFB pokes, this isn't implemented, yet.
ResetAPIState();
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.0f, 0.0f, (float)GetTargetWidth(), (float)GetTargetHeight());
D3D::context->RSSetViewports(1, &vp);
D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), nullptr);
D3D::drawColorQuad(rgbaColor, 0.f,
(float)RectToLock.left * 2.f / GetTargetWidth() - 1.f,
- (float)RectToLock.top * 2.f / GetTargetHeight() + 1.f,
(float)RectToLock.right * 2.f / GetTargetWidth() - 1.f,
- (float)RectToLock.bottom * 2.f / GetTargetHeight() + 1.f);
RestoreAPIState();
}
else // if (type == POKE_Z)
{
// TODO: The first five PE registers may change behavior of EFB pokes, this isn't implemented, yet.
ResetAPIState();
D3D::stateman->PushBlendState(clearblendstates[3]);
D3D::stateman->PushDepthState(cleardepthstates[1]);
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.0f, 0.0f, (float)GetTargetWidth(), (float)GetTargetHeight(),
1.0f - MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f,
1.0f - MathUtil::Clamp<float>((xfmem.viewport.farZ - MathUtil::Clamp<float>(xfmem.viewport.zRange, 0.0f, 16777215.0f)), 0.0f, 16777215.0f) / 16777216.0f);
D3D::context->RSSetViewports(1, &vp);
D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(),
FramebufferManager::GetEFBDepthTexture()->GetDSV());
D3D::drawColorQuad(0, 1.0f - float(poke_data & 0xFFFFFF) / 16777216.0f,
(float)RectToLock.left * 2.f / GetTargetWidth() - 1.f,
- (float)RectToLock.top * 2.f / GetTargetHeight() + 1.f,
(float)RectToLock.right * 2.f / GetTargetWidth() - 1.f,
- (float)RectToLock.bottom * 2.f / GetTargetHeight() + 1.f);
D3D::stateman->PopDepthState();
D3D::stateman->PopBlendState();
RestoreAPIState();
}
return 0;
}
D3D::DrawEFBPokeQuads(type, points, num_points);
if (type == POKE_Z)
{
D3D::stateman->PopDepthState();
D3D::stateman->PopBlendState();
}
RestoreAPIState();
}
void Renderer::SetViewport()
{