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

CustomTexture: new name format #1885

Merged
merged 8 commits into from Jan 22, 2015
Merged

Conversation

degasus
Copy link
Member

@degasus degasus commented Jan 13, 2015

Warning: This will break the hashes for most paletted textures.

@degasus
Copy link
Member Author

degasus commented Jan 13, 2015

@BigheadSMZ have fun testing :D

@BigheadSMZ
Copy link

Just got home and this is taking priority over both shower and supper. I'll report back soon, so excited!!

Edit: Thank you thank you thank you thank you thank you! I never imagined a day where this would be a reality, I've anticipated for so long, and now it's here. This change made my night perfect. Did I mention thank you?! So far it seems to be working with all paletted textures. I'll be testing this and dumping for hours to come, but from what it looks like there will probably no issues to report.

Edit 2: Been redumping and I must say I love this. I already eliminated over 96k duplicate textures... Some behavior I noticed is hash_8 textures are also affected (I knew hash_9 was paletted but never knew hash_8 was?), also not every single texture is affected. Some paletted textures keep their ID, both _8's and _9's, which is strange in some circumstances.

Examples:
http://i.imgur.com/aRXiIK4.jpg - The red box kept the same hash as before but the others did not.
http://i.imgur.com/5asuC9x.jpg - Only 3/10 icons here have a new hash.
http://i.imgur.com/75r9REW.jpg - Almost everything with 8/9 here needs to be redumped.

Outside of that being strange to me because I assume they are from the same palette, everything seems to be working perfect. I have not stumbled onto a single duplicate texture.

@mimimi085181
Copy link
Contributor

@BigheadSMZ :
If a palette uses the full available range, then the hashes from the old and the new method are supposed to be identical.
And also, there's a 3rd kind of paletted textures. This would either be 10 or A, depending on the number system being decimal or hexadecimal for this, which i don't know.

@degasus
Copy link
Member Author

degasus commented Jan 14, 2015

@BigheadSMZ Please don't use edits to update your post after a longer time. If there was a progress, just repost so I'll notice ;)

btw, the _10 format is still broken a lot. The code doesn't calculate the tlut size correct in this case :/

for (size_t i = 0; i < texture_size/2; i++)
{
min = std::min<u32>(min, ((u16*)texture)[i] & 0x3fff);
max = std::max<u32>(max, ((u16*)texture)[i] & 0x3fff);

This comment was marked as off-topic.

@degasus degasus changed the title [WIP] CustomTexture: check for min/max index on paletted textures [WIP] CustomTexture: new name format Jan 14, 2015
@degasus
Copy link
Member Author

degasus commented Jan 14, 2015

@BigheadSMZ Updated with lots of changes. Now all formats did change, but it automatically convert them on the fly. So please make a copy of your texture packs. Does everything still works fine?
Also, do you think the new format is better? We won't be able to change it again within the next years :/

@BigheadSMZ
Copy link

I don't know how the coding side of this looks, but from a users standpoint this is beyond my imagining. No more country code, the original dimensions in the texture, and the hashes seems longer making less chance for two textures to share a name. And the converter, wow. You really outdid yourself. I never imagined any of this when hoping to just see an end to duplicate textures. The original dimensions in the texture is so amazing, something so small but so incredibly convenient!

I have tried to replicate any bugs with the old method of dumping and have not been able to. No matter what options I tick with any accuracy in any order, a texture name is always dumped with the same name. Before I could get a total of 6 different possibilities per texture! Words can't properly express my gratitude for all of this, it feels almost too good and perfect to be true. I have not tested other texture packs yet, but for Xenoblade it's perfect.

The only thing I can think of that remains is allowing more levels of mipmaps, unless that is already done. And a question regarding mipmaps, is how small should the smallest mipmap be, like 8x8, or 4x4, or even all the way down to 1x1? I think once objects are that small the visual difference between 4 and 8 is almost imperceptible, but I should know what Dolphin expects for a minimum.

@BigheadSMZ
Copy link

Ok two things, one is issue with converter and other is something i remembered.

I confirmed what StripTheSoul said here: https://forums.dolphin-emu.org/Thread-hd-retexture-xenoblade-chronicles-hd-texture-pack-v5-7-december-27-2014?pid=353730#pid353730 ... and it seems the converter misses the textures for Sonic Colors (SNCE8P). I redumped a few with Master branch Dolphin and they are indeed dumped correctly ("Fast" accuracy with "Load" checked). This is a very small pack, so redumping this wouldn't be much issue.. but the fact it is missing the textures for this game might mean it affects others.

Another thing I noticed Dolphin has always done is dump frames from movie sequences as textures. This happens in Xenoblade and Sonic Colors and I imagine any game with FMVs. It's not a huge issue if it has no work around, but it can be annoying because some videos in Xenoblade dump like 500 (maybe more?) frames. http://i.imgur.com/X2HI2gl.jpg

Oh and one last thing I could think of, maybe some identifier in the texture name to know if it has mipmaps or not if this is possible? By looking at a custom texture with no mipmaps included, it is hard to tell if it should have them or not.

@degasus
Copy link
Member Author

degasus commented Jan 15, 2015

Using more levels per texture isn't done right now, but it won't affect this PR. So it should be fine to just create all levels right now and it will be used soon. I'd suggest to go down to 1x1. It's not for a visual difference, it's to remove aliasing.
And damn, I've missed to also rename the mipmap textures... Might this be the issue with Sonic Colors? I'll look at this later :/

I'm sorry for videos. Technically, they are just textures. So I doubt a hack is worth to detect this kind of textures. Maybe you want to change the video? Just create a custom texture per frame :D

I'll add a flag if a texture has mipmaps. Sounds good.

@BigheadSMZ
Copy link

I fell asleep way too early last night...

  • For mipmaps, awesome! A flag would be really nice (maybe like tex_m_ or something simple, the names are already kind of long), and it's good to know what to use as smallest dimension, 1x1 is fine if it helps visually.
  • Sonic Colors I'm not sure what's going on, I can't get a result I understand. It just ignores all 22 custom textures for this game for some reason and redumps them. The formats are _5 and _14 (and one _2), but these are working for Xenoblade.
  • Don't worry about the videos, I was just bringing it up in case it was a Dolphin bug. But if they are textures and not an actual video format, then it makes sense that they dump.

So the only outstanding issues I can see is the mystery of the converter ignoring Sonic Colors, and whatever is left with mipmaps.

@degasus
Copy link
Member Author

degasus commented Jan 15, 2015

@BigheadSMZ You can check if the Sonic issue is the same as the mipmap issue if the textures without any "_mip%d" parts are converted but the _mapX textures did stay as they are.

@BigheadSMZ
Copy link

I tested packs for: Kirby Air Ride, Legend of Zelda: Wind Waker, Metal Gear Solid: Twin Snakes, New Super Mario Bros. Wii, Paper Mario: TTYD, Resident Evil 3, Star Wars Rogue Leader: Rogue Squadron II, Super Mario Sunshine, Super Paper Mario, Super Smash Bros. Brawl, Tales of Symphonia, and Xenoblade Chronicles.

All these packs are working as intended and the textures get converted. Sonic Colors is just being stubborn for some reason. Most of the textures in that pack are not ones that use mipmaps so I don't know about this game... It's only 22 textures total so it's not a big issue as all other packs seem to convert just fine.

And one last thing I can think of, if mipmap textures have a flag, is it still worth dumping mipmaps (mip1, mip2, etc)... As long as we know it needs mips and know the min dimensions should be 1, there is not much need to have the dumped mips.

@Tinob
Copy link
Contributor

Tinob commented Jan 15, 2015

Some games use mipmaps to achieve effects like distance attenuation, so they can be different from a normal mipmap.

@degasus
Copy link
Member Author

degasus commented Jan 15, 2015

"m" is now in the filename for mipmap textures.
Converting of mipmaps is implemented but untested right now.

@BigheadSMZ I don't think only dumping the first mipmap is worth. Dumping isn't only for custom texture, it's also for debugging.

How shall we choose if textures should be converted? Is just an ini fine or do you want me to create a gui checkbox?

Still to be discussed: Which hash algorithm shall we use? At the moment we can switch for free.

Shall we also mark this texture in some way which let us detect which format it has? Maybe we're able to change it easier in the future.

@Tinob
Copy link
Contributor

Tinob commented Jan 15, 2015

the hash algorithm is a difficult issue, hardware crc is really fast on intel cpus but gives more collisions than murmurhash3, mumurhash3 is faster than crc on anything older than haswell and on every amd cpu, xxhash shares the same properties of murmur3 and is the fastest, at least on amd and pre-haswell, for new intel’s really don't have the opportunity to compare.

@JMC47
Copy link
Contributor

JMC47 commented Jan 15, 2015

The new CRC is definitely faster on Ivy Bridge and Sandy Bridge, according to my benchmarking... unless the previous usage wasn't murmurhash3? I'd need to have a build with all three options to know for sure.

@degasus
Copy link
Member Author

degasus commented Jan 15, 2015

Mipmaps seems to work fine, also Sonic seems to work fine here, but I have no clue what I've fixed.

@degasus
Copy link
Member Author

degasus commented Jan 15, 2015

Updated with a gfx ini option: "ConvertHiresTextures"
Used "tex1_" as prefix to support new formats in future ("tex2_"...)

I personally have no clue about hashes, so just tell me which one should be used :D

Ready for review?

@degasus degasus changed the title [WIP] CustomTexture: new name format CustomTexture: new name format Jan 15, 2015
@BigheadSMZ
Copy link

Tested several texture packs now and everything seems to working. If you are still open to suggestions, I have only two at this point.

  • It seems all new hashes for all textures have eight 0's in front of them, which seems redundant and just makes the name 8 characters longer (16 for paletted). I don't know if you have something in mind for that or it was intentional but its fine the way it is if it needs to be that way.
  • Second is just a small nitpick and is not important either, but when looking at the textures in a list view having the m after the dimensions for mip textures might be slightly more visually appealing because the numbers line up.

tex1_256x164_00000000cd3c5907_3
tex1_m_256x256_000000009340a099_14
vs
tex1_256x164_00000000cd3c5907_3
tex1_256x256_m_000000009340a099_14

Both of these suggestions are not important at all and I'm happy it works so well and would be content forever in its current state. Thank you for all your hard work, Dolphin and its team never fail to amaze me month after month...

@degasus
Copy link
Member Author

degasus commented Jan 16, 2015

Oh damn, this zeros are a major issue. On linux, they're dumped with 16 digits - but easy to fix: PRIx64...

@degasus
Copy link
Member Author

degasus commented Jan 16, 2015

Both issues should be fixed, build is updated. Are the hashes now 16 digits long?

@BigheadSMZ
Copy link

Yes this format seems perfect now, except maybe typo for underscore in mipmap?

most: tex1_36x36_4653193aaa14d048_0.png
paletted: tex1_200x40_63f3408997969cd6_9a81ceb434acb873_8.png
mipmap: tex1_256x256m__efef240984783a47_14.png

Honestly it looks better that way except the double underscore so maybe this a bonus. Aside from that, I got nothing left at this point, I don't think it can be made much better than this. :)

@degasus
Copy link
Member Author

degasus commented Jan 16, 2015

yeah, it was a typo. It's hard to test such changes with only a webbrowser and the github edit interface...

@BigheadSMZ
Copy link

Tested it out again with the mipmap marker fix, and everything is beautiful. A tear of happiness ran down my cheek. I can't find any more bugs and the converter is working flawlessly with every situation I throw at it. Once again, even if you get sick of hearing it... amazing and thank you!

I would like to make a post in the custom texture section of the forums after this gets merged to master to notify other texture pack authors, unless someone else has this planned. Because I don't understand everything at the level of everyone here, I would appreciate it if someone can verify everything is correct, I'm not missing anything, or if there are better words for what I'm trying to say. I have a rough draft here: http://pastebin.com/FcP3Rsf7

@BhaaLseN
Copy link
Member

Back in 2013, @lioncash implemented it as a replacement for murmur, and we concluded that it didn't make much of a difference. On my Phenom II X4 905e it was mostly either equal or xxhash slightly slower; with very few instances where it was faster (by a margin that could might aswell just be within the statistical error range of the measurements).

@Tinob
Copy link
Contributor

Tinob commented Jan 16, 2015

Murmur is the winner then :)

@PatrickFerry
Copy link
Contributor

On my Haswell G3258 I can only recommend using xxhash over Murmur
I've done a lot of testing with this on different backends/ Audio or without/ different games/ dual core||single core.
You're right intel is good with CRC.
This is one of the examples (D3D/ Single core/ No skipping/ No audio/ A fifolog)
0: CRC: 71 FPS
1: Murmurhash3: 62 FPS
2: xxhash: 68 FPS

@degasus
Copy link
Member Author

degasus commented Jan 17, 2015

So xxhash64 sounds like the fastest one. I'll have to wait for PR #1898

@degasus degasus force-pushed the custom_texture branch 2 times, most recently from 8865d1c to 1d0557a Compare January 21, 2015 20:47
@degasus
Copy link
Member Author

degasus commented Jan 21, 2015

So I think I'm done, new xxhash is in use.

Last call for final review and testing

@BigheadSMZ
Copy link

Out of curiosity. Is it safe to use the latest build in this PR to start converting textures before it gets merged to master so we can get a jump start on it? (...as in, hashes are not going to change again)

Edit: I know you said not to use edits, but this isn't that important and you can just get it when you get it. I'm gonna give this one more batch of testing now for the next few hours and let you know if I find anything wrong.

@degasus
Copy link
Member Author

degasus commented Jan 22, 2015

@BigheadSMZ I don't know why the name should change again, so I think it's fine to start to redump.

@degasus
Copy link
Member Author

degasus commented Jan 22, 2015

@BigheadSMZ Still dumping?

@PatrickFerry
Copy link
Contributor

A couple questions:
Does XXHash have less collisions than what was used forced to safe?
Would dumping take longer with XXhash in externals over a smaller block of code inlined in Dolphin?

@BigheadSMZ
Copy link

I dumped and renamed for about 6 hours straight, and I must say I never get tired of seeing everything textured all the time! Everything seems to work perfectly, I probably have at least 80% of the textures converted, all of them would probably take a full playthrough.

I do have a few questions that all tie into the same answer. Can the two formats work together? Like if I nailed all the paletted textures, could I still include other textures that were previously dumped from fast? Or should I wait until I have everything renamed to release the pack? I'm patient enough to do a full playthrough if I must, but if I can take a shortcut to offer people something quick in the meantime then I'll go that route.

@degasus
Copy link
Member Author

degasus commented Jan 22, 2015

@ZephyrSurfer The generated code would be the same, so we should just care about the maintainance. And the collisions should be better because of u64 hash, but xxhash is about as good as murmur3 here.

@BigheadSMZ Of course, both formats will live together for a while. But as long as both formats are used, we have to hash the texture in both ways. Maybe with a bit more overhead. I think the next stable release must support the old texture format, but I want to remove it quite after the next stable release. I want to merge those max/min calculations of paletted textures into videocommon to reduces redundant uploads. This maybe fixes the metroid prime stuttering :D

@BigheadSMZ
Copy link

That sounds perfect to me! Both me and frozenwings on the forum are starting a playthrough, between both of us we should hopefully hit everything along the way so this backwards compatibility will be awesome until we finish, and hopefully eliminate that massive 2.8GB pack we currently have as soon as possible. All of this is irrelevant to this PR, so in regards to it, there are no issues I could find and everything is working, including renaming mipmaps and deleting duplicates. I can't think of anything else, so from my perspective it looks good to me.

skidau added a commit that referenced this pull request Jan 22, 2015
CustomTexture: new name format
@skidau skidau merged commit d27bd9d into dolphin-emu:master Jan 22, 2015
@Tinob
Copy link
Contributor

Tinob commented Jan 22, 2015

I think there is a small error in the generation of the old hash, you always executes the xor betwen tex and tlut hash but in the old code the xor was only executed when the format needed it.

@degasus
Copy link
Member Author

degasus commented Jan 22, 2015

@Tinob This is a xor with zero, so it should be fine. Else no non-paletted texture could be loaded.

@Tinob
Copy link
Contributor

Tinob commented Jan 22, 2015

:) sorry i was thinking in nxor

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