Skip to content

fix(renderer): disable window framebuffer alpha#1

Open
ClaudioBo wants to merge 2 commits into
CTR-tools:masterfrom
ClaudioBo:master
Open

fix(renderer): disable window framebuffer alpha#1
ClaudioBo wants to merge 2 commits into
CTR-tools:masterfrom
ClaudioBo:master

Conversation

@ClaudioBo

Copy link
Copy Markdown
Contributor

Description

Disables alpha in the window framebuffer to prevent the compositor from interpreting it as window
transparency.

Tested on

  • OS: CachyOS 7.0.12-1
  • Desktop: KDE Plasma 6.27
  • Display server: Wayland

Before

unfixed.mp4

After

fixed.mp4

@aalhendi aalhendi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We currently use framebuffer alpha as PS1 GPU metadata. The shader writes PS1 mask/STP state into the output alpha channel, and framebuffer readback packs that alpha back into PS1 VRAM bit 15.
Setting SDL_GL_ALPHA_SIZE = 0 can remove that storage from the default framebuffer, which risks breaking mask/STP behavior and framebuffer-feedback effects.

PSX Layout:
rrrrr ggggg bbbbb bit15

// Native:
  // when storing:
fragColor.a = ... ? 1.0 : 0.0; // storing bit15 into GL alpha channel
  // when renderer copies fb back into emulated psx vram
u8 a = (c >> 31) & 1;
*data_dst++ = r | (g << 5) | (b << 10) | (a << 15); // NOTE(aalhendi): alpha gets packed in bit 15

The safer fix is to separate emulation state from presentation.
We would probably keep PS1 mask/STP alpha in an internal RGBA target, then present an explicitly opaque final image to the SDL window.

Since this issue is compositor dependent, it is a low-priority target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants