Skip to content
New issue

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

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

Already on GitHub? # to your account

Lua d2dlist API #233

Open
Aurumaker72 opened this issue Nov 9, 2024 · 1 comment
Open

Lua d2dlist API #233

Aurumaker72 opened this issue Nov 9, 2024 · 1 comment
Labels
proposal This issue contains a feature or change proposal.

Comments

@Aurumaker72
Copy link
Collaborator

Aurumaker72 commented Nov 9, 2024

Rationale

Lua-to-C calls are relatively slow and should ideally be avoided in hot paths.

Drawing routines, regardles of their usage of either wgui or d2d, incur overhead from them.

Proposal

A thin abstraction for D2D should be introduced, in which commands can be encode as opcodes and have accompanying parameters.

Lua scripts utilizing this new API would only need to call one function and provide it a list of commands.

d2d.atdrawd2d(function()
    d2d.execute_list({
        {
            d2d.FILL_RECT, -- Opcode as integer constant
            4278190080, -- Color as raw integer
            0, -- Left
            0, -- Top
            100, -- Right
            150, -- Bottom
        }
    })
end)

Pros and Cons

  • General performance improvement
  • C side can perform various optimizations on the display list prior to D2D handoff

  • Another drawing API
  • Needs prototype+measuring to determine if perf difference justifies working on this
@Aurumaker72 Aurumaker72 added the proposal This issue contains a feature or change proposal. label Nov 9, 2024
@jgcodes2020
Copy link

Suggestion: include an API for generating draw lists (similar to https://docs.rs/vello/latest/vello/struct.Scene.html)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
proposal This issue contains a feature or change proposal.
Projects
None yet
Development

No branches or pull requests

2 participants