Skip to content

fix regression that disabled custom fpp color format in some platforms#2623

Open
riccardobl wants to merge 2 commits intojMonkeyEngine:masterfrom
riccardobl:ffpformat
Open

fix regression that disabled custom fpp color format in some platforms#2623
riccardobl wants to merge 2 commits intojMonkeyEngine:masterfrom
riccardobl:ffpformat

Conversation

@riccardobl
Copy link
Member

Fixes the issue reported here

@yaRnMcDonuts yaRnMcDonuts added this to the v3.10.0 milestone Feb 21, 2026
@capdevon
Copy link
Contributor

capdevon commented Feb 24, 2026

It might also be worth adding a validation step to ensure that the framebuffer format selected by the user is actually supported by the renderer.

Given this addition, we may also want to consider whether fbFormat should be serialized, so that the chosen format can be preserved across saves and restores.

        if (fbFormat == null) {
            // Determine optimal framebuffer format based on renderer capabilities
            fbFormat = getDefaultFrameBufferFormat(renderer);
        } else {
            // User requested a specific format → verify GPU support
            if (!isFormatSupported(fbFormat, renderer)) {
                Format fallback = getDefaultFrameBufferFormat(renderer);
                logger.warning("Requested framebuffer format " + fbFormat +
                        " not supported. Falling back to " + fallback);
                fbFormat = fallback;
            }
        }
    private Format getDefaultFrameBufferFormat(Renderer renderer) {
        Collection<Caps> caps = renderer.getCaps();
        if (caps.contains(Caps.PackedFloatTexture)) {
            return Format.RGB111110F;
        } else if (caps.contains(Caps.FloatColorBufferRGB)) {
            return Format.RGB16F;
        } else if (caps.contains(Caps.FloatColorBufferRGBA)) {
            return Format.RGBA16F;
        } else {
            return Format.RGB8;
        }
    }

    private boolean isFormatSupported(Format format, Renderer renderer) {
        Collection<Caps> caps = renderer.getCaps();
        switch (format) {
            case RGB111110F:
                return caps.contains(Caps.PackedFloatTexture);
            case RGB16F:
                return caps.contains(Caps.FloatColorBufferRGB);
            case RGBA16F:
                return caps.contains(Caps.FloatColorBufferRGBA);
            case RGB8:
                return true;
            default:
                return false;
        }
    }

@riccardobl

@riccardobl
Copy link
Member Author

Yes, for serialization. However, I suggest that we avoid verifying whether the format is supported when set manually.
If a developer is setting this low-level value, it likely means they have a specific need for a particular format. Changing it, even with a warning, could make debugging more difficult. The developer can perform the necessary validation on their side if needed.

Copy link
Contributor

@codex128 codex128 left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

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.

4 participants