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

Scheduling, texture names, optimization, and other questions. #3

Open
Trainmaster9977 opened this issue Apr 15, 2023 · 0 comments
Open

Comments

@Trainmaster9977
Copy link

Hello!

I've been trying to use Uam to reinsert customized shaders into Smash Brothers Ultimate. (All the shaders are in raw binary btw, and I've been using the associated option)

While your tool has been a godsend, I do have quite a few questions on how it works, its limitations, etc. If you have a better way for me to reach ya, please let me know, but for now:

ONE - SCHEDULING;

This is the big one. Now, Uam is definitely really helpful. I tried to write a simple shader a while back, by converting my own code to raw bytes- but figuring out how to write the scheduling instructions kinda killed it for me. And if I ignored them, it gave me weird and awful results in game.

But when I tried using Uam, the scheduling instructions seemed to work like a dream.

However...it isn't perfect, and I'm unsure of it's limitations.

I've recently annotated a giant shader with hundreds of variables, and as a test, I modified it to fit within the length limit, before converting it via Uam. And after some tweaking to get the texture names and calls to c1 right, I put it back into the game.

And....it MOSTLY worked like I expected it to.

Mostly being the operative word.

While in general it was what I expected, with big enough models, some of it would have...the best way I can describe it, is static. It looks similar to Z-fighting (though I doubt it is Z-fighting, given I didn't do any model editing), and is something I think I saw when I was trying to write the binary manually.

In other words, while it's mostly accurate, that "static" of sorts is still there, I think is likely to do with scheduling.

Let me be clear: I am not mocking Uam for being bad at scheduling or anything. It's still a godsend, something I could only dream of writing, and it's really difficult in general to not only reverse engineer formats, but make your own compilers.

However, given that, I do want to ask about well....the more specific strengths and weaknesses, boundaries and limitations, of Uam's scheduling.
Currently the only way for me to figure out those things is by trial and error, so I'd like to ask about them directly. What can it do, what can't it do, and what are the best ways to make sure no scheduling issues occur?

That leads us to

TWO: OPTIMIZATION

All the questions I have about the scheduling also apply to optimization.

Smash Ultimate's Shaders have a length limit per shader, and nobody has figured out how to change said limit yet. And usually, converting the binary to glsl, and then converting that glsl back to binary (via Uam) ends up with binary that's longer than the original.

Which again, I fully get. We aren't going to get as optimized as the original tools for a LONG time, that's a given.

However, when I was cutting down the annotated code mentioned earlier in order to fit within said length limit (by making it only use 1 channel from the actual color texture), I noticed that it was still a bit above what I expected from Uam in terms of size.

But on a hunch, I tried rewriting it - specifically by making more things use FMA - and it started to shrink down. Eventually, to the point that I was able to get it back to the length limit.

But like scheduling, that begs the question of how it works. What are the best optimizations for the compiler? What tips should I know when writing code for it? What does it already do in terms of optimization? What shouldn't I do? Etc etc etc.

Like with scheduling, the only way I can tell is through trial and error, so I would rather try asking directly.

Again, not knocking Uam here, I just want to ask for the best methods to use in terms of that.

and finally (for now)

THREE: TEXTURE NAMES

For some reason, Uam does seem to mess up the texture names. The binary to glsl converter I'm working with, ryujinx.shadertools, has all texture names converted to "fp_tex_tcb_X", with X being the value its marked with in the code. But when I compile something with Uam and view it in envydis or convert it via ryujinx.shadertools, it has the format of '1AY", with Y being a completely different value.

Now, while I got that fp_tex_tcb_X format wouldn't be read, I then tried tex_X, textureX, and texture_X, and it still didn't work. So I have no clue what I should write in order for uam to compile it with the correct values.

So do I want to ask how that works, and how I should name em in order to get those correct values.

CONCLUSION:

I'm sorry for the length of this, I am....very long winded as a person. But yeah, I wanted to actually just try to ask all this and hope I get an answer. Please LMK if there is a better way to contact you or ask this sorta thing. Sent ya a twitter follow, if that helps.

And apologies if there are other people working on Uam besides Fincs. They're the only one I saw listed besides DevKitPro themselves, but yeah.

Either way, thank you, and I hope to hear back from you soon.

-Trainmaster

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

No branches or pull requests

1 participant