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

Automatic game hacks #1894

Closed
mirh opened this issue Apr 9, 2017 · 39 comments
Closed

Automatic game hacks #1894

mirh opened this issue Apr 9, 2017 · 39 comments

Comments

@mirh
Copy link

mirh commented Apr 9, 2017

Yes, I know, people wisdom and will is crap.
And yes, I realize in some cases we are in situations comparable to a triangle, with speed, accuracy and "neatness" on the opposite vertices.
But it's also undeniable that in others, enabling them (for as much "dirty as mud") it's a no brainer. And really, it starts to feel like a joke for people to wander forums and do the same guesswork over and over again separately.

And looking at how nicely #1874 has been executed, I was dreaming a similar "automatic preset" for hacks too (handled in gameindex together with gamefixes perhaps?)
Or at least some way, link, note, whatever for ANY average joe to at least take notice he can do something.
It's depressing to see how many people just crank up resolution, and then complains even it the issue had been worked around ages before.

EDIT: supposedly Dolphin calls this "Game INIs"

@gregory38
Copy link
Contributor

Gameindex is already a huge file to handle in GIT. If we really put a database, it would be better to store it in a more efficient format. But eventually a solution to handle per game setting would be nice.

@mirh
Copy link
Author

mirh commented Apr 19, 2017

Gameindex is already a huge file to handle in GIT.

Indeed. But either we drop the "editable/readble by people" criteria, or otherwise I don't see how in the world a 5000 entries X 10 lines each X let's say 20 characters could fit in less than the actual ~1MB.

Reorganizing it as I mentioned in #1893 could quite potentially fix some redundancy (who knows, perhaps in the same order of magnitude of the additions for hacks we'd have to make) then, but with time I'm sure it will still grow.
With these assumptions, and if the problem is just with git being a bit of a PITA for large files.. Perhaps LFS and/or a separate repo just for the database might be the answer?

@gregory38
Copy link
Contributor

Yeah, I know. But the fact is that last time I listed the big entry in .git (I don't remember how). This file got easily 15 entries on the top 20. I'm not sure that I want to handle a GB history for it.

@mirh
Copy link
Author

mirh commented Apr 19, 2017

Oh, in that sense, yeah I see it being a massive problem.
But.. Shouldn't git be supposed to just store differences [at least for plain text files]?

@gregory38
Copy link
Contributor

Top 100 in reverse (bigger file at the bottom)

1219134 bin/GameIndex.dbf
1219293 bin/GameIndex.dbf
1224166 bin/GameIndex.dbf
1224166 bin/GameIndex.dbf
1224243 bin/GameIndex.dbf
1225608 bin/GameIndex.dbf
1225622 bin/GameIndex.dbf
1225745 bin/GameIndex.dbf
1226961 bin/GameIndex.dbf
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p01_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p02_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p03_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p04_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p06_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p07_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p08_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p09_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p10_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p11_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p12_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p13_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p14_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p15_shape24.bmp
1228938 3rdparty/SDL-1.3.0-5387/test/shapes/p16_shape24.bmp
1245982 bin/GameIndex.dbf
1247291 bin/GameIndex.dbf
1247544 bin/GameIndex.dbf
1247805 bin/GameIndex.dbf
1247822 bin/GameIndex.dbf
1247843 bin/GameIndex.dbf
1247899 bin/GameIndex.dbf
1248091 bin/GameIndex.dbf
1248129 bin/GameIndex.dbf
1248168 bin/GameIndex.dbf
1248960 bin/GameIndex.dbf
1248990 bin/GameIndex.dbf
1249565 bin/GameIndex.dbf
1249620 bin/GameIndex.dbf
1249637 bin/GameIndex.dbf
1249669 bin/GameIndex.dbf
1249769 bin/GameIndex.dbf
1249842 bin/GameIndex.dbf
1249886 bin/GameIndex.dbf
1249908 bin/GameIndex.dbf
1249927 bin/GameIndex.dbf
1249939 bin/GameIndex.dbf
1249949 bin/GameIndex.dbf
1249965 bin/GameIndex.dbf
1249981 bin/GameIndex.dbf
1249997 bin/GameIndex.dbf
1250067 bin/GameIndex.dbf
1250137 bin/GameIndex.dbf
1250138 bin/GameIndex.dbf
1250334 bin/GameIndex.dbf
1250370 bin/GameIndex.dbf
1250435 bin/GameIndex.dbf
1251175 bin/GameIndex.dbf
1251398 bin/GameIndex.dbf
1251533 bin/GameIndex.dbf
1251534 bin/GameIndex.dbf
1251543 bin/GameIndex.dbf
1251656 bin/GameIndex.dbf
1251783 bin/GameIndex.dbf
1251791 bin/GameIndex.dbf
1251855 bin/GameIndex.dbf
1251926 bin/GameIndex.dbf
1252097 bin/GameIndex.dbf
1252904 bin/GameIndex.dbf
1253511 bin/GameIndex.dbf
1253665 bin/GameIndex.dbf
1254253 bin/GameIndex.dbf
1254573 bin/GameIndex.dbf
1254750 bin/GameIndex.dbf
1254805 bin/GameIndex.dbf
1254932 bin/GameIndex.dbf
1254932 bin/GameIndex.dbf
1254996 bin/GameIndex.dbf
1255658 bin/GameIndex.dbf
1255697 bin/GameIndex.dbf
1258683 bin/GameIndex.dbf
1258812 bin/GameIndex.dbf
1258994 bin/GameIndex.dbf
1260064 bin/GameIndex.dbf
1260069 bin/GameIndex.dbf
1260171 bin/GameIndex.dbf
1260224 bin/GameIndex.dbf
1260338 bin/GameIndex.dbf
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p01_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p02_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p04_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p06_shape1alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p06_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p07_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p08_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p09_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p10_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p11_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p13_shape32alpha.bmp
1638538 3rdparty/SDL-1.3.0-5387/test/shapes/p15_shape32alpha.bmp
3457692 plugins/zerogs/dx/Windows/ps2fx.dat

Generated by

git rev-list --all --objects | \
    sed -n $(git rev-list --objects --all | \
    cut -f1 -d' ' | \
    git cat-file --batch-check | \
    grep blob | \
    sort -n -k 3 | \
    tail -n100 | \
    while read hash type size; do
         echo -n "-e s/$hash/$size/p ";
    done) | \
    sort -n -k1

@gregory38
Copy link
Contributor

 But.. Shouldn't git be supposed to just store differences [at least for plain text files]?

It is more complicated :)

@mirh
Copy link
Author

mirh commented Apr 19, 2017

=D

@avih
Copy link
Contributor

avih commented Apr 19, 2017

Top 100 in reverse

Top 100 what? surely all the GameIndex.dbf updates are tiny diffs, are they not?

[edit]
Also, surely this list is incorrect, because it should have had the really bad updates of cheats_ws.zip - that's really binary update and each time it's a new ~600K blob (which is the main reason I wait at least 6 months between updates). But I don't see it on the list so I think the list is incorrect.

@gregory38
Copy link
Contributor

gregory38 commented Apr 19, 2017

yeah there is something fishy. 100 * 1MB give us a size biger than .git/objects

@gregory38
Copy link
Contributor

ok I was wrong. You can forgot what I said.

@avih
Copy link
Contributor

avih commented Apr 20, 2017

ok I was wrong. You can forgot what I said.

Wrong about what?

Regardless, I think we should get back to square one and evaluate this thing from the beginning.

  1. What do "automatic game hacks" do? Can you give an example of such hacks for few games and describe what they do?

  2. Do we have a list of "game hacks" or of games which could benefit from it? If not, where from do we collect the info about which games could use such hacks? Can we estimate how many games roughly are we talking about?

Once we have those, we'd have a better picture of the scope and usefulness of this thing, and then be able to make a better decision on whether we want it, and if yes, then we can discuss where to store the info etc. But for now, we're not there yet. So let's start by answering 1 and 2 and get a clearer picture first.

This whole hoo-ha on GameIndex.dbf was a bit premature IMO.

@gregory38
Copy link
Contributor

The above command doesn't show the real size of the object inside the pack format. But instead the size when they're unpacked. I'm prefer to be cautious than sorry. Git history is nearly 100MB already.

@avih
Copy link
Contributor

avih commented Apr 20, 2017

I'm prefer to be cautious than sorry.

About what? I don't see (yet) anything which suggested we will end up doing big updates...

@gregory38
Copy link
Contributor

I was afraid that any update on the db will end up to a big increase of the git history (due to the big size of the file). But I was misleading by some git command.

@avih
Copy link
Contributor

avih commented Apr 20, 2017

Ah. I think that very roughly the extra size a commit adds to the repo is proportional to the patch size, possibly compressed. But then I'm not even sure it could be calculated exactly because git may repack objects to store them more efficiently.

Specifically for the games db updates, I doubt very highly that "normal" games db commits add anything meaningful to the repo size (the initial commits could have been big, because a lot of data, but from then it's incremental).

But then again, we're not there yet. I'm still at "what the heck is this issue about?" part.

@willkuer
Copy link
Contributor

The main point is that gsdx has a lot of settungs changing the output. The amount of settings and their labels/descriptions are highly confusing for new users. However with the recent development these settings improve the output accuracy significantly so that default settings are far from optimal settings.

The question is whether it is worth to create a new database to store optimal settings for each game similiarly as it is currently done with the gameindex.dbf. gsdx so far handled all these game specific settings in a hard coded way as crc hacks. However I'd believe not all settings can be handled by the crc hack system and doing it in a hard coded way in the binary might not be the best idea.

IMO settings are currently changing too fast. A new setting appears every second week and old settings are reworked or eliminated. Creating a game specific database makes currently no sense as it would've been outdated after a couple of days. One first needs to wait till gregory finishes his master plan for gsdx accuracy vs hacks and then one could consider it.

@mirh
Copy link
Author

mirh commented Apr 20, 2017

What do "automatic game hacks" do? Can you give an example of such hacks for few games and describe what they do?

First link in the OP.

Can we estimate how many games roughly are we talking about?

Is there a single ps2 game that hasn't "rough spots"? :s

Once we have those, we'd have a better picture of the scope and usefulness of this thing

Gsdx hacks are the first thing that comes to my mind, but we may as well throw in just anything else that is hackable

Then, on the specific [gsdx] implementation, I'm not sure. Arguably some hacks become "positive" only once certain others ones are enabled (e.g. sprite hacks after increase of resolution), so some way to conditionally enable them would be required.
Thankfully this hasn't necessarily to reside in database (e.g. gsdx "greys out" aforementioned sprite hack on native).
We could eventually generalize #1874 setting to comprehend anything in HW settings but resolution possibly (perhaps I'm wandering too much now)

Performance would be at stake in some cases, absolutely true and arguable on forums. As I was saying in the OP though, there are many, many other cases where enabling a hack is a no brainer.

One first needs to wait till gregory finishes his master plan for gsdx accuracy vs hacks and then one could consider it.

You might have a point, but anyway this doesn't block the "backend" to be developed in the meantime.

The question is whether it is worth to create a new database to store optimal settings for each game similiarly as it is currently done with the gameindex.dbf.

I never mentioned a new database. It seems a waste tbh considering:

  1. parts of the infrastructure is already there (VU rounding modes iirc)
  2. you would duplicate a big deal of information already in gameindex

@avih
Copy link
Contributor

avih commented Apr 20, 2017

So, so basically this issue is about gsdx game fixes per game, and storing them in a db, while possibly moving also some/all the crc hacks to that db?

Or is mostly about just moving the crc hacks from the gsdx source files to a separate db file which can be edited without compiling gsdx?

Specifically WRT the crc hacks, this might not be trivial because many of them involve actual logic, i.e. programming, which would be hard to support with a "db" file, IMHO.

@avih
Copy link
Contributor

avih commented Apr 20, 2017

Specifically WRT the crc hacks, this might not be trivial because many of them involve actual logic, i.e. programming, which would be hard to support with a "db" file, IMHO.

Not trivial but not impossible either, and I even created a proof of concept exactly for developing CRC hacks without recompiling gsdx, and even edit them while the game is running to see their effect in real time.

It's at https://github.com/PCSX2/pcsx2/tree/master/tools/dynacrchack and I haven't tried it for a while. In a nutshell, you run PCSX2, and then:

  • Edit a C source code of the CRC hack.
  • Save it.
  • The save triggers a compile of the crc hack into a dll.
  • gsdx recognizes that the crc hack dll has changed, and reloads the newly compiled dll.
  • You view if your changes worked, and if required, goto step 1.

All while pcsx2 keeps running.

@avih
Copy link
Contributor

avih commented Apr 20, 2017

It's at https://github.com/PCSX2/pcsx2/tree/master/tools/dynacrchack and ...

And even with this extremely ugly (though potentially useful) hack, it can only do the "normal" crc hacks. There are many more lines of code scattered inside GSdx where it checks if the CRC is whatever and does something a little differently as a result. These would most likely be very difficult to move to an external file.

In general, the only way we can do this IMO for gsdx is:

  1. Only for "normal" crc hacks.
  2. It has to be written in some programming language and not some "values" db.
  3. We'd have to interpret or compile it at runtime (possibly only once on load).

So my guess is that this won't happen. But it's still possible. If someone wants to consider this, tcc (the compiler i used for that hack) is ~300k for windows including the include files, etc, and it should not be hard to either distribute it with pcsx2 (windwos only) or use it as a library which pcsx2 uses to compile the crc hacks in runtime.

Another option is a scripting language like lua or javascript, in which the hacks will be programmed. There are good small libraries which pcsx2 can use, but it'd likely be a bit slower than compiling c code (however, the normal crc hacks are not hot code, so the perf impact could be quite small).

But my guess - not gonna happen.

@willkuer
Copy link
Contributor

I think the current implementation of crc hacks is just fine. Using github, necessary updates are really easy to implement. It is more about all the UserHack_* type of settings.

I think reusing the gamedbf for a plugin is not a good idea. Especially considering that a user can have/use several versions of the same plugin while the gamedbf disregards plugin versioning. It also sounds inconsequent to implement something in the core db for a plugin.

IMO the only option would be to have a tickbox in gsdx plugin settings 'Use automatic HW/SW hacks' that most other settings disable/grey out. Then upon gsdx load the gsdx version and game specific game db (of type key=>value) overwrites all settings of type UserHack_* if the switch is enabled.

Implementation should be farely easy. Creating and maintaining the knowledge/data base too much effort for such a small team.

@avih
Copy link
Contributor

avih commented Apr 20, 2017

It is more about all the UserHack_* type of settings.

That's why I asked to be more specific about what's this about. Sure, specific config options per game to improve the user experience is doable.

Regardless, implementing JS scripting as live crc hacks code would have been fun :p

@mirh
Copy link
Author

mirh commented Apr 20, 2017

I'm not sure what's the problem with CRC hacks where they already are.
Especially, since they seem a lot more specific than normal userhacks.

Especially considering that a user can have/use several versions of the same plugin while the gamedbf disregards plugin versioning.

But gamedbf is only shipped together with X gsdx version.

It also sounds inconsequent to implement something in the core db for a plugin.

The "hack implementation" itself may be of course plugin specific, I see it. And even though gsdx is de facto the only one, "coherency" is still a good point.
BUT I'm not sure it would be physically possible to workaround some (if not all?) bugs otherwise, if I can explain.

In other words, I mean, if the game was originally programmed to have screen divided in tiles, with borders not visible on native resolution just by miracle, and then you proceed upsampling/scaling..
ZeroGS, gsdx, whatever.. Would it matter? Is it not really something game-specific and related in the end?

If any I'd see the point in using "neutral" "tags" in the database, like "has shifted pixels", or "requires flushing".

Creating and maintaining the knowledge/data base too much effort for such a small team.

If nobody creates it.. There won't be any difference from now. If somebody put its effort into it instead, profit.
Even if we kept a very extremely conservative stance on the matter (like, when hacks get reworked a little, comment/remove all corresponding entries until retested) that'd still be an improvement..
Even though:

  • I don't really see the need for this excessive testing at least in git (you know what I mean :*)
  • if "tags" are made "neutral" it won't nevertheless change the fact that the game still need them

That's why I asked to be more specific about what's this about. Sure, specific config options per game to improve the user experience is doable.

https://www.reddit.com/r/emulation/comments/56wj30/mipmapping_makes_the_ace_combat_games_run_way/d8osrry/

@gregory38
Copy link
Contributor

CRC hacks mostly depends on Dx state, mostly the depth emulation. (and likely some bug in GL depth too).

I think the main issue (for an user point of view) are "upscaling" hacks.

@lightningterror
Copy link
Contributor

lightningterror commented Jul 5, 2017

Many issues arise from up scaling hence I don't think it would be a good idea to have such list. Some could be useful tho.

However the one option that seems mandatory is HW mipmapping. Since all renderers share the same issue for specific games.
pcsx2 detects serial or crc info and activates mipmapping if configured.

Adding another option to the mipmapping list would be great in combination to the above changes.

Automatic (Default)
Off
Basic
Full

Basically it will work in a similar fashion the crc option does.
@turtleli @ssakash

@PCSX2 PCSX2 deleted a comment from arkhamsaiyan Jul 5, 2017
@mirh
Copy link
Author

mirh commented Jul 5, 2017

Many issues arise from up scaling

... And that's why having the required quirks baked/listed in helps?

However the one option that seems mandatory is HW mipmapping.

The only thing that might tamper with the plan, is when even fixes have problems, and there's some tradeoff of sort (say, accuracy for performance)

Automatic (Default)

Note that we are starting to basically have an automatic setting for just about anything.

@lightningterror
Copy link
Contributor

lightningterror commented Jul 5, 2017

... And that's why having the required quirks baked/listed in helps?

For those issues there needs to be different configs for native and for upscaled.

Note that we are starting to basically have an automatic setting for just about anything.

It's a good thing imo. People won't have to spend time tweaking settings. Making things easier.

@mirh
Copy link
Author

mirh commented Jul 5, 2017

For those issues there needs do be different configs for native and for upscaled.

Of course?
And you can either add some sort of (if !native) parsable section to gameindex - or just leave the burden of knowing when to select stuff to gsdx/core (e.g. align sprite gets always toggled off on native)

It's a good thing imo. People won't have to spend time tweaking settings. Making things easier.

Indeed that's the very point of this issue!
I was pointing out (what I already stated in the OP) that at this point you can as well have a universal "automatic" setting for all gsdx

@lightningterror
Copy link
Contributor

lightningterror commented Nov 28, 2017

I could maybe do something like this for HW hacks ( bow down to my magnificent paint skills )
image

If checked then automatic hw hacks is disabled and you can toggle like you normally do.
If unchecked everything is greyed out. Automatic Hw hacks are enabled.
Just like willkuer said.

Not promising but I can look in to it 😛

@mirh
Copy link
Author

mirh commented Nov 28, 2017

That checkbox there is as magnificently well-fitting as it is half-assed ... :s
The major problem is, figuring out how to handle 'logic'.

Which is not meant to any particular c++ complex crc hacks logic/programming (I think we all agreed they are good where they are)
But just something as simple as to just perform a check on, say, non-native resolutions for example.

My first idea was to add this to gameindex (since.. well, it already lists all games) - but I can see why one would be baffled from adding conditionals and more complexity to an already massive file.
Another similar file would feel redundant though.

@MrCK1
Copy link
Member

MrCK1 commented Nov 28, 2017

I think this will just end up creating more work for everyone and future contributors. I don't like adding things to their own list that then have to be actively maintained and kept up to date while still tracking regressions.

This is too risky IMO, and there's just too many games to worry about.

@mirh
Copy link
Author

mirh commented Nov 28, 2017

I think this will just end up creating more work for everyone and future contributors.

No maintenance, worst case... means we are simply back to current situation. Already discussed here.
I seriously cannot see any downside to this, aside of course of the dev time required.

This is too risky IMO, and there's just too many games to worry about.

Seriously, market this feature well for 1.6, and it's going to be the greatest thing invented since sliced bread.
Somebody could even yell we are almost as good as dolphin

@BlackJoe23
Copy link

It might be easier to implement a per game config setting like in rpcs3. Although I'm not sure how it'd fit in the pcsx2 GUI. The most frustrating thing about the current model is having to switch settings every time you play a different game (unless you spend a bunch of time linking game ini's to shortcuts).

@mirh
Copy link
Author

mirh commented Jan 31, 2018

Yes, per game config is the point of this? I'm not sure where the news would be.
And it would have nothing to do with GUI. We already have a database for games, and there you'll have this.

Anyway, after the discussions in #2265... I'm wondering how many hacks would require a particular "logic", if we can hardcode in gsdx "don't use this or that on native resolutions"?

@BlackJoe23
Copy link

I personally think that not including any more per game config settings would alleviate the large git concerns. So if there was some way to easily edit in the gui that might require way less space and therefore minimize increase in git size since that seems to concern the devs.

@mirh
Copy link
Author

mirh commented Feb 4, 2018

Git size concerns were a dupe, leave those alone.

@lightningterror
Copy link
Contributor

lightningterror commented Aug 3, 2018

While good in theory, realistically this will be a nightmare to maintain. Almost every game needs some kind of game hack. Maintaining GameDB is already difficult as it is.

Per game configuration Spectabis is a better alternative for now.

A real solution would be improving the accuracy, detection .. etc without the need of hacks.

I'll be closing this.

@mirh
Copy link
Author

mirh commented Aug 3, 2018

Good luck improving somehow upscaling?
And there's no maintainability problem if you keep high standards for submissions (plus, the optional external gameindex)

And Spectabis has no general databse that I know of.

@lightningterror
Copy link
Contributor

While it may seem good in theory, reality is it's a nightmare for maintenance.
Upscaling can be improved, it's just a matter of someone having the time, knowledge and will to do it, it will be better to spend time on that rather than adding more hacks to a db.
Besides today default settings already work best.
Anyway will close this.

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

No branches or pull requests

7 participants