Closed TheSpydog closed 5 years ago
static inline
functions out of mojoshader.c and into the mojoshader_profile_common.h where they're getting copied and pasted around several files.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...
All right, all the formerly static inline
functions from mojoshader_profile.h are now non-static, non-inline functions housed in mojoshader_profile_common.c. I've additionally tried to organize things a bit better to match the original declaration order of mojoshader.c, although there are still some notable changes and/or omissions:
Several functions are only ever used in mojoshader.c, so they're still defined as static functions in that file:
free_reglist()
reglist_exists()
register_was_written()
get_defined_register()
add_attribute_register()
add_sampler()
adjust_token_position()
A couple functions turned out to only be used by the ARB1 profile, so I moved them into mojoshader_profile_arb1.c:
allocate_scratch_register()
allocate_branch_label()
And finally, get_used_register()
was literally never used anywhere, so I just removed it.
Also, I merged the PREDECLARE_PROFILE
macro calls into the existing #if SUPPORT_PROFILE_*
stuff, per your comment.
All right, with the help of Bloaty McBloatface and #pragma GCC visibility
, I've managed to reduce the size difference between this version and the old version to a mere 56 bytes (when stripped and compiled with -DCOMPILER_SUPPORT=OFF
).
Other notable change: usagestrs[]
has been moved from mojoshader_profile.h
to mojoshader_profile_d3d.c
since only the D3D profile made use of this array.
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!
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 static
but aren't anymore. One example is isscalar
, which looked like this...
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): separateprofiles.txt
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.