Skip to content

Commit

Permalink
GPU: Handle buffer overhead in postshader uniforms.
Browse files Browse the repository at this point in the history
Framebuffers may be temporarily larger than the estimated width, because
we estimate different sizes for them and resizing is expensive.

This moves accounting for that to texelDelta instead of pixelDelta.
  • Loading branch information
unknownbrackets committed May 13, 2020
1 parent 472c51f commit d6d1fe6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,9 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) {
}

PostShaderUniforms uniforms{};
presentation_->CalculatePostShaderUniforms(vfb->bufferWidth, vfb->bufferHeight, textureCache_->VideoIsPlaying(), &uniforms);
int actualWidth = (vfb->bufferWidth * vfb->renderWidth) / vfb->width;
int actualHeight = (vfb->bufferHeight * vfb->renderHeight) / vfb->height;
presentation_->CalculatePostShaderUniforms(actualWidth, actualHeight, textureCache_->VideoIsPlaying(), &uniforms);
presentation_->SourceFramebuffer(vfb->fbo);
presentation_->CopyToOutput(flags, uvRotation, u0, v0, u1, v1, uniforms);
} else if (useBufferedRendering_) {
Expand Down
12 changes: 6 additions & 6 deletions GPU/Common/PresentationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ void PresentationCommon::GetCardboardSettings(CardboardSettings *cardboardSettin
}

void PresentationCommon::CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, bool hasVideo, PostShaderUniforms *uniforms) {
float u_delta = 1.0f / renderWidth_;
float v_delta = 1.0f / renderHeight_;
float u_pixel_delta = u_delta;
float v_pixel_delta = v_delta;
float u_delta = 1.0f / bufferWidth;
float v_delta = 1.0f / bufferHeight;
float u_pixel_delta = 1.0 / renderWidth_;
float v_pixel_delta = 1.0 / renderHeight_;
if (postShaderAtOutputResolution_) {
float x, y, w, h;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL);
u_pixel_delta = (1.0f / w) * (480.0f / bufferWidth);
v_pixel_delta = (1.0f / h) * (272.0f / bufferHeight);
u_pixel_delta = 1.0f / w;
v_pixel_delta = 1.0f / h;
}
int flipCount = __DisplayGetFlipCount();
int vCount = __DisplayGetVCount();
Expand Down

0 comments on commit d6d1fe6

Please sign in to comment.