-
Notifications
You must be signed in to change notification settings - Fork 236
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
Cleanup #826
Cleanup #826
Conversation
src/rencache.c
Outdated
@@ -159,7 +160,7 @@ void rencache_invalidate(void) { | |||
} | |||
|
|||
|
|||
void rencache_begin_frame(lua_State *L) { | |||
void rencache_begin_frame(UNUSED lua_State *L) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing it moved the UNUSED from this to f_begin_frame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't those lua_State
s be useful in case we add support for multiple windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure; but we can always add them back in when and if that happens. As it stands, if it's causing a warning, let's just nix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to keep so that the signature of all rencache functions stays similar.
We cannot remove lua_State
from the f_{begin,end}_frame
functions so it might be worth to keep this
src/rencache.c
Outdated
@@ -200,7 +201,7 @@ static void push_rect(RenRect r, int *count) { | |||
} | |||
|
|||
|
|||
void rencache_end_frame(lua_State *L) { | |||
void rencache_end_frame(UNUSED lua_State *L) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing it moved the UNUSED from this to f_end_frame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more stuff
This now compiles using zig cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran this through CodeChecker and found some additional things
if (new_fds[stream] > STDERR_FD || new_fds[stream] < REDIRECT_PARENT) { | ||
for (size_t i = 0; i < env_len; ++i) { | ||
free((char*)env_names[i]); | ||
free((char*)env_values[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah; this is a good point; ideally though we'd probably have this as separate logic, rather than repeating it. Perhaps goto
? That is the standard way of doing exception handling in C.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem right now is that the code is not designed around this but I can look into this
src/renderer.c
Outdated
r = (color.r * src.r * color.a + dst.r * (65025 - src.r * color.a) + 32767) / 65025; | ||
g = (color.g * src.g * color.a + dst.g * (65025 - src.g * color.a) + 32767) / 65025; | ||
b = (color.b * src.b * color.a + dst.b * (65025 - src.b * color.a) + 32767) / 65025; | ||
*destination_pixel++ = dst.a << surface->format->Ashift | r << surface->format->Rshift | g << surface->format->Gshift | b << surface->format->Bshift; | ||
*destination_pixel++ = SDL_MapRGBA(surface->format, r, g, b, dst.a); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the proper way™ makes things a bit slower. On my system this change increases CPU usage by ~7%, both with and without LITE_USE_SDL_RENDERER
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code should act the same since we have no palette set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function calls are more expensive than doing it directly, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the overhead could come from having to dynamically resolve the symbol.
Another guess would be that the SDL_expand_byte
lookup is more expensive than just doing naive bit shifts.
This might be worth investigating further to see where the difference comes from.
So I'd like to merge this, but I'd like to not lose any performance on the tight loop. Can we just revert that bit, and leave a comment above it that it's out of standard, so that we don't lose the performance, but still keep an eye on it? |
- add logic to loop over more lua names (in the future more names might be discovered) - disable warnings and errors on dependencies
- various functions from string.h were used but never defined - logic was done across multiple different data types with different signedness, got all of them up to snuff - give 0 sized array size of 1 (array of size 0 is illegal, but rewriting the code is out of the scope of this commit) - add preprocessor that marks possibly unused argument as such (does not mean they will get optimized out or anything) - correctly initialize structs with all data needed All these were found by generating the project using `meson -Dwarning_level=3 -Dwerror=true`
OK, I've tested this, and it looks good. Merging. |
Update meson.build
adding missing includes and checks, correct data types, pointer mess