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

[WIP] Implement minimal support for TMEM caching, enough for Spyro: Heros Tail #3749

Closed
wants to merge 1 commit into from

Conversation

phire
Copy link
Member

@phire phire commented Mar 26, 2016

If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use.


This change is Reviewable

@phire
Copy link
Member Author

phire commented Mar 26, 2016

Ideally we could skip all hashing for textures until the game invalidates the relevant TMEM sub-cache. but that would require a much larger implementation to track which textures are stored in which caches. We also don't know if games correctly invalidate TMEM whenever they replace a texture, or if some games might rely on textures naturally getting evicted by intermediate draw calls.

This Initial is based on catching those cases where the fact that the game hasn't invalidated TMEM is guaranteed to cause a visual glitch if the memory backing the texture has changed and assuming that it didn't change. If absolutely anything about a texture changes (format, etc) we re-load it.

Note: This currently has one "exploitable" flaw. If two texture units are pointing at the same sub-cache within TMEM (which this PR doesn't check) but only one texture was used in the previous drawcall, then the second texture was likely be pushed out and a game might get-away with safely assuming that second texture was invalidated.

@lioncash lioncash added the WIP / do not merge Work in progress (do not merge) label Mar 26, 2016
@JMC47
Copy link
Contributor

JMC47 commented Mar 30, 2016

Seems to break Cel-Damage and other games; they seem to lose their textures.

@BhaaLseN
Copy link
Member

Does it make sense to turn that 0xff into a constant? It appears all over the place and looks like an address or a mask, but I'd generally go for a named constant or at least comment to help others while reading the code.

@phire
Copy link
Member Author

phire commented Mar 30, 2016

it's a bitmap with all 8 bits set.

I should probably use BitSet instead.

If none of the texture registers have changed, we can blindly reuse
the old textures without rehashing.
@phire phire force-pushed the minimal_tmem_cache_support branch from 3889283 to cfd640d Compare June 16, 2016 06:10
@phire
Copy link
Member Author

phire commented Jun 16, 2016

Rebased

@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • spyro-bloom on ogl-lin-intel: diff
  • spyro-depth on ogl-lin-intel: diff
  • spyro-bloom on ogl-lin-mesa: diff
  • spyro-depth on ogl-lin-mesa: diff

automated-fifoci-reporter

@RisingFog
Copy link
Member

This PR needs to be rebased.

@mimimi085181
Copy link
Contributor

I don't understand how this makes games lose textures. Shouldn't it either reuse an existing texture from the cache, or fall back like usual to creating it?

It sounds a bit like somehow there's a texture created at the offset from empty data and then the data is written, but that change somehow does not invalidate the cache?

@GitToTheHub
Copy link

Is that ready to merge?

@JosJuice
Copy link
Member

@GitToTheHub It says WIP and even has merge conflicts. I would say no.

@GitToTheHub
Copy link

thanks i saw that, i was only wondering that nothing more happen since June

mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jun 29, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jun 30, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 1, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 2, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 2, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 2, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 2, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
@phire
Copy link
Member Author

phire commented Jul 4, 2017

This has been superseded by #5718

@phire phire closed this Jul 4, 2017
@mimimi085181
Copy link
Contributor

For future reference, the pr that replaces this pr is: #5726

mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 5, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 6, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 6, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 8, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 9, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Jul 10, 2017
This is a remake of dolphin-emu#3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Aug 12, 2017
This is just the optimisation that was ripped out of the original tmem pr from phire: dolphin-emu#3749

I'm curious, if it just works like that.

PS: Somebody should check, if i did the bitset stuff right.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Aug 12, 2017
This is just the optimisation that was ripped out of the original tmem pr from phire: dolphin-emu#3749

I'm curious, if it just works like that.

PS: Somebody should check, if i did the bitset stuff right.
mimimi085181 added a commit to mimimi085181/dolphin that referenced this pull request Aug 13, 2017
This is just the optimisation that was ripped out of the original tmem pr from phire: dolphin-emu#3749

I'm curious, if it just works like that.

PS: Somebody should check, if i did the bitset stuff right.
@phire phire deleted the minimal_tmem_cache_support branch February 2, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP / do not merge Work in progress (do not merge)
9 participants