Skip to content

Feature requests #4

@kynex7510

Description

@kynex7510

Here's a list of features that GLASS needs to work propertly under baremetal. This is an issue and not a PR because the features are varied and I don't feel like proposing any design choice, I'll limit myself to describe what I'm currently doing for workarounds.

FCRAM/linear allocator

This is required by basically everything in the library, as GPU-accessible memory is an ubiquitous characteristic. In my local fork, I've adapted the allocator from libctru, and calculate the memory range in linearInit as such:

const bool n3ds = getCfg11Regs()->socinfo & SOCINFO_LGR2;
auto blk = MemBlock::Create((u8*)FCRAM_BASE, n3ds ? FCRAM_SIZE + FCRAM_EXT_SIZE : FCRAM_SIZE);

Note that this doesn't account for LGR1.

Framebuffer info query

There needs to be a way to query for currently used FB formats and whether wide mode is enabled, to correctly calculate dimensions and format values for DisplayTransfer. In my local repo, GFX_getFormat is implemented as such:

GfxFmt GFX_getFormat(const GfxLcd lcd)
{
    GfxState *const state = &g_gfxState;
    return state->lcds[lcd].fb_fmt & PDC_FB_FMT_MASK;
}

Meanwhile, GFX_getTopMode is implemented as such:

GfxTopMode GFX_getTopMode(void)
{
   GfxState *const state = &g_gfxState;
   return state->topMode;
}

Where state->topMode is set at the end of allocateFramebufs().

Framebuffer single screen swap

There exists gfxScreenSwapBuffers in libctru, which swaps frambuffers only for the specified LCD. The function accepts a stereo parameter which should be false when the 3d slider is off (0.0f), so that libctru can use the left framebuffer data in place of the right one; this way applications can avoid rendering into the right-side framebuffer. Additionally this function saves swapping framebuffers when one of the screens is unused.
There should be an equivalent GFX_screenSwapBuffers function for consistent behaviour, which however would require some adjustments to support stereo, specifically at buffer management, since frambuffers are set in allocateFramebufs and are never touched again. For this reason, I don't have custom code, and currently rely on GFX_swapBuffers, which works fine for testing but is ultimately incompatible for 2 screens (as it ends up getting called twice per frame).
I would be fine giving up on stereo if the implementation is deemed too time consuming or not fit, so long single-swap is available in some way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions