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

Rework blitter functions arguments #185

Open
tehKaiN opened this issue Mar 4, 2023 · 3 comments
Open

Rework blitter functions arguments #185

tehKaiN opened this issue Mar 4, 2023 · 3 comments

Comments

@tehKaiN
Copy link
Member

tehKaiN commented Mar 4, 2023

Currently, blitCopy() etc require something like 10 args, passing which is a bad idea performance-wise.

It could be replace by passing an arg struct. Instead of

blitCopy(s_pBgSub, 0, 0, s_pBfr->pBack, 0, 0, 320, 128, MINTERM_COPY);
blitCopy(s_pBgSub, 0, 128, s_pBfr->pBack, 0, 128, 320, 128, MINTERM_COPY);

It would be something like

tBlitCopyArgs sArgs = {s_pBgSub, 0, 0, s_pBfr->pBack, 0, 0, 320, 128, MINTERM_COPY};
blitCopyPredefined(&sArgs);
sArgs.uwSrcY = 128;
sArgs.uwDstY = 128;
blitCopyPredefined(&sArgs);

Pros:

  • less stdcall overhead
  • ability to cache repetitive blits

Cons:

  • a bit less readable syntax (completely optional if old functions stay as is)
  • no compile-time checks if all struct fields have been set - especially dangerous if additional field will be added in future. Could be resolved by
@Vairn
Copy link
Contributor

Vairn commented Jun 6, 2023

seems like a good idea, you can do some easy batch rendereing with only changing two values, especially with my wall rendering calls blitcopymask 2000* odd times a frame.

might be an little exaggerated

@steamknight
Copy link

If we pass a structure, there will be a pointer dereference for each original parameter inside the blit call. I'm curious if that will still be faster than passing in 10 arguments to the function or if the compiler can optimize the extra dereference away.

@tehKaiN
Copy link
Member Author

tehKaiN commented Jun 7, 2023

Definitely needs benchmarking!

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

No branches or pull requests

3 participants