Commit graph

313 commits

Author SHA1 Message Date
kd-11
fc486a1bac rsx: Preserve memory order when doing flush
- Orders flushing to preserve memory at all cost
- Avoids false positive where flushing overlapping sections can falsely invalidate another with head/tail test
2018-09-21 16:32:23 +03:00
kd-11
a21bdb9f45 rsx; blit engine fixes
- Forcefully downloads and reuploads data from the CPU in case of unexpected overlaps
- Properly detect correct size of newly created blit targets
- Remember to clear any existing views when changing the default component map!
2018-09-21 16:32:23 +03:00
kd-11
f413996362 rsx: Minor texture cache fixes
- Retag resources reprotected under flush_always rules
- Properly check for blit resource fitting taking into account format
mismatch, pitch mismatch and typeless transfers
2018-09-10 15:43:28 +03:00
Nekotekina
ca5158a03e Cleanup semaphore<> (sema.h) and mutex.h (shared_mutex)
Remove semaphore_lock and writer_lock classes, replace with std::lock_guard
Change semaphore<> interface to Lockable (+ exotic try_unlock method)
2018-09-03 23:00:36 +03:00
Nekotekina
a93a40e8d9 Disable texture_cache::emit_once (MSVC crash) 2018-08-25 01:58:28 +03:00
Nekotekina
923314aef5 Rewrite texture_cache::emit_once
Also trying to workaround MSVC bug
2018-08-25 01:15:47 +03:00
kd-11
c6e35706a3 vk: Support sw component swizzle decode because metal sucks 2018-08-23 22:54:56 +03:00
kd-11
f3d3a1a4a5 rsx: Rework section reuse logic 2018-08-22 17:22:54 +03:00
kd-11
4b2b662c3a rsx: Followup to the memory inheritance hierachy patch
- Tags framebuffer resources on first use (when on_write is called to verify memory)
- Texture cache now selects the best match and even sorts atlas writes with memory write order to avoid older data showing over newer one
2018-08-18 16:14:30 +03:00
kd-11
f8a9b1fa30 [WIP] rsx: Improve memory inheritance hierachy
- Cascade memory writes by invalidating 'downstream' subsurfaces
- Fixup; always resolve for overlapping surfaces before sampling (force
  atlas gather test)
2018-08-18 16:14:30 +03:00
kd-11
cc7848b3ef vulkan: Fix blit engine transfer to ARGB8 render target memory 2018-08-18 16:14:30 +03:00
Rui Pinheiro
23b52e1b1c Mark unsync textures dirty when deferred flushing
invalidate_range_impl_base does not mark all textures that will only be
unprotected as dirty when doing a deferred flush, since that is done by
flush_all.

However, if there are no sections to flush, the deferred flush will
use the same code path as non-deferred flushes for unprotecting textures
and forget to mark them as dirty.

This commit fixes this bug.
2018-08-16 15:38:36 +03:00
Rui Pinheiro
fa6a5761b3 Refactor get_intersecting_set
The existing implementation restarts the loop immediately after
finding a range_data instance that updates the trampled_range.

This commit refactors this method to continue the loop with the updated
trampled_range, and then repeat only those range_data instances that
were iterated through before the trampled_range was last updated.
As a result, the number of total iterations required is reduced.
2018-08-16 15:38:36 +03:00
Rui Pinheiro
b534d49e48 Fix off-by-one error in get_intersecting_set
When the trampled range changes, get_intersecting_set restarts the
outer loop. However, due to an off-by-one error, it skips the first
cache entry when doing so. This can cause a texture not to be
correctly unlocked, which could lead to issues or even deadlocks.

This commit fixes this off-by-one error.
2018-08-16 15:38:36 +03:00
kd-11
8695f95267 rsx: Reimplement cached textures and their views 2018-07-22 17:19:59 +03:00
kd-11
24f4c92759 rsx: Improve texture cache read speculation 2018-06-26 20:07:20 +03:00
kd-11
1730708f47 rsx: Rework memory protection management for framebuffer access
- Avoid re-locking memory if there is no reason to do so (no draws issued)
- Actively bound regions should always get written to the backing cache
- Forcefully read memory during download if writes to the target have occured since last sync event
2018-06-26 20:07:20 +03:00
kd-11
d77e62c94e rsx: Improve GPU resource read prediction 2018-06-18 17:32:22 +03:00
kd-11
dd4c13b625 rsx: Avoid race conditions in unsynchronized unprotect 2018-06-18 17:32:22 +03:00
kd-11
3150619320 rsx: Preserve read AA state separate from write AA state
- Some applications (e.g Backbreaker) use an evil hack to resolve MSAA.
  The application respecifies a formerly AA region as a region with no AA then performs a framebuffer feedback lookup.
  The old memory keeps AA during read, but writes back to itself with AA resolved.
  This is evil on several levels but it just happens to work on PS3
2018-06-08 22:17:50 +03:00
kd-11
0f24379c0e rsx: Obey MSAA resolve during memory persistence transfer
- Ugh. This is a bandaid on a festering wound, AA badly needs a rewrite

 Also silence some warnings
2018-06-08 22:17:50 +03:00
kd-11
b030d1900c rsx: Fixup - fix broken memory protection fail caused by region respec
- Some applications will alternate memory between framebuffer and texture data
2018-05-24 10:36:04 +03:00
kd-11
f8d999b384 fixup - range check 2018-05-23 19:07:08 +03:00
kd-11
3f14bc6961 rsx: Silence some meaningless error 2018-05-23 19:07:08 +03:00
kd-11
8fcd5c1e5a rsx: Texture cache fixes
1. rsx: Rework section synchronization using the new memory mirrors
2. rsx: Tweaks
    - Simplify peeking into the current rsx::thread instance.
      Use a simple rsx::get_current_renderer instead of asking fxm for the same
    - Fix global rsx super memory shm block management
3. rsx: Improve memory validation. test_framebuffer() and
tag_framebuffer() are simplified due to mirror support
4. rsx: Only write back confirmed memory range to avoid overapproximation errors in blit engine
5. rsx: Explicitly mark clobbered flushable sections as dirty to have them
removed
6. rsx: Cumulative fixes
    - Reimplement rsx::buffered_section management routines
    - blit engine subsections are not hit-tested against confirmed/committed memory range
      Not all applications are 'honest' about region bounds, making the real cpu range useless for blit ops
2018-05-23 19:07:08 +03:00
scribam
04ad49de4d typos 2018-05-14 21:14:39 +04:00
kd-11
f3210a9a33 rsx: Workaround for lost memory sections
- TODO: surface_cache and texture_cache need a better method of persisting partial framebuffer resources
2018-04-25 19:14:36 +03:00
kd-11
291a828217 fixups 2018-04-25 19:14:36 +03:00
kd-11
da99f3cb9a rsx: Critical fixes
- texture cache: Avoid leaking memory sections
  - Avoid double ref increment on flush-always reprotection
  - Detect invalidated_resources entries in surface cache when protecting fbo memory
- vk: Copypasta bugfix, properly initialize aspect mask
2018-04-25 19:14:36 +03:00
kd-11
a42b00488d rsx: Texture fixes
- gl/vk: Fix subresource copy/blit
- gl/vk: Fix default_component_map reading
- vk: Reimplement cell readback path and improve software channel decoder
- Properly name the subresource layout field - its in blocks not bytes!
- Implement d24s8 upload from memory correctly
- Do not ignore DEPTH_FLOAT textures - they are depth textures and abide by the depth compare rules
- NOTE: Redirection of 16-bit textures is not implemented yet
2018-04-25 19:14:36 +03:00
kd-11
9abbbb79ae rsx: Blit engine fixes
- Ignore unlocked blit sections [TODO]
- Do not attempt blit on hw if bytesize is unsupported
- gl: Implement typeless memory transfers
  Uses pbo to handle type-agnostic memory transfer
2018-04-25 19:14:36 +03:00
kd-11
cf1b700ebc rsx: Improve format mismatch detection hack 2018-04-25 19:14:36 +03:00
kd-11
e291494282 rsx: Texture cache updates
- Properly implement section gather for 3d and cubemaps
  Implements render-to-3d and fixes some corner cases for render-to-cubemap
2018-04-05 01:06:50 +03:00
kd-11
321c360dcb rsx: Overhaul rendertarget sampling/shuffles
- Reimplements render target views used for sampling
- Optimizes access using an encoded control token
- Adds proper encoding for 24-bit textures (DRGB8 -> ORGB/OBGR)
- Adds proper encoding for ABGR textures (ABGR8 -> ARGB8)
- Silence some compiler warnings as well
- TODO: Real texture views for OGL current method is a hack
2018-03-25 13:31:06 +03:00
kd-11
9fc1740608 rsx/fp: Fragment program overhaul
- Separate TXB from TXL: They are completely different!
- Properly perform TMU emulation in the fragment shader. Implemens SRGB conversion and alphakill at the moment
- Properly perform ROP emulation in the fragment shader. Implements FRAMEBUFFER_SRGB. While support on the chip looks to be incomplete (and wierd), it does work
- Document some more bits in SHADER_CONTROL register
2018-03-25 13:31:06 +03:00
kd-11
9f416e5ce1 rsx/gl/vk: Obey channel remapping on framebuffer resources if requested 2018-03-25 13:31:06 +03:00
kd-11
5817f9fe3f rsx: Texture format fixes
- Implement SRGB (gamma corrected) textures (DXT1, DXT3, DXT5, RGBA8 only)
- Fix channel map decode for XY data texture formats
- Fix remap layout for X16 textures (verified with Mass Effect 3)
2018-03-25 13:31:06 +03:00
kd-11
e230867492 rsx: Properly implement raster window offsets 2018-03-13 18:55:03 +03:00
kd-11
20d4c09a1c rsx/vk/gl: Enforce format matching for render target resources. Fall back to raw data copy if match fails
- Forces Bitcast of texture data if input format cannot possibly be the
  same as the existing texture format

- rsx: Other minor improvements to texture cache :-
  - remove obsolete blit engine incompatibility warning. The texture will be re-uploaded if it is indeed incompatible
  - Implement warn_once and err_once to avoid spamming the log with systemic errors
  - Track mispredicted flushes
  - Reswizzle bitcasted texture data to native layout
    TODO: Also needs reshuffle according to input remap vector
2018-03-13 18:55:03 +03:00
kd-11
07cbf3da48 rsx/gl: Minor fixes
- Identify depth textures reaching the gpu via shader_read upload path
- Use correct timestamp counter for opengl
- inline draw_state::test_property because msvc doesnt do it for us
2018-03-13 18:55:03 +03:00
kd-11
01349b8cee rsx: Texture cache fixes - Optionally attempt to merge framebuffers into an atlas if partial resources are missing - Support for data update requests to the temporary subresource handler This is useful for framebuffer feedback loops where a new copy is needed after every draw call (resource is always dirty) 2018-03-13 18:55:03 +03:00
kd-11
4487cc8e7a Remove an ugly hack pertaining to partial framebuffer-resident texture data - Its better to fill in the missing information with a wrap or clamp than to fake the texture reads in valid regions - Texture coordinate scaling is used to fill in for the cropped dimension available 2018-03-13 18:55:03 +03:00
kd-11
661b8b006f rsx: Add texture readback statistics to the texture cache and debug overlay 2018-02-16 16:14:54 +03:00
kd-11
1bd77c2f51 rsx: Add cache pattern checking to blit engine resources
- Feature was implemented long ago but was not functional due to bugs
2018-02-16 16:14:54 +03:00
kd-11
3bbecd998a infinitesimal fixes 2018-02-16 16:14:54 +03:00
kd-11
89c548b5d3 rsx: fbo fixes 2.5
- Implement flush-always behaviour to partially fix readback from a currently bound fbo
  - Without this, only the first read is correct, as more draws are added the results become 'wrong'
  - Fixes WCB and cpublit behviour
- Synchronize blit_dst surfaces to avoid data loss when gpu texture scaling is used
  - Its still faster in such cases to disable gpu texture scaling but some types cannot be disabled without force cpu blit (e.g framebuffer transfers)
- Memory management tuning
  - rsx: on-demand texture cache rescanning for unprotected sections
  - rsx: Only framebuffer resources are upscaled
  - Do not resize regular blit engine resources
  - Lazy initialize readback buffer when using opengl
  -- These measures should help minimize vram usage
2018-02-16 16:14:54 +03:00
Nekotekina
cce0ad0c35 Clean vm::ps3 namespace use 2018-02-09 17:49:37 +03:00
kd-11
eeb6e29e39 vulkan: implement proper texture read barriers 2018-02-02 10:07:55 +03:00
kd-11
b9cca71c47 gl: API compliance fixes
- Do not assume texture2D when creating new textures
- Flag invalid texture cache if readonly texture is trampled by fbo memory.
  Avoids binding a stale handle to the pipeline and is rare enough that it should not hurt performance
2018-02-02 10:07:55 +03:00
kd-11
6828fbf658 rsx/texture_cache: Remove hacks; it has been proven that in offsets are in x16 fixed point 2018-01-19 12:03:57 +03:00