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

Allow Enabling and Disabling Specific Framebuffer Effects #570

Open
HomaodeFerro opened this issue Jan 6, 2025 · 11 comments
Open

Allow Enabling and Disabling Specific Framebuffer Effects #570

HomaodeFerro opened this issue Jan 6, 2025 · 11 comments
Labels
enhancement New feature or request renderer related to rendering

Comments

@HomaodeFerro
Copy link

HomaodeFerro commented Jan 6, 2025

Firstly, I would like to extend my heartfelt thanks for the outstanding work on this port! I am thrilled to be able to play Perfect Dark on virtually all of my devices thanks to your efforts 💯.

My suggestion for a future update concerns the ability to selectively enable or disable specific Framebuffer effects. I have a small computer with integrated graphics which runs the port flawlessly, with the exception of the CamSpy effect. This effect causes the screen to go black shortly after being selected from the item menu, but the screen returns to normal once CamSpy is deselected.

I modified the configuration file pd.ini by setting the FramebufferEffects variable to 0, as my GPU cannot support the effect. This resolved the issue, but unfortunately, it also disabled other effects that my GPU is capable of handling, such as blur, cloak, etc.

It would be greatly beneficial to have separate variables for individual Framebuffer effects. This would enable players to tailor their gaming experience, retaining the effects that their hardware can manage while only disabling those that cause issues.

I have attached images demonstrating the game with Framebuffer effects both enabled and disabled for comparison.

FramebufferEffects ON:

FramebufferEffects_1-1
FramebufferEffects_1-2

FramebufferEffects OFF:

FramebufferEffects_0-1
FramebufferEffects_0-2

@fgsfdsfgs
Copy link
Owner

What GPU do you have?

@HomaodeFerro
Copy link
Author

@fgsfdsfgs My Mini PC is quite modest:

OS: Batocera Plus with Linux 5.2.16
CPU: Intel Celeron CPU 1037U at 1.80GHz (Dual Core)
GPU: Intel® HD Graphics for 3rd Generation Intel® Processors

An additional detail that might be related: Batocera Plus didn't come with the latest GLIBC dependencies, so I had to force the game to run with an updated version of GLIBC located in the project folder.

I also didn't compile the game myself. I am using the latest available Linux X86_64 version.

@fgsfdsfgs fgsfdsfgs added enhancement New feature or request renderer related to rendering labels Jan 7, 2025
@LonelySpaceDetective
Copy link

I wonder how common it is for some of the framebuffer effects to work, but not all of them.

I don't really have any real issues with adding more options, but I feel like the additional toggles might clutter the video settings menu and make it a tad more overwhelming for novice users. Maybe there could a dedicated sub-menu for individual framebuffer effects, with a global toggle?

@HomaodeFerro
Copy link
Author

HomaodeFerro commented Jan 7, 2025

I wonder how common it is for some of the framebuffer effects to work, but not all of them.

I have wondered about that as well, @LonelySpaceDetective. I recall having an older integrated GPU that wouldn't render blur, but this one, for instance, handles it perfectly. I believe it must be a more common scenario for those with slightly newer integrated GPUs.

I don't really have any real issues with adding more options, but I feel like the additional toggles might clutter the video settings menu and make it a tad more overwhelming for novice users. Maybe there could a dedicated sub-menu for individual framebuffer effects, with a global toggle?

Your idea is great, and I agree with the importance of maintaining a user-friendly and clean interface. I was considering a simpler approach: instead of having a single variable for all framebuffer effects, we could edit individual variables within the pd.ini file for each effect, like so:

[Video]
FramebufferFXBlur = 1
FramebufferFXCloak = 1
FramebufferFXCamSpy = 0

@fgsfdsfgs
Copy link
Owner

Earlier Intel HD Graphics are very special. It's kind of a wonder the game works as well as it does on yours, to be honest. But I'll add some kind of option for this. Maybe just change the current one to accept two values, like "On" and "Blur only", since these are technically distinct.

@HomaodeFerro
Copy link
Author

HomaodeFerro commented Jan 7, 2025

Earlier Intel HD Graphics are very special. It's kind of a wonder the game works as well as it does on yours, to be honest.

Yup ^_^ These older Intel HD Graphics were barely used since many people added an offboard GPU. Still, the game running at 720p with stable 60 frames on my system is pretty amazing, all thanks to your hard work.

Lots of folks in the Batocera community are running this on old Mini PCs and laptops. I totally get that this isn't the main focus for the port, but if it makes sense for you guys, adding this improvement could be really cool for a chunk of the community.

But I'll add some kind of option for this. Maybe just change the current one to accept two values, like "On" and "Blur only", since these are technically distinct.

Much appreciated, @fgsfdsfgs! You guys are like the champions for the retro gaming "bikergang" community :) Your suggestion hits the nail on the head and would definitely fix things up nicely. My GPU can actually handle the cloak effect, but during the 'G5 Building: Reconnaissance' mission, the framerate starts to drop as soon as the second wave of invisible enemies comes in.

@HomaodeFerro
Copy link
Author

HomaodeFerro commented Jan 8, 2025

@fgsfdsfgs @LonelySpaceDetective Hey everyone! I've noticed that my old Intel HD Graphics is incompatible and struggles with the cloak effects. The cloak appears in a light gray tone due to this incompatibility, whereas turning off FramebufferEffects entirely results in a black cloak during those moments:

FramebufferEffects ON:
https://github.com/user-attachments/assets/c94f837f-269d-45bd-ac79-9bbd1b545d20

FramebufferEffects OFF:
IMG_20250108_113755

Additionally, the CamSpy effect shows a black box from a distance. My friend Pon mentioned facing a similar issue with the CamSpy effect with the PlayStation Classic port.

FramebufferEffects ON:
https://github.com/user-attachments/assets/83064ce8-8970-4ed8-b2d0-5bec0327ee65

I'm keen on contributing and fixing this issue, and if feasible, tackling other problems that GPUs like mine might have. Could you point me in the right direction? This is all new territory for me, but as someone with a background in development, I'm ready to tackle the tough stuff if you can show me how.

Regardless, the solution you've proposed is already satisfactory. I'm offering my help because I love Perfect Dark, and if it's a matter of needing an extra hand, I can definitely be that hand.

@fgsfdsfgs
Copy link
Owner

What exact Intel HD Graphics is that? You can run the game with --debug-gl on the command line and post the log I suppose.

@HomaodeFerro
Copy link
Author

You can run the game with --debug-gl on the command line and post the log I suppose.

Done! I'm not sure if I missed any arguments, but I've generated a log output to a txt file using the command you provided. Thanks for the help!

debug_log1.txt

What exact Intel HD Graphics is that?

It's exactly the one I mentioned earlier:

CPU: Intel Celeron CPU 1037U at 1.80GHz (Dual Core)
GPU: Intel® HD Graphics for 3rd Generation Intel® Processors

More details here: https://www.intel.com/content/www/br/pt/products/sku/71995/intel-celeron-processor-1037u-2m-cache-1-80-ghz/specifications.html

@fgsfdsfgs
Copy link
Owner

fgsfdsfgs commented Jan 10, 2025

Oh, thought you meant there was an even older one. Well, that log doesn't provide anything interesting, other than the fact that this was using Mesa. Thanks for testing.

I'm assuming these older cards either don't like glBlitFramebuffer, which is used extensively in all the framebuffer effects, or they don't like reading from the front buffer, which is in general something I probably shouldn't do, so they default to the back buffer.

If you want to try figuring it out yourself, the camspy lens effect is drawn in bviewDrawFisheye and bviewDrawFisheyeLine, the cloak effect is drawn in chrRenderCloak and the motion blur is drawn in bviewDrawMotionBlur. Blur and fisheye use g_BlurFb as the framebuffer, while chrRenderCloak uses several framebuffers in the var8009ccc0 array.

In general graphics are handled by composing an N64 display list (with port-specific extensions), which is then processed in gfx_pc.cpp, which uses gfx_opengl.cpp as the backend. The framebuffer effects use the extended display list command G_COPYFB_EXT (gDPCopyFramebufferEXT), which is basically just glBlitFramebuffer, and G_SETTIMG_FB_EXT to use them as a texture. Look for videoCreateFramebuffer, videoCopyFramebuffer and videoFramebuffersSupported in the code to find other places where framebuffers are used.

I should probably add translucency as the fallback for cloaking if framebuffers aren't supported or something.

@HomaodeFerro
Copy link
Author

@fgsfdsfgs Thanks a lot for the explanation and help. I've been trying to fix the issue on my own, but I admit my attempts haven't been very successful. After studying the project's behavior as you guided, I decided to add logs in each of the functions you mentioned. I had a few questions along the way and got some help from ChatGPT: I first tested bviewDrawMotionBlur, then bviewDrawFisheye and bviewDrawFisheyeLine, and finally chrRenderCloak, generating 3 log files for each of the framebuffer effects.

Blur effect log: I ran the game through the opening of the first level and proceeded to the perfect menu. I didn't notice any issues and the blur effect ran smoothly, although the log suggests that the blur was initially not applied.
log_blur.txt

Camspy fisheye log: I skipped the opening and went straight to the level selection menu, choosing 'DataDyne Research: Investigation' from mission 1. After taking out the first guard, I immediately tested the CamSpy and noticed that the log shows an error "[DEBUG] /home/homaodeferro/perfect_dark/src/game/bondview.c:313: Blur framebuffer is dirty; skipping rendering."
log_eyefish.txt

Cloak effect log: I followed a similar walkthrough to the menu and selected the stage 2 of mission 3, 'G5 Building: Reconnaissance'. I didn't observe any anomalies in the logs, but as my understanding is quite basic, I'm attaching them here as well.
log_cloak.txt

Please let me know if there's anything specific I should be looking at or any further steps you recommend.

I should probably add translucency as the fallback for cloaking if framebuffers aren't supported or something.

Wow! Since my GPU isn't compatible, and I barely noticed the cloak effect not being executed correctly, adding translucency when framebuffer effects are off could be really, really great ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request renderer related to rendering
Projects
None yet
Development

No branches or pull requests

3 participants