Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Unknown's clearing fix from #8973. #8987

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions GPU/GLES/DrawEngineGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,43 @@ void DrawEngineGLES::DoFlush() {
glClear(target);
framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason);

int scissorX1 = gstate.getScissorX1();
int scissorY1 = gstate.getScissorY1();
int scissorX2 = gstate.getScissorX2() + 1;
int scissorY2 = gstate.getScissorY2() + 1;
framebufferManager_->SetSafeSize(scissorX2, scissorY2);

// If easy, immediately clear the RAM too.
if (g_Config.bBlockTransferGPU && colorMask && alphaMask) {
u8 *addr = Memory::GetPointer(gstate.getFrameBufAddress());
const bool singleByteClear = (clearColor >> 16) == (clearColor && 0xFFFF) && (clearColor >> 24) == (clearColor & 0xFF);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp: another typo, & 0xFFFF. I'll see if I can update this.

-[Unknown]

const int bpp = gstate.FrameBufFormat() == GE_FORMAT_8888 ? 4 : 2;
if (singleByteClear) {
const int xoff = scissorX1 * bpp;
const int stride = gstate.FrameBufStride() * bpp;
const int xlen = (scissorX2 - scissorX1) * bpp;
addr += xoff;
for (int y = scissorY1; y < scissorY2; ++y) {
memset(addr + y * stride, clearColor, xlen);
}
} else if (bpp == 4) {
u32 *addr32 = (u32 *)addr;
const int stride = gstate.FrameBufStride();
for (int y = scissorY1; y < scissorY2; ++y) {
for (int x = scissorX1; x < scissorX2; ++x) {
addr32[y * stride + x] = clearColor;
}
}
} else if (bpp == 2) {
u16 *addr16 = (u16 *)addr;
const int stride = gstate.FrameBufStride();
for (int y = scissorY1; y < scissorY2; ++y) {
for (int x = scissorX1; x < scissorX2; ++x) {
addr16[y * stride + x] = clearColor;
}
}
}
}
}
}

Expand Down