-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Reorganize profiles into their own files #5
Conversation
|
|
Very well, I’ll try to review the refactor tomorrow. We’ll have to figure out the best path for dealing with the static functions. May have to macro, may have to throw them in common.c. That may have to be a separate commit though, since this changes enough as it is... |
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.
This was my first review pass. Overall it seems fine aside from style things, but I'm not crazy enough to expect perfect style from a 17k-line patch.
The main thing we need to document very very carefully in our final commit message is where everything moved. I tried marking spots that were clear transfers but then things fell apart a little since stuff got moved into profile_common, or were actually only used in certain spots, and some functions stayed as static inline while others did not, etc.
What might be the best next step is starting the process of replacing all the static inline
functions with whatever is more appropriate now that it's all split up. Some of it could be macro-fied (i.e. all the one-liners) but that would mean editing even more code, so let's do that another time. What we can do now is try to group the related functions together and try to give them the same attributes. For example, if we have this...
static inline void Blorp1()
{
lots;
of;
if (crap) {
oh;
good;
grief;
} // if
} // Blorp1
static inline int Blorp2(int zoop)
{
return zoop == 69;
} // Blorp2
static inline int Blorp3(const char *why)
{
return strcmp(why, "because");
} // Blorp3
... even though Blorp2/3 are trivial to inline, we have to be the bad guy and put all the Blorps in common.c together, instead of mixing/matching. Thankfully the only place where this got really messy was the register functions, everything else seemed clear.
The final version of this one patch will probably make the binary size a lot bigger, but fixing that can be a separate commit.
} Profile; | ||
|
||
|
||
// Common utilities... |
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.
Marking this as a change of mojoshader.c:301...
ctx->free(ptr, ctx->malloc_data); | ||
} // Free | ||
|
||
int set_output(Context *ctx, Buffer **section); |
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.
Marking this as a change of mojoshader.c:342...
return ctx->isfail; | ||
} // isfail | ||
|
||
void failf(Context *ctx, const char *fmt, ...); |
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.
Marking this as a change of mojoshader.c:420...
void floatstr(Context *ctx, char *buf, size_t bufsize, float f, | ||
int leavedecimal); | ||
|
||
RegisterList *reglist_insert(Context *ctx, RegisterList *prev, |
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.
Seeing lots of changes here compared to mojoshader.c:516...
profiles/mojoshader_profile.h
Outdated
dst->writemask3 = ((mask >> 3) & 1); | ||
} // set_dstarg_writemask | ||
|
||
int allocate_scratch_register(Context *ctx); |
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.
Marking as a change of mojoshader.c:743...
All right, all the formerly Several functions are only ever used in mojoshader.c, so they're still defined as static functions in that file:
A couple functions turned out to only be used by the ARB1 profile, so I moved them into mojoshader_profile_arb1.c:
And finally, Also, I merged the |
All right, with the help of Bloaty McBloatface and Other notable change: |
What's left to do here before this can be merged? Are we waiting on the SPIR-V emitter so we can refactor that into the new format too? |
I'll do one last review of this today and if everything looks good we can make a Mercurial patch to push to upstream. EDIT: Have to push this to tomorrow, sorry! |
int isscalar(Context *ctx, const MOJOSHADER_shaderType shader_type, | ||
const RegisterType rtype, const int rnum); | ||
|
||
static const char swizzle_channels[] = { 'x', 'y', 'z', 'w' }; |
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.
May be a possible cause of increased size, but just barely...
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, it's annoying. I've tried moving it around and making it non-static, but no matter what it doesn't seem to affect the stripped binary size. :/
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.
That's hopefully the optimizer being smart. Oh well, we can just leave this...
Passed this through all of my compilers and they seem to be happy with everything. The very last thing we get to do also happens to be the most tedious: We'll need to fix parameter lists for functions that used to be https://github.com/FNA-XNA/MojoShader/pull/5/files#diff-d496920d66adab7260e5d2670f334605L766 ... but now looks like this: https://github.com/FNA-XNA/MojoShader/pull/5/files#diff-f6bd4f8f8bd83197cca2564b822858d9R357 We just have to line everything up again. Once that's done we should be good to go on the Hg version of this patch. |
All right, I think I got 'em all. There could be a few that snuck by me, but we'll fix them as we see them. Here's the hg patch (uploaded as a .txt file since GitHub doesn't like .patch files): |
Merged into upstream: https://hg.icculus.org/icculus/mojoshader/rev/b8ece252a201 |
Couldn't get to sleep last night, so I did what any normal person would do -- clean up MojoShader! I ripped out all the profiles and put them in their own files in the
profiles/
subdirectory. IMO this has been long overdue, but after having done it, I can totally see why nobody attempted it before. :PA few things:
mojoshader_internal.h
error that I commented out. It's being fussy with the new files (probably due to some preprocessor ordering rule I'm not familiar with), but hopefully it won't be a difficult fix.