Commit Graph

278 Commits

Author SHA1 Message Date
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
Stenzek 1f3b90d70a TextureCacheBase: Change CalculateLevelSize to match D3D/OGL sizes
This was causing crashes/driver resets when odd-dimension textures were
being loaded, due to the size we were uploading being larger than the size
of the higher-level texture calculated by the runtime.
2016-01-13 12:54:38 +10:00
Scott Mansell 74b772c3be Avoid the "Memory stride too small" assert
EFB2Tex still has no idea what to do with these weird textures so we
simply disable EFB2Tex when one is encountered.
2016-01-09 18:30:29 +13:00
Markus Wick 8cf078a1a0 Merge pull request #3407 from phire/fix_assert
TextureCache, fix an incorrect assert.
2015-12-29 20:58:24 +01:00
Lioncash e082ebad1a HiresTextures: Remove the need to explicitly free SOIL allocated data 2015-12-29 08:40:17 -05:00
Scott Mansell d8e5d8659e TextureCache, fix an incorrect assert. 2015-12-29 14:25:31 +13:00
Lioncash f295182833 VideoBackends: Simplify initialization and deinitialization of resources
Approximately three or four times now, the issue of pointers being
in an inconsistent state been an issue in the video backend renderers
with regards to tripping up other developers.

Global (ugh) resources are put into a unique_ptr and will always have a
well-defined state of being - null or not null
2015-12-20 22:40:37 -05:00
Scott Mansell 03461915a7 Fix lens flares in Mario Kart Wii. 2015-12-01 05:25:38 +13:00
degasus c9dc5fb376 TextureCache: Allow the backends to return nullptr for textures. 2015-11-24 22:48:55 +01:00
degasus ee2223c4a0 TextureCache: Fix crash for invalid textures. 2015-11-17 23:29:54 +01:00
degasus 087ba5268a TextureCache: Rewrite EFB Copy control flow 2015-11-15 12:02:41 +01:00
degasus dcdf8fd3ce TextureCache: Split efb2ram from efb2tex 2015-11-15 11:59:52 +01:00
Tillmann Karras 2ad901b2da VideoCommon: drop unused variable/setter 2015-11-06 15:43:58 +01:00
Tillmann Karras 81d9cce70c VideoCommon: rename TextureCache to TextureCacheBase 2015-11-06 15:43:58 +01:00
Lioncash c28e3affc5 TextureCacheBase: Change CacheLinesPerRow to BytesPerRow 2015-10-22 08:14:43 -04:00
mimimi085181 ff709247e2 Check the hashes of efb copies before applying them as partial texture updates 2015-10-18 16:36:38 +02:00
mimimi085181 af28934703 Do not delete strided efb copies on load
This hopefully allows to use partial texture updates with strided efb copies that start at the same offset as the loaded texture
2015-10-15 00:45:55 +02:00
mimimi085181 e24b8c4ab7 Respect the stride for efb copies when hashing them 2015-09-26 20:19:02 +02:00
Scott Mansell a355d9868e FifoRecorder: Use Video Common to record efb2ram correctly.
Texture updates have been moved into TextureCache, while
TMEM updates where moved into bpmem. Code for handling
efb2ram updates was added to TextureCache.

There was a bug for preloaded RGBA8 textures, it only copied
half the texture. The TODO was wrong too.
2015-09-22 23:59:16 +12:00
mimimi085181 dd458b554d Fix performance regression in Sonic the Fighters, introduced by PR#2001 2015-09-12 09:12:14 +02:00
Scott Mansell 68b415ba87 Merge pull request #3019 from mimimi085181/store-base-hash
Store the base hash for paletted textures in the texture cache entries
2015-09-12 16:24:29 +12:00
flacs c5685ba53a Merge pull request #2972 from lioncash/align
General: Replace GC_ALIGN macros with alignas
2015-09-11 17:00:13 +00:00
mimimi085181 e408e0ab17 Store the base hash for paletted textures in the texture cache entries 2015-09-10 22:28:59 +02:00
mimimi085181 38f6cf2089 Perform garbage collection for efb copies
This checks every TEXTURE_KILL_THRESHOLD frames, to see if the hash for the memory area of the efb copy has hanged. If it has changed, the efb copy can be removed, it wouldn't be used anymore. Before this pr, some efb copies would never be deleted.

Fixes issue https://bugs.dolphin-emu.org/issues/6101 and possibly some other VRAM leaks.
2015-09-10 11:58:58 +02:00
Scott Mansell ac467d9fb9 FifoPlayer: Don't check efb copy hashes when plaing back a broken dff 2015-09-07 05:20:25 +12:00
Lioncash 8ce04f9a65 General: Replace GC_ALIGN macros with alignas
Standard supported alignment -> out with compiler-specific.
2015-09-06 12:53:51 -04:00
Scott Mansell bda964e0b9 Workaround to allow partial texture updates to keep working in NSMBWii 2015-09-07 02:32:01 +12:00
Scott Mansell ee649c6d9f Make efb2tex behave more like efb2ram.
Instead of having special case code for efb2tex that ignores hashes,
the only diffence between efb2tex and efb2ram now is that efb2tex
writes zeros to the memory instead of actual texture data.

Though keep in mind, all efb2tex copies will have hashes of zero as
their hash.
2015-09-07 02:32:01 +12:00
Scott Mansell d797b5d0b5 Use ROUND_UP instead of custom bittwiddling. 2015-09-06 23:00:17 +12:00
Scott Mansell b9be3245e1 Move common EFB copy code into VideoCommon
Addded a few duplicated depth copy texture formats to the enum
in TextureDecoder.h. These texture formats were already implemented
in TextureCacheBase and the ogl/dx11 texture cache implementations.
2015-09-06 21:16:51 +12:00
Scott Mansell 52948bb3ef Cleanup and unify handling of efb copy stride. 2015-09-05 23:37:24 +12:00
Rodolfo Bogado d8cd2c3252 Implement scaled partial texture updates 2015-07-02 08:53:40 -03:00
Lioncash daa205990f Use emplace() instead of insert() where applicable for maps. 2015-06-28 19:52:40 -04:00
Jules Blok 2a5dd69c72 Merge branch 'stable' 2015-06-24 19:34:16 +02:00
mimimi085181 829fc3dc2d Quick fix for an invalid iterator 2015-06-24 19:12:46 +02:00
mimimi085181 0ed6b5623f Support partial texture updates via efb copies 2015-06-21 14:02:44 +02:00
degasus c375111076 Options: merge SCoreStartupParameter into SConfig 2015-06-12 19:07:45 +02:00
mimimi085181 4d5fdb74be Code cleanup for FreeTexture after merging PR #2097 2015-06-09 21:45:09 +02:00
mimimi085181 3b9020dc9b Search the texture cache for small textures by address and hash
This fixes issue 6563:
https://code.google.com/p/dolphin-emu/issues/detail?id=6563

This PR adds a 2nd map to texture cache, which uses the hash as key. Cache entries from this new map are used only if the address matches or if the texture was fully hashed. This restriction avoids false positive cache hits. This results in a possible situation where safe texture cache accuracy could be faster than the fast one.

Small textures means up to 1KB for fast texture cache accuracy, 4KB for medium, and all textures for safe accuracy.

Since this adds a small overhead to all texture cache handling, some regression testing would be nice. Games, which use a lot of textures the same time, should be affected the most.
2015-06-05 21:30:39 +02:00
Markus Wick a6412fb41e Merge pull request #2162 from degasus/prefetch_tex
CustomTexture: prefetch all available textures
2015-05-26 13:30:26 +02:00
Tillmann Karras 30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00
Tillmann Karras cefcb0ace9 Update license headers to GPLv2+ 2015-05-25 13:22:31 +02:00
degasus 242f7d964d CustomTexture: prefetch all available textures 2015-05-16 15:12:07 +02:00
Jules Blok 54f4443971 VideoCommon: Implement EFB dumping for both backends. 2015-05-02 13:23:33 +02:00
degasus 35373c5185 TextureCache: load all mipmap levels from custom textures
This drops the "feature" to load level 0 from the custom texture
and all other levels from the native one if the size matches.
But in my opinion, when a custom texture only provide one level,
no more should be used at all.
2015-03-02 00:09:09 +01:00
degasus 7ca24f90d1 TexCache: increase TEXTURE_KILL_THRESHOLD
Xenoblade uses more than 40 textures alternately per frame for eg water effects.
So don't try to drop them as aggressive.
2015-03-01 13:41:14 +01:00
Lioncash 7408de7e79 Merge pull request #2058 from Stevoisiak/Codemaid-Cleanup-Take2
Basic Formatting/Whitespace Cleanup
2015-02-25 18:07:56 -05:00
Stevoisiak 93b16a4a2d Formatting/Whitespace Cleanup
Various fixes to formatting and whitespace
2015-02-25 10:48:21 -05:00
degasus 967eaad8df VideoCommon: rename efb2tex and efb2ram 2015-02-24 23:10:13 +01:00
Tillmann Karras e2fec13ab6 Fix some -Wsign-compare warnings 2015-02-24 10:29:59 +01:00
magumagu 074397c12d Explicitly set up AllocateTexture configuration for palette conversion.
No functional change.
2015-02-19 15:57:05 -08:00
magumagu ddc815dd7a Remove TextureAddress struct. 2015-02-19 15:36:32 -08:00
magumagu c0a4760f0e Decode EFB copies used as paletted textures.
A number of games make an EFB copy in I4/I8 format, then use it as a
texture in C4/C8 format.  Detect when this happens, and decode the copy on
the GPU using the specified palette.

This has a few advantages: it allows using EFB2Tex for a few more games,
it, it preserves the resolution of scaled EFB copies, and it's probably a
bit faster.

D3D only at the moment, but porting to OpenGL should be straightforward..
2015-02-19 15:09:27 -08:00
mimimi085181 2f8e0c9bb9 Allow multiple texture cache entries for textures at the same address
This is the same trick which is used for Metroid's fonts/texts, but for all textures. If 2 different textures at the same address are loaded during the same frame, create a 2nd entry instead of overwriting the existing one. If the entry was overwritten in this case, there wouldn't be any caching, which results in a big performance drop.

The restriction to textures, which are loaded during the same frame, prevents creating lots of textures when textures are used in the regular way. This restriction is new. Overwriting textures, instead of creating new ones is faster, if the old ones are unlikely to be used again.

Since this would break efb copies, don't do it for efb copies.

Castlevania 3 goes from 80 fps to 115 fps for me.

There might be games that need a higher texture cache accuracy with this, but those games should also see a performance boost from this PR.

Some games, which use paletted textures, which are not efb copies, might be faster now. And also not require a higher texture cache accuracy anymore. (similar sitation as PR https://github.com/dolphin-emu/dolphin/pull/1916)
2015-02-18 23:54:40 +01:00
Markus Wick 43605f8716 Merge pull request #1948 from magumagu/remove-efb-cache
Remove EFB to RAM cache, and simplify code.
2015-01-27 09:42:15 +01:00
degasus 51990fcdfa TexCache: Rewrite the texID generation for paletted textures
This changes the behavior if both texture are available. The old code did
try to load the modfied texID, the new code tries the unmodified texID first.
2015-01-24 13:58:20 +01:00
magumagu 6659c15bed Remove EFB to RAM cache, and simplify code. 2015-01-23 10:48:15 -08:00
degasus 62402efa6c CustomTexture: Mark textures with mipmaps 2015-01-21 21:22:55 +01:00
degasus ee9d05d67f CustomTexture: Use another file name with wildcards 2015-01-21 21:22:55 +01:00
Ryan Houdek 50d495b581 Merge pull request #1916 from mimimi085181/master
Make efb to texture less broken for paletted textures that are efb copies
2015-01-21 13:40:36 -06:00
mimimi085181 0d3343d093 Make efb to texture less broken for paletted textures that are efb copies
Don't change the texID depending on the tlut_hash for paletted textures that are efb copies and don't have an entry in the cache for texID ^ tlut_hash. This makes those textures less broken when using efb to texture.

This is not really fixing those textures, but it's a step forward. The mini map in Twilight Princess for example is in grayscales with this and is more or less usable.
2015-01-19 01:31:41 +01:00
degasus 9f13a77799 TexCache: don't try to aggressive reuse the entry
As we pool them now, freeing and reallocating them is quite fast.
2015-01-18 19:58:33 +01:00
degasus 8565f02699 TexCache: use an unordered_multimap for the tex pool 2015-01-18 19:58:33 +01:00
degasus 4639d3b1bc TexCache: also incude textures within the render target pool 2015-01-18 19:47:48 +01:00
degasus 6cd6e6546f TexCache: merge texture and rendertarget factory function 2015-01-18 19:47:48 +01:00
degasus 615ae9f106 TexCache: remove PC_TexFormat
We only support rgba32 for a while now, so there is no need to have everything in common configureable.
2015-01-18 19:47:48 +01:00
mimimi085181 96bcb09fb2 Fix another small bug with the efb2ram cache
Textures that are directly next to each other were falsely detected as overlapping.
2015-01-17 19:10:00 +01:00
degasus 22e06daf5c TexCache: recreate the entry on level missmatch 2015-01-11 23:11:04 +01:00
degasus a9eb08b85d TexCache: Choose texture based on mipmap count 2015-01-11 22:41:04 +01:00
degasus 744b1c1624 TexCache: rewrite level calculation 2015-01-11 22:23:35 +01:00
degasus d95e5e2b6f TexCache: create a const Config struct 2015-01-11 22:23:35 +01:00
degasus d640453274 TexCache: cleanup max texture level 2015-01-11 22:23:35 +01:00
degasus 1261f5f7f4 TextureCache: inline arguments into texture cache 2015-01-11 22:23:35 +01:00
degasus 2b47df07b6 TexCache: use c++11 syntax for std::map::erase 2015-01-11 22:23:35 +01:00
degasus 1c98a43203 TexCache: clean up frameCount handling 2015-01-11 22:23:35 +01:00
degasus 6ba613fbd3 TexCache: unify global variables 2015-01-11 22:23:35 +01:00
degasus 774596dbed TexCache: rename OverlapsMemoryRange 2015-01-11 22:23:35 +01:00
degasus dddcea5a9a TexCache: don't invalidate efb copys because of config changes
We'll loose data on invalidating them. So just keep them until a new copy is done.
A wrong scaled copy is better than no copy if the game doesn't creates a new one.
2015-01-11 22:23:35 +01:00
degasus 38f42da55a TexCache: remove expanded_width
This variable isn't use any more.
2015-01-10 12:22:03 +01:00
degasus 614d058db1 TexCache: don't load tex level 0 on creation
This reverts an optimization which isn't worth imo. Every texture uploads have to alloc vram and a staging buffer, so there is no need to do both in the same call.
2015-01-10 12:21:33 +01:00
Markus Wick f0f8384639 Merge pull request #1785 from degasus/custom_texture
VideoCommon: Custom texture handling
2015-01-08 13:29:45 +01:00
Tillmann Karras 4d1face540 Fix indentation 2015-01-07 21:51:47 +01:00
degasus c6dd5044d6 VideoCommon: make hash independet from hires textures 2014-12-29 10:24:27 +01:00
degasus f8184858da VideoCommon: Merge code to generate texture names on dumping 2014-12-29 10:24:27 +01:00
degasus 51bfc4c52a VideoCommon: rewrite custom textures 2014-12-29 10:24:21 +01:00
Jules Blok 31a55384b3 VideoConfig: Rename "StereoMonoEFBDepth" to "StereoEFBMonoDepth"
Makes a little bit more sense.
2014-12-24 23:30:40 +01:00
Rohit Nirmal 239eaf122a VideoCommon: Fix -Wsign-compare warnings. 2014-11-29 17:40:14 -06:00
Jules Blok 0f63186371 TextureCache: Add "Mono EFB Depth Copy" stereoscopy option. 2014-11-23 14:27:40 +01:00
Jules Blok 8210b9c915 TextureCache: Ensure that all render target textures have as many layers as the frame buffer.
Also fixes a case where the D3D code path did not initialize num_layers leading to undefined behaviour.
2014-11-23 14:27:40 +01:00
Jules Blok ee76c03160 TextureCache: Recompile EFB2Tex shaders when stereo 3D is toggled. 2014-11-23 14:27:40 +01:00
Jules Blok 4d9589b35f Cosmetics. 2014-11-23 14:27:38 +01:00
Jules Blok 5944d15021 TextureCache: Check the number of layers before reusing a texture. 2014-11-23 14:23:42 +01:00
Fiora 733795891c D3D: fix issues with multi-level 1x1 textures on D3D
Fixes NBA 2K11, maybe other things.
2014-11-12 21:43:48 -08:00
comex 7f6284c2fc Change a bunch of reference function arguments to pointers.
Per the coding style and sanity.
2014-10-02 03:00:33 -04:00
Jasper St. Pierre ea1245d191 TextureDecoder: Pass the TLUT address straight into the texture decoder
This removes the requirement for the TextureDecoder to have access to
global texture memory.
2014-09-04 18:36:57 -07:00
Jasper St. Pierre fcd4ecc942 TextureDecoder: Add an enum for the TLUT formats
Quick code cleanup. The enum names and values come from libogc.
2014-09-04 18:36:56 -07:00
Jasper St. Pierre a8e591dc73 VideoCommon: Remove support for decoding to ARGB textures
The D3D / OGL backends only ever used RGBA textures, and the Software
backend uses its own custom code for sampling. The ARGB path seems to
just be dead code.

Since ARGB and RGBA formats are similar, I don't think this will make
the code more difficult to read or unable to be used as
reference. Somebody who wants to use this code to output ARGB can simply
modify the MakeRGBA function to put the shift at the other end.
2014-09-04 18:36:56 -07:00
Yuriy O'Donnell d8d9bc8c6c Render: Implemented simple render target pool
This avoids creating and destroying render targets every frame,
which is a significant CPU overhead.

Old render targets are destroyed after 3 frames.
2014-09-04 22:21:06 +02:00
Lioncash 4af8d9d248 VideoCommon: Clean up brace placements 2014-08-30 18:06:45 -04:00
degasus 81ed17be53 avoid the extern keyword in .cpp files 2014-07-11 16:10:20 +02:00
degasus 6d3f249dcc mark all local variables as static 2014-07-11 16:10:20 +02:00
Lioncash ce54c1e571 Kill off replaceable usages of s[n]printf. 2014-06-18 19:53:38 -04:00
Lioncash 49b0eef393 Remove the min/max functions in CommonFuncs.
The algorithm header has the same functions.
2014-05-29 21:44:41 -04:00
Pierre Bourdon 664c8d30a0 Remove all trailing whitespaces from our codebase. 2014-03-29 11:05:44 +01:00
Tony Wasserka 8941f19cdb BPMemory: Expose the pixel_format and zformat fields in PE_CONTROL as enumerations. 2014-03-25 23:57:58 +01:00
Lioncash a82675b7d5 Kill off some usages of c_str.
Also changes some function params, but this is ok.
Some simplifications were also able to be made (ie. killing off strcmps with ==, etc).
2014-03-14 13:51:23 -04:00
Matthew Parlane 31cfc73a09 Fixes spacing for "for", "while", "switch" and "if"
Also moved && and || to ends of lines instead of start.
Fixed misc vertical alignments and some { needed newlining.
2014-03-11 00:35:07 +13:00
Tillmann Karras d802d39281 clang-modernize -use-nullptr
and s/\bNULL\b/nullptr/g for *.cpp/h/mm files not compiled on my machine
2014-03-09 21:14:26 +01:00
Tillmann Karras c89f04a7c5 clang-modernize -loop-convert
and some manual adjustments
2014-03-09 21:11:59 +01:00
Tillmann Karras 315a8ba1c0 Various changes suggested by cppcheck
- remove unused variables
- reduce the scope where it makes sense
- correct limits (did you know that strcat()'s last parameter does not
  include the \0 that is always added?)
- set some free()'d pointers to NULL
2014-02-28 12:43:20 +01:00
Lioncash 2afe215271 Convert all includes to relative paths. 2014-02-18 02:19:10 -05:00
Lioncash 3fd87a7636 Second and final pass of clearing out tabs. 2014-02-17 02:19:41 -05:00
Tillmann Karras 404624bf0b Turn loops into range-based form
and some things suggested by cppcheck and compiler warnings.
2014-02-13 09:05:50 +01:00
degasus 01351795f0 TextureCache: Warn for invalid custom textures
At the moment, custom textures with:
- invalid mipmap size
- invalid aspect ratio
- non-fractional scaling factors
are allowed. But they can't be loaded fine by the backend, so generate a warning if someone trys to load them.
2014-01-03 14:30:12 +01:00
Jasper St. Pierre 34692ab826 Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00