Minor refactor in PresentationCommon (combine loose coordinates to a struct)
This commit is contained in:
parent
8e7d2109fe
commit
e559fc022f
4 changed files with 48 additions and 35 deletions
|
@ -39,7 +39,7 @@ struct Vertex {
|
|||
uint32_t rgba;
|
||||
};
|
||||
|
||||
void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) {
|
||||
void CenterDisplayOutputRect(FRect *rc, float origW, float origH, float frameW, float frameH, int rotation) {
|
||||
float outW;
|
||||
float outH;
|
||||
|
||||
|
@ -60,16 +60,16 @@ void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW
|
|||
float smallDisplayW = origW * customZoom;
|
||||
float smallDisplayH = origH * customZoom;
|
||||
if (!rotated) {
|
||||
*x = floorf(((frameW - smallDisplayW) / 2.0f) + offsetX);
|
||||
*y = floorf(((frameH - smallDisplayH) / 2.0f) + offsetY);
|
||||
*w = floorf(smallDisplayW);
|
||||
*h = floorf(smallDisplayH);
|
||||
rc->x = floorf(((frameW - smallDisplayW) / 2.0f) + offsetX);
|
||||
rc->y = floorf(((frameH - smallDisplayH) / 2.0f) + offsetY);
|
||||
rc->w = floorf(smallDisplayW);
|
||||
rc->h = floorf(smallDisplayH);
|
||||
return;
|
||||
} else {
|
||||
*x = floorf(((frameW - smallDisplayH) / 2.0f) + offsetX);
|
||||
*y = floorf(((frameH - smallDisplayW) / 2.0f) + offsetY);
|
||||
*w = floorf(smallDisplayH);
|
||||
*h = floorf(smallDisplayW);
|
||||
rc->x = floorf(((frameW - smallDisplayH) / 2.0f) + offsetX);
|
||||
rc->y = floorf(((frameH - smallDisplayW) / 2.0f) + offsetY);
|
||||
rc->w = floorf(smallDisplayH);
|
||||
rc->h = floorf(smallDisplayW);
|
||||
return;
|
||||
}
|
||||
} else if (g_Config.iSmallDisplayZoomType == (int)SmallDisplayZoom::AUTO) {
|
||||
|
@ -77,10 +77,10 @@ void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW
|
|||
float pixelCrop = frameH / 270.0f;
|
||||
float resCommonWidescreen = pixelCrop - floor(pixelCrop);
|
||||
if (!rotated && resCommonWidescreen == 0.0f && frameW >= pixelCrop * 480.0f) {
|
||||
*x = floorf((frameW - pixelCrop * 480.0f) * 0.5f);
|
||||
*y = floorf(-pixelCrop);
|
||||
*w = floorf(pixelCrop * 480.0f);
|
||||
*h = floorf(pixelCrop * 272.0f);
|
||||
rc->x = floorf((frameW - pixelCrop * 480.0f) * 0.5f);
|
||||
rc->y = floorf(-pixelCrop);
|
||||
rc->w = floorf(pixelCrop * 480.0f);
|
||||
rc->h = floorf(pixelCrop * 272.0f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -104,10 +104,10 @@ void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW
|
|||
}
|
||||
}
|
||||
|
||||
*x = floorf((frameW - outW) / 2.0f);
|
||||
*y = floorf((frameH - outH) / 2.0f);
|
||||
*w = floorf(outW);
|
||||
*h = floorf(outH);
|
||||
rc->x = floorf((frameW - outW) / 2.0f);
|
||||
rc->y = floorf((frameH - outH) / 2.0f);
|
||||
rc->w = floorf(outW);
|
||||
rc->h = floorf(outH);
|
||||
}
|
||||
|
||||
PresentationCommon::PresentationCommon(Draw::DrawContext *draw) : draw_(draw) {
|
||||
|
@ -252,10 +252,10 @@ bool PresentationCommon::BuildPostShader(const ShaderInfo *shaderInfo, const Sha
|
|||
nextHeight *= next->SSAAFilterLevel;
|
||||
} else if (shaderInfo->outputResolution) {
|
||||
// If the current shader uses output res (not next), we will use output res for it.
|
||||
float x, y, w, h;
|
||||
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, g_Config.iInternalScreenRotation);
|
||||
nextWidth = (int)w;
|
||||
nextHeight = (int)h;
|
||||
FRect rc;
|
||||
CenterDisplayOutputRect(&rc, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, g_Config.iInternalScreenRotation);
|
||||
nextWidth = (int)rc.w;
|
||||
nextHeight = (int)rc.h;
|
||||
}
|
||||
|
||||
// No depth/stencil for post processing
|
||||
|
@ -499,13 +499,13 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
|
|||
int lastHeight = srcHeight_;
|
||||
|
||||
// These are the output coordinates.
|
||||
float x, y, w, h;
|
||||
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, uvRotation);
|
||||
FRect rc;
|
||||
CenterDisplayOutputRect(&rc, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, uvRotation);
|
||||
|
||||
if (GetGPUBackend() == GPUBackend::DIRECT3D9) {
|
||||
x -= 0.5f;
|
||||
rc.x -= 0.5f;
|
||||
// This is plus because the top is larger y.
|
||||
y += 0.5f;
|
||||
rc.y += 0.5f;
|
||||
}
|
||||
|
||||
if ((flags & OutputFlags::BACKBUFFER_FLIPPED) || (flags & OutputFlags::POSITION_FLIPPED)) {
|
||||
|
@ -515,10 +515,10 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
|
|||
// To make buffer updates easier, we use one array of verts.
|
||||
int postVertsOffset = (int)sizeof(Vertex) * 4;
|
||||
Vertex verts[8] = {
|
||||
{ x, y, 0, u0, v0, 0xFFFFFFFF }, // TL
|
||||
{ x, y + h, 0, u0, v1, 0xFFFFFFFF }, // BL
|
||||
{ x + w, y + h, 0, u1, v1, 0xFFFFFFFF }, // BR
|
||||
{ x + w, y, 0, u1, v0, 0xFFFFFFFF }, // TR
|
||||
{ rc.x, rc.y, 0, u0, v0, 0xFFFFFFFF }, // TL
|
||||
{ rc.x, rc.y + rc.h, 0, u0, v1, 0xFFFFFFFF }, // BL
|
||||
{ rc.x + rc.w, rc.y + rc.h, 0, u1, v1, 0xFFFFFFFF }, // BR
|
||||
{ rc.x + rc.w, rc.y, 0, u1, v0, 0xFFFFFFFF }, // TR
|
||||
};
|
||||
|
||||
float invDestW = 1.0f / (pixelWidth_ * 0.5f);
|
||||
|
@ -648,7 +648,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
|
|||
|
||||
if (isFinalAtOutputResolution) {
|
||||
PostShaderUniforms uniforms;
|
||||
CalculatePostShaderUniforms(lastWidth, lastHeight, (int)w, (int)h, &postShaderInfo_.back(), &uniforms);
|
||||
CalculatePostShaderUniforms(lastWidth, lastHeight, (int)rc.w, (int)rc.h, &postShaderInfo_.back(), &uniforms);
|
||||
draw_->UpdateDynamicUniformBuffer(&uniforms, sizeof(uniforms));
|
||||
} else {
|
||||
Draw::VsTexColUB ub{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue