Commit graph

164 commits

Author SHA1 Message Date
mimimi085181
4e8ff42503 Do not load overwritten textures by hash
In this case, comparing the hash is not enough to check, if two textures are identical.
2017-08-06 03:13:57 +02:00
mimimi085181
a21ac22e07 fix stored memory stride for normal textures 2017-08-06 03:13:57 +02:00
N.E.C
c3a57bbad5 Video: Clearly separate Texture and EFB Copy formats
Improve bookkeeping around formats. Hopefully make code less confusing.

- Rename TlutFormat -> TLUTFormat to follow conventions.
- Use enum classes to prevent using a Texture format where an EFB Copy format
  is expected or vice-versa.
- Use common EFBCopyFormat names regardless of depth and YUV configurations.
2017-08-03 18:35:29 -07:00
Anthony
ab5a5ee3ea Merge pull request #5726 from mimimi085181/minimal-tmem-cache-emulation
Implement minimal emulation of TMEM caching
2017-07-11 22:49:19 -07:00
mimimi085181
53663c00b9 Implement minimal emulation of TMEM caching
This is a remake of https://github.com/dolphin-emu/dolphin/pull/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.
2017-07-10 01:49:27 +02:00
JosJuice
5ca3aee00a FileUtil: Add a class for Exists/IsDirectory/GetSize
Some code was calling more than one of these functions in a row
(in particular, FileUtil.cpp itself did it a lot...), which is
a waste since it's possible to call stat a single time and then
read all three values from the stat struct. This commit adds a
File::FileInfo class that calls stat once on construction and
then lets Exists/IsDirectory/GetSize be executed very quickly.

The performance improvement mostly matters for functions that
can be handling a lot of files, such as File::ScanDirectoryTree.

I've also done some cleanup in code that uses these functions.
For instance, some code had checks like !Exists() || !IsDirectory(),
which is functionally equivalent to !IsDirectory(), and some
code was using File::GetSize even though there was an IOFile
object that the code could call GetSize on.
2017-06-29 19:07:29 +02:00
iwubcode
e4896d39bd Video Backends: Move and rename HostTextureFormat to AbstractTextureFormat 2017-06-13 00:41:56 -05:00
iwubcode
2cdc93f4ab Video Backends: Split texture cache code out into separate files, introduce 'AbstractTexture' 2017-06-13 00:41:51 -05:00
Shawn Hoffman
e1a3e41bf3 fix various instances of -1 being assigned to unsigned types 2017-06-07 19:52:07 -07:00
Stenzek
cc851c41c1 TextureCache: Move host texture utility functions to VideoCommon
The appropriate place for these would be AbstractTexture, once it is
finished.
2017-04-29 13:46:43 +10:00
Stenzek
f4b848949c TextureCache: Support compressed textures and pass pitch/size to upload
This also removes an extra copy of the image for custom textures.
2017-04-29 00:14:23 +10:00
Stenzek
e9850aa0f2 VideoBackends: Support updated texture encoding shader generators 2017-04-12 00:11:22 +10:00
Anthony
c6b553b6d2 Merge pull request #5220 from stenzek/small-nonsquare-mips
TextureCache: Fix incomplete GPU texture decoding of non-square mips
2017-04-09 13:45:38 -07:00
Stenzek
2492f196a7 TextureCache: Fix incomplete GPU texture decoding of non-square mips 2017-04-07 23:03:14 +10:00
Michael Maltese
cef5bd4a09 TextureCacheBase: remove duplicated variable
Fixes warning:

```
Source/Core/VideoCommon/TextureCacheBase.cpp:869:17: warning: declaration shadows a local variable [-Wshadow]
      const u8* tlut = &texMem[tlutaddr];
                ^
Source/Core/VideoCommon/TextureCacheBase.cpp:784:13: note: previous declaration is here
  const u8* tlut = &texMem[tlutaddr];
            ^
```
2017-04-06 13:52:42 -07:00
Michael Maltese
e9e3226026 TextureCacheBase: fix custom textures not being loaded
Fixes bug #10183 [0] introduced by 3bd184a / PR #4467 [1].

TextureCacheBase was no longer calling `entry->Load` for custom textures
since the compute shader decoding logic was added. This adds it back in.
It also slightly restructures the decoding if-group to match the one
below, which I think makes the logic more obvious.

(recommend viewing with `git diff -b` to ignore the indentation changes)

[0]: https://bugs.dolphin-emu.org/issues/10183
[1]: https://github.com/dolphin-emu/dolphin/pull/4467
2017-04-04 14:34:46 -07:00
Stenzek
79ba946d70 VideoCommon: Changes to TextureCache to support decoding in backend 2017-04-01 12:32:10 +10:00
Lioncash
57c21b9576 TextureCacheBase: Convert bound_textures from a C array to a std::array
Prevents array-to-pointer decay and simplifies some code.
2017-03-25 14:53:25 -04:00
degasus
ca8d9e2215 TextureCache: Don't lock freed rendertargets for one frame.
New Super Mario Bros on PAL still renders at 60 fps, but skips every 5th XFB copy.
So our detection of "per frame" fails, and we require twice the amound of texture objects.
But our pool frees unused textures after 3 frames, so half of them needs to be reallocated
every few frames.

This commit removes the lock for render targets. It was introduced to not update a texture
while it is still in use. But render targets aren't updated while rendering, so this
lock isn't needed. Non-rendertarget textures however aren't as dynamic, so the lock should
have no performance update.
2017-03-22 23:28:42 +01:00
Markus Wick
ef74c5eabd Merge pull request #5051 from stenzek/renderer-fixes
VideoBackends: Fix crashes introduced by #4999
2017-03-09 21:06:50 +01:00
JosJuice
ced1614cac Unify the way of setting game ID, title ID, revision
The existing code from ConfigManager, ES and MIOS is merged
into a new set of functions called SetRunningGameMetadata.
2017-03-09 15:34:14 +01:00
Stenzek
2cd240af0d VideoBackends: Move max texture size to VideoConfig
This stops the virtual method call from within the Renderer constructor.

The initialization here for GL had to be moved to VideoBackend, as the
Renderer constructor will not have been executed before the value is
required.
2017-03-10 00:04:13 +10:00
Stenzek
277829d842 VideoCommon: Eliminate static state in Renderer 2017-03-04 16:39:50 +10:00
degasus
d0a73c1d90 TextureCache: Add a dirty bit for partial updates on overlapping EFB copies. 2016-12-27 17:26:04 +01:00
degasus
abf9bb170b TextureCache: Drop unused parameter in backend API. 2016-12-26 22:10:32 +01:00
degasus
04f319066d TextureCache: Extract BP enum check to VideoCommon.
We have TOO many video backends.
2016-12-26 22:10:21 +01:00
Tillmann Karras
44acd9fdb9 VideoCommon: use u32 for texture addresses 2016-12-25 18:48:19 +01:00
Mat M
9160be50db Merge pull request #4224 from lioncash/tcache
TextureCacheBase: Eliminate static state
2016-12-23 04:33:42 -05:00
Stenzek
accce4294a TextureCache: Use same color coefficients for EFB2Tex as EFB2RAM 2016-12-15 02:20:46 +10:00
Lioncash
58a5395173 TextureCacheBase: Eliminate static state 2016-12-09 16:50:37 -05:00
Léo Lam
31ccfffd38 Common: Add alignment header
Gets rid of duplicated alignment code.
2016-12-06 20:33:53 +01:00
JosJuice
1081497cad DiscIO/SConfig: Rename GetUniqueID to GetGameID
We call this "game ID" everywhere else, and it's not
actually completely unique.
2016-10-29 15:24:02 +02:00
Stenzek
b6d09c61ed TextureCache: Don't re-use pooled textures within the same frame
This is an issue because a driver may have to maintain two copies of a
texture if it batches all uploads together at the start of a frame.

In the Vulkan backend, we do something similar to avoid breaking out of a
render pass to copy a texture from the streaming buffer to the destination
image.

This was causing issues in the sms-bubbles fifolog, where an EFB copy to
the same address of a previously-used texture caused the previous texture
to be re-used again for a different image later on in the frame, causing
the original contents to be discarded.
2016-10-06 20:23:37 +10:00
Stenzek
828aac7890 VideoBackends: Make TextureCache::CompileShaders return a bool 2016-10-01 01:09:12 +10:00
Jules Blok
92920c4005 TextureCacheBase: Address 0x0 is valid, don't you dare ignore it. 2016-08-30 16:45:49 +02:00
Lioncash
e01c143379 Common: namespace MemoryUtil 2016-08-07 13:03:07 -04:00
Pierre Bourdon
3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Scott Mansell
96ab76f81d TextureCache: Rename functions and add comments to clear up docs 2016-06-18 04:27:16 +12:00
Scott Mansell
94eaacae30 TextureCache: Track efb copies used in a partially updated texture
Fixes a major preformance regression in Skies of Arcadia during
battle transisions.

I had plans for a more advanced version of this code after 5.0,
but here is a minimal implemenation for now.
2016-06-17 23:46:22 +12:00
mimimi085181
9f625417c0 Partial updates for paletted textures
This pr fixes another regression that happened after pr #3165 was merged. The shadows in mario baseball should now work again.
2016-04-09 18:22:36 +02:00
Pierre Bourdon
e98fb0af84 Merge pull request #3752 from mimimi085181/remove-use-only-once-restriction-partial-updates
Remove the restriction to use efb copies only once as partial update
2016-04-09 18:10:20 +02:00
mimimi085181
befb2e4809 Partial texture updates: Allow the efb copy to start before the texture
This is an oversight from pr https://github.com/dolphin-emu/dolphin/pull/3266 . Thanks to degasus for pointing this out.

It's possible that MAX_TEXTURE_BINARY_SIZE can be optimised, but i wanted to play it safe considering the 5.0 stable release.
2016-04-02 20:34:49 +02:00
mimimi085181
2dd9e6bfe2 Remove the restriction to apply efb copies only once as partial update
I'm not entirely sure what is happening, but this optimisation is causing an issue in Sonic Riders: Zero Gravity. Apparently the issue would also be fixed by PR#3747, but this PR should also fix similar issues.

Games that use partial updates might get slower with this, so some performance regression testing would be nice. Games like New Super Mario Bros, RS2, Zelda TP and Silent Hill. Testing with high graphics settings makes sense, since this would mostly end up in more work for the GPU.
2016-03-27 04:13:20 +02:00
EmptyChaos
0b9a72a62d VideoCommon: Refactor TexMode0 mipmaps disabled test into a helper function 2016-03-24 13:43:29 +11:00
mimimi085181
e4f984d5dd Minor fixes to the partial updates code
- remove an outdated comment about the efb to ram and scaled efb restriction
- when upscaling efb copies, mark the new texture as efb copy
- dx12 fixes for the src box, especially the number of layers for 3D
2016-03-16 22:24:11 +01:00
mimimi085181
80250f47e9 Partial texture updates with parts of efb copies new version 2016-03-16 22:24:10 +01:00
mimimi085181
bb4d636f34 Copy all layers of textures with CopyRectangleFromTexture 2016-02-14 21:17:06 +01:00
mimimi085181
99555a35ca For partial texture updates check the dimensions of the efb copy and the target texture, not just the binary size.
This should get Donkey Kong Country Returns characters to be as broken as they should be. They will be fixed in a later pr.

Expected result is:
efbtex: characters are always flickering or invisible, no matter what scaling or IR setting
efb2ram: characters are always working properly at 1xIR, no matter what scaling or IR setting
2016-02-14 17:13:51 +01:00
Pierre Bourdon
cf20ff48aa Merge pull request #3480 from phire/memory_stride_too_small
Avoid the "Memory stride too small" assert
2016-01-30 13:11:07 +01:00
Lioncash
d9fec92628 VideoCommon: Header cleanup
Also remedies places where the video backends and core rely on things
being indirectly included.
2016-01-17 20:11:45 -05:00