Skip to content

Commit

Permalink
GLES: Cleanup stencil upload w/h handling.
Browse files Browse the repository at this point in the history
In case a buffer has been resized recently, we want to upload just the
detected drawable area, probably.  Before this was inconsistent depending
on the render resolution.
  • Loading branch information
unknownbrackets committed Jun 18, 2018
1 parent da5f0f7 commit f603619
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions GPU/Common/FramebufferCommon.h
Expand Up @@ -86,10 +86,13 @@ struct VirtualFramebuffer {
// width/height: The detected size of the current framebuffer. // width/height: The detected size of the current framebuffer.
u16 width; u16 width;
u16 height; u16 height;
// renderWidth/renderHeight: The actual size we render at. May be scaled to render at higher resolutions. // renderWidth/renderHeight: The scaled size we render at. May be scaled to render at higher resolutions.
// The physical buffer may be larger than renderWidth/renderHeight.
u16 renderWidth; u16 renderWidth;
u16 renderHeight; u16 renderHeight;
// bufferWidth/bufferHeight: The actual (but non scaled) size of the buffer we render to. May only be bigger than width/height. // bufferWidth/bufferHeight: The pre-scaling size of the buffer itself. May only be bigger than width/height.
// Actual physical buffer is this size times the render resolution multiplier.
// The buffer may be used to render a width or height from 0 to these values without being recreated.
u16 bufferWidth; u16 bufferWidth;
u16 bufferHeight; u16 bufferHeight;


Expand Down
11 changes: 6 additions & 5 deletions GPU/GLES/StencilBufferGLES.cpp
Expand Up @@ -146,27 +146,28 @@ bool FramebufferManagerGLES::NotifyStencilUpload(u32 addr, int size, bool skipZe


// Our fragment shader (and discard) is slow. Since the source is 1x, we can stencil to 1x. // Our fragment shader (and discard) is slow. Since the source is 1x, we can stencil to 1x.
// Then after we're done, we'll just blit it across and stretch it there. // Then after we're done, we'll just blit it across and stretch it there.
if (dstBuffer->bufferWidth == dstBuffer->renderWidth || !dstBuffer->fbo) { if (dstBuffer->width == dstBuffer->renderWidth || !dstBuffer->fbo) {
useBlit = false; useBlit = false;
} }
u16 w = useBlit ? dstBuffer->bufferWidth : dstBuffer->renderWidth; u16 w = useBlit ? dstBuffer->width : dstBuffer->renderWidth;
u16 h = useBlit ? dstBuffer->bufferHeight : dstBuffer->renderHeight; u16 h = useBlit ? dstBuffer->height : dstBuffer->renderHeight;


Draw::Framebuffer *blitFBO = nullptr; Draw::Framebuffer *blitFBO = nullptr;
if (useBlit) { if (useBlit) {
blitFBO = GetTempFBO(TempFBO::COPY, w, h, Draw::FBO_8888); blitFBO = GetTempFBO(TempFBO::COPY, w, h, Draw::FBO_8888);
draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }); draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE });
} else if (dstBuffer->fbo) { } else if (dstBuffer->fbo) {
draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }); draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::DONT_CARE });
} }
render_->SetViewport({ 0, 0, (float)w, (float)h, 0.0f, 1.0f }); render_->SetViewport({ 0, 0, (float)w, (float)h, 0.0f, 1.0f });


float u1 = 1.0f; float u1 = 1.0f;
float v1 = 1.0f; float v1 = 1.0f;
MakePixelTexture(src, dstBuffer->format, dstBuffer->fb_stride, dstBuffer->bufferWidth, dstBuffer->bufferHeight, u1, v1); MakePixelTexture(src, dstBuffer->format, dstBuffer->fb_stride, dstBuffer->width, dstBuffer->height, u1, v1);
textureCacheGL_->ForgetLastTexture(); textureCacheGL_->ForgetLastTexture();


// We must bind the program after starting the render pass, and set the color mask after clearing. // We must bind the program after starting the render pass, and set the color mask after clearing.
render_->SetScissor({ 0, 0, w, h });
render_->SetDepth(false, false, GL_ALWAYS); render_->SetDepth(false, false, GL_ALWAYS);
render_->Clear(0, 0, 0, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, 0x8, 0, 0, 0, 0); render_->Clear(0, 0, 0, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, 0x8, 0, 0, 0, 0);
render_->SetStencilFunc(GL_TRUE, GL_ALWAYS, 0xFF, 0xFF); render_->SetStencilFunc(GL_TRUE, GL_ALWAYS, 0xFF, 0xFF);
Expand Down

0 comments on commit f603619

Please sign in to comment.