mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 12:19:12 +00:00
GeometryShader: Transform the projection within the geometry shader.
Reduces the amount of data transferred through uniforms. The shearing transformation is reduced to a single multiplication/addition for optimization.
This commit is contained in:
parent
4fd943aedd
commit
6cacfad010
4 changed files with 14 additions and 24 deletions
|
@ -515,25 +515,13 @@ void VertexShaderManager::SetConstants()
|
|||
|
||||
if (g_ActiveConfig.bStereo && xfmem.projection.type == GX_PERSPECTIVE)
|
||||
{
|
||||
Matrix44 projMtx;
|
||||
Matrix44::Set(projMtx, g_fProjectionMatrix);
|
||||
|
||||
Matrix44 leftShearMtx, rightShearMtx;
|
||||
Matrix44::Shear(leftShearMtx, g_ActiveConfig.iStereoSeparation / (200.0f * g_ActiveConfig.iStereoFocalLength));
|
||||
Matrix44::Shear(rightShearMtx, -g_ActiveConfig.iStereoSeparation / (200.0f * g_ActiveConfig.iStereoFocalLength));
|
||||
|
||||
Matrix44 leftProjMtx, rightProjMtx, leftCorrectedMtx, rightCorrectedMtx;
|
||||
Matrix44::Multiply(projMtx, leftShearMtx, leftProjMtx);
|
||||
Matrix44::Multiply(s_viewportCorrection, leftProjMtx, leftCorrectedMtx);
|
||||
Matrix44::Multiply(projMtx, rightShearMtx, rightProjMtx);
|
||||
Matrix44::Multiply(s_viewportCorrection, rightProjMtx, rightCorrectedMtx);
|
||||
memcpy(constants.stereoprojection, leftCorrectedMtx.data, 4*16);
|
||||
memcpy(constants.stereoprojection + 4, rightCorrectedMtx.data, 4*16);
|
||||
float offset = g_ActiveConfig.iStereoSeparation / (200.0f * g_ActiveConfig.iStereoFocalLength);
|
||||
constants.stereooffset[0] = offset;
|
||||
constants.stereooffset[1] = -offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(constants.stereoprojection, constants.projection, 4 * 16);
|
||||
memcpy(constants.stereoprojection + 4, constants.projection, 4 * 16);
|
||||
constants.stereooffset[0] = constants.stereooffset[1] = 0;
|
||||
}
|
||||
|
||||
dirty = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue