Commit graph

334 commits

Author SHA1 Message Date
riperiperi
bdc1f91a5b
Remove pool cache entries for incompatible overlapping textures (#2568)
This greatly reduces memory usage in games that aggressively reuse memory without removing dead textures from the pool, such as the Xenoblade games, UE3 games, and to a lesser extent, UE4/unity games.

This change stops memory usage from ballooning in xenoblade and some other games. It will also reduce texture view/dependency complexity in some games - for example in MK8D it will reduce the number of surface copies between lighting cubemaps generated for actors.

There shouldn't be any performance impact from doing this, though the deletion and creation of textures could be improved by improving the OpenGL texture storage cache, which is very simple and limited right now. This will be improved in future.

Another potential error has been fixed with the texture cache, which could prevent data loss when data is interchangably written to textures from both the GPU and CPU. It was possible that the dirty flag for a texture would be consumed without the data being synchronized on next use, due to the old overlap check. This check no longer consumes the dirty flag.

Please test a bunch of games to make sure they still work, and there are no performance regressions.
2021-08-20 17:52:09 -03:00
riperiperi
97aedc030d
Fix GetHandleInformation for mipmapped 3d textures (#2569)
Got this the wrong way round - was causing games to try synchronize mipmap levels of like 52 on a 3d texture with 6 levels. Also, corrected the variable name in the method that _was_ working.
2021-08-20 14:59:39 -03:00
gdkchan
680d3ed198
Enable transform feedback buffer flush (#2552) 2021-08-17 14:09:27 -03:00
gdkchan
eb181425b1
Fix size of cached compute shaders (#2548)
* Fix size of cached compute shaders

* Missed one
2021-08-12 15:59:24 -03:00
gdkchan
8196086f7a
Revert "Calculate vertex buffer sizes from index buffer (#1663)" (#2544)
This reverts commit 10d649e6d3.
2021-08-11 22:13:48 -03:00
gdkchan
3148c0c21c
Unify GpuAccessorBase and TextureDescriptorCapableGpuAccessor (#2542)
* Unify GpuAccessorBase and TextureDescriptorCapableGpuAccessor

* Shader cache version bump
2021-08-11 18:56:59 -03:00
gdkchan
c3e2646f9e
Workaround for Intel FrontFacing built-in variable bug (#2540) 2021-08-11 23:01:06 +02:00
riperiperi
0a80a837cb
Use "Undesired" scale mode for certain textures rather than blacklisting (#2537)
* Use "Undesired" scale mode for certain textures rather than blacklisting

* Nit

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-08-11 22:44:51 +02:00
gdkchan
ed754af8d5
Make sure attributes used on subsequent shader stages are initialized (#2538) 2021-08-11 22:27:00 +02:00
gdkchan
10d649e6d3
Calculate vertex buffer sizes from index buffer (#1663)
* Calculate vertex buffer size from maximum index buffer index

* Increase maximum index buffer count for it to be considered profitable for counting
2021-08-11 22:06:09 +02:00
gdkchan
0f6ec446ea
Replace BGRA and scale uniforms with a uniform block (#2496)
* Replace BGRA and scale uniforms with a uniform block

* Setting the data again on program change is no longer needed

* Optimize and resolve some warnings

* Avoid redundant support buffer updates

* Some optimizations to BindBuffers (now inlined)

* Unify render scale arrays
2021-08-11 21:33:43 +02:00
gdkchan
d9d18439f6
Use a new approach for shader BRX targets (#2532)
* Use a new approach for shader BRX targets

* Make shader cache actually work

* Improve the shader pattern matching a bit

* Extend LDC search to predecessor blocks, catches more cases

* Nit

* Only save the amount of constant buffer data actually used. Avoids crashes on partially mapped buffers

* Ignore Rd on predicate instructions, as they do not have a Rd register (catches more cases)
2021-08-11 20:59:42 +02:00
gdkchan
ff5df5d8a1
Support non-contiguous copies on I2M and DMA engines (#2473)
* Support non-contiguous copies on I2M and DMA engines

* Vector copy should start aligned on I2M

* Nits

* Zero extend the offset
2021-08-04 22:20:58 +02:00
riperiperi
4b60371e64
Return mapped buffer pointer directly for flush, WriteableRegion for textures (#2494)
* Return mapped buffer pointer directly for flush, WriteableRegion for textures

A few changes here to generally improve performance, even for platforms not using the persistent buffer flush.

- Texture and buffer flush now return a ReadOnlySpan<byte>. It's guaranteed that this span is pinned in memory, but it will be overwritten on the next flush from that thread, so it is expected that the data is used before calling again.
- As a result, persistent mappings no longer copy to a new array - rather the persistent map is returned directly as a Span<>. A similar host array is used for the glGet flushes instead of allocating new arrays each time.
- Texture flushes now do their layout conversion into a WriteableRegion when the texture is not MultiRange, which allows the flush to happen directly into guest memory rather than into a temporary span, then copied over. This avoids another copy when doing layout conversion.

Overall, this saves 1 data copy for buffer flush, 1 copy for linear textures with matching source/target stride, and 2 copies for block textures or linear textures with mismatching strides.

* Fix tests

* Fix array pointer for Mesa/Intel path

* Address some feedback

* Update method for getting array pointer.
2021-07-19 19:10:54 -03:00
riperiperi
ca5ac37cd6
Flush buffers and texture data through a persistent mapped buffer. (#2481)
* Use persistent buffers to flush texture data

* Flush buffers via copy to persistent buffers.

* Log error when timing out, small refactoring.
2021-07-16 18:10:20 -03:00
gdkchan
bb6fab2009
Ensure that DMA copy target textures are kept alive or flushed (#2478) 2021-07-14 14:48:57 -03:00
gdkchan
96a070a9a7
Do not require texture and sampler pools being initialized (#2476) 2021-07-14 14:27:22 -03:00
gdkchan
04dce402ac
Implement a fast path for I2M transfers (#2467) 2021-07-12 16:48:57 -03:00
gdkchan
9b08abc644
Fix shader compilation on shaders that uses rectangle textures (#2471) 2021-07-12 16:20:33 -03:00
gdkchan
40b21cc3c4
Separate GPU engines (part 2/2) (#2440)
* 3D engine now uses DeviceState too, plus new state modification tracking

* Remove old methods code

* Remove GpuState and friends

* Optimize DeviceState, force inline some functions

* This change was not supposed to go in

* Proper channel initialization

* Optimize state read/write methods even more

* Fix debug build

* Do not dirty state if the write is redundant

* The YControl register should dirty either the viewport or front face state too, to update the host origin

* Avoid redundant vertex buffer updates

* Move state and get rid of the Ryujinx.Graphics.Gpu.State namespace

* Comments and nits

* Fix rebase

* PR feedback

* Move changed = false to improve codegen

* PR feedback

* Carry RyuJIT a bit more
2021-07-11 17:20:40 -03:00
gdkchan
59900d7f00
Unscale textureSize when resolution scaling is used (#2441)
* Unscale textureSize when resolution scaling is used

* Fix textureSize on compute

* Flag texture size as needing res scale values too
2021-07-09 00:09:07 -03:00
gdkchan
b02719cf41
Flush UBO updates more frequently (#2407) 2021-07-07 21:20:52 -03:00
gdkchan
8b44eb1c98
Separate GPU engines and make state follow official docs (part 1/2) (#2422)
* Use DeviceState for compute and i2m

* Migrate 2D class, more comments

* Migrate DMA copy engine

* Remove now unused code

* Replace GpuState by GpuAccessorState on GpuAcessor, since compute no longer has a GpuState

* More comments

* Add logging (disabled)

* Add back i2m on 3D engine
2021-07-07 20:56:06 -03:00
gdkchan
d125fce3e8
Allow shader language and target API to be specified on the shader translator (#2402) 2021-07-06 21:20:06 +02:00
riperiperi
94cc365b63
Honour copy dependencies when switching render target (#2433)
* Honour copy dependencies when switching render target

When switching from one render target to another, when both have a copy dependency to each other, a copy can be deferred on the second target when unbinding the first.

Before, this would not be honoured before binding the new texture, so the copy would stay deferred until the render targets change again, at which point it would copy in old data and essentially clear all the draws done during that time.

This change runs synchronize memory to make sure that copies are honoured. This can cause a redundant copy, but it's better than it breaking for now.

This should fix miiedit on AMD/Intel GPUs on windows. May fix other games, or perhaps rare copy dependency bugs on NVIDIA too.

* Address feedback
2021-07-03 01:55:04 -03:00
gdkchan
fbb4019ed5
Initial support for separate GPU address spaces (#2394)
* Make GPU memory manager a member of GPU channel

* Move physical memory instance to the memory manager, and the caches to the physical memory

* PR feedback
2021-06-29 19:32:02 +02:00
gdkchan
fefd4619a5
Add support for custom line widths (#2406) 2021-06-25 20:11:54 -03:00
gdkchan
493648df31
Fix default value for unwritten shader outputs (#2412)
* Fix shader default output values

* Shader cache version bump
2021-06-25 19:56:03 -03:00
gdkchan
ed2f5ede0f
Fix texture sampling with depth compare and LOD level or bias (#2404)
* Fix texture sampling with depth compare and LOD level or bias

* Shader cache version bump

* nit: Sorting
2021-06-25 00:54:50 +02:00
gdkchan
a10b2c5ff2
Initial support for GPU channels (#2372)
* Ground work for separate GPU channels

* Rename TextureManager to TextureCache

* Decouple texture bindings management from the texture cache

* Rename BufferManager to BufferCache

* Decouple buffer bindings management from the buffer cache

* More comments and proper disposal

* PR feedback

* Force host state update on channel switch

* Typo

* PR feedback

* Missing using
2021-06-24 01:51:41 +02:00
riperiperi
12a7a2ead8
Inherit buffer tracking handles rather than recreating on resize (#2330)
This greatly speeds up games that constantly resize buffers, and removes stuttering on games that resize large buffers occasionally:

- Large improvement on Super Mario 3D All-Stars (#1663 needed for best performance)
- Improvement to Hyrule Warriors: AoC, and UE4 games. These games can still stutter due to texture creation/loading.
- Small improvement to other games, potential 1-frame stutters avoided.

`ForceSynchronizeMemory`, which was added with POWER, is no longer needed. Some tests have been added for the MultiRegionHandle.
2021-06-24 01:31:26 +02:00
gdkchan
c71ae9c85c
Fix shader texture LOD query (#2397) 2021-06-23 23:31:14 +02:00
gdkchan
49edf14a3e
Pass all inputs when geometry shader passthrough is enabled (#2362)
* Pass all inputs when geometry shader passthrough is enabled

* Shader cache version bump
2021-06-23 23:04:59 +02:00
gdkchan
65fee49e8a
Fix separate bindless sampler at offset 0 (#2360) 2021-06-20 20:48:12 +02:00
riperiperi
7ff1f9aa12
End shader decoding when reaching a block that starts with an infinite loop (after BRX) (#2367)
* End shader decoding when reaching an infinite loop

The NV shader compiler puts these at the end of shaders.

* Update shader cache version
2021-06-15 02:09:59 +02:00
Mary
afd68d4c6c
GAL: Fix sampler leaks on exit (#2353)
Before this, all samplers instance were leaking on exit because the
dispose method was never getting called.

This fix this issue by making TextureBindingsManager disposable and
calling the dispose method in the TextureManager.
2021-06-09 01:00:28 +02:00
Mary
60cf3dfebc
Do not clear gpu subchannel state on BindChannel (#2348)
This fixes a regression caused by #980, that was causing a crash on New
Super Lucky's Tale.

As always, this need feedback on possible regression on any games.

Fix #2343.
2021-06-09 00:50:18 +02:00
gdkchan
02e2e561ac
Support bindless textures with separate constant buffers for texture and sampler (#2339) 2021-06-09 00:42:25 +02:00
gdkchan
3b90adcd1d
Fix shaders with mixed PBK and SSY addresses on the stack (#2329)
* Fix shaders with mixed PBK and SSY addresses on the stack

* Address PR feedback and nits
2021-06-03 01:41:53 +02:00
gdkchan
b84ba43406
Fix texture blit off-by-one errors (#2335) 2021-06-03 01:30:48 +02:00
gdkchan
79b3243f54
Do not attempt to normalize SNORM image buffers on shaders (#2317)
* Do not attempt to normalize SNORM image buffers on shaders

* Shader cache version bump
2021-05-31 21:59:23 +02:00
riperiperi
54ea2285f0
POWER - Performance Optimizations With Extensive Ramifications (#2286)
* Refactoring of KMemoryManager class

* Replace some trivial uses of DRAM address with VA

* Get rid of GetDramAddressFromVa

* Abstracting more operations on derived page table class

* Run auto-format on KPageTableBase

* Managed to make TryConvertVaToPa private, few uses remains now

* Implement guest physical pages ref counting, remove manual freeing

* Make DoMmuOperation private and call new abstract methods only from the base class

* Pass pages count rather than size on Map/UnmapMemory

* Change memory managers to take host pointers

* Fix a guest memory leak and simplify KPageTable

* Expose new methods for host range query and mapping

* Some refactoring of MapPagesFromClientProcess to allow proper page ref counting and mapping without KPageLists

* Remove more uses of AddVaRangeToPageList, now only one remains (shared memory page checking)

* Add a SharedMemoryStorage class, will be useful for host mapping

* Sayonara AddVaRangeToPageList, you served us well

* Start to implement host memory mapping (WIP)

* Support memory tracking through host exception handling

* Fix some access violations from HLE service guest memory access and CPU

* Fix memory tracking

* Fix mapping list bugs, including a race and a error adding mapping ranges

* Simple page table for memory tracking

* Simple "volatile" region handle mode

* Update UBOs directly (experimental, rough)

* Fix the overlap check

* Only set non-modified buffers as volatile

* Fix some memory tracking issues

* Fix possible race in MapBufferFromClientProcess (block list updates were not locked)

* Write uniform update to memory immediately, only defer the buffer set.

* Fix some memory tracking issues

* Pass correct pages count on shared memory unmap

* Armeilleure Signal Handler v1 + Unix changes

Unix currently behaves like windows, rather than remapping physical

* Actually check if the host platform is unix

* Fix decommit on linux.

* Implement windows 10 placeholder shared memory, fix a buffer issue.

* Make PTC version something that will never match with master

* Remove testing variable for block count

* Add reference count for memory manager, fix dispose

Can still deadlock with OpenAL

* Add address validation, use page table for mapped check, add docs

Might clean up the page table traversing routines.

* Implement batched mapping/tracking.

* Move documentation, fix tests.

* Cleanup uniform buffer update stuff.

* Remove unnecessary assignment.

* Add unsafe host mapped memory switch

On by default. Would be good to turn this off for untrusted code (homebrew, exefs mods) and give the user the option to turn it on manually, though that requires some UI work.

* Remove C# exception handlers

They have issues due to current .NET limitations, so the meilleure one fully replaces them for now.

* Fix MapPhysicalMemory on the software MemoryManager.

* Null check for GetHostAddress, docs

* Add configuration for setting memory manager mode (not in UI yet)

* Add config to UI

* Fix type mismatch on Unix signal handler code emit

* Fix 6GB DRAM mode.

The size can be greater than `uint.MaxValue` when the DRAM is >4GB.

* Address some feedback.

* More detailed error if backing memory cannot be mapped.

* SetLastError on all OS functions for consistency

* Force pages dirty with UBO update instead of setting them directly.

Seems to be much faster across a few games. Need retesting.

* Rebase, configuration rework, fix mem tracking regression

* Fix race in FreePages

* Set memory managers null after decrementing ref count

* Remove readonly keyword, as this is now modified.

* Use a local variable for the signal handler rather than a register.

* Fix bug with buffer resize, and index/uniform buffer binding.

Should fix flickering in games.

* Add InvalidAccessHandler to MemoryTracking

Doesn't do anything yet

* Call invalid access handler on unmapped read/write.

Same rules as the regular memory manager.

* Make unsafe mapped memory its own MemoryManagerType

* Move FlushUboDirty into UpdateState.

* Buffer dirty cache, rather than ubo cache

Much cleaner, may be reusable for Inline2Memory updates.

* This doesn't return anything anymore.

* Add sigaction remove methods, correct a few function signatures.

* Return empty list of physical regions for size 0.

* Also on AddressSpaceManager

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-05-24 22:52:44 +02:00
riperiperi
79092310fa
Compare aligned size for largest mip level when considering sampler resize (#2306)
* Compare aligned size for largest mip level when considering sampler resize

When selecting a texture that's a view for a sampler resize, we should take care that resizing it doesn't change the aligned size of any larger mip levels.

This PR covers two cases:
- When creating a view of the texture, we check that the aligned size of the view shifted up to level 0 still matches the aligned size of the container. If it does not, a copy dependency is created rather than resizing.
- When searching for a texture for sampler, textures that do _not_ match our aligned size when both are shifted up by its base level are not considered an exact match, as resizing the found texture will cause the mip 0 aligned size to change. It will create a copy dependency view instead.

Fixes graphical errors and crashes (on flush) in various Unity games that use render-to-texture.

* Move shared code to its own method.
2021-05-24 17:35:26 +10:00
gdkchan
e9c15d32cb
Use a different method for out of bounds blit (#2302)
* Use a different method for out of bounds blit

* This is not needed
2021-05-22 01:26:49 +02:00
gdkchan
a03bbef4d6
Add another Depth32F texture format (#2304) 2021-05-22 01:15:08 +02:00
gdkchan
f0add129e2
Fix non-independent blend state not being updated (#2303)
* Fix non-independent blend state not being updated

* Actually, this is not needed
2021-05-22 01:08:00 +02:00
riperiperi
5271cfe70b
Fix dimensions check for scale eligibility (#2301) 2021-05-21 01:09:18 +02:00
gdkchan
12533e5c9d
Fix buffer and texture uses not being propagated for vertex A/B shaders (#2300)
* Fix buffer and texture uses not being propagated for vertex A/B shaders

* Shader cache version bump
2021-05-20 21:43:23 +02:00
gdkchan
b34c0a47b4
Fix constant buffer array size when indexing is used and other buffer descriptor and resolution scale regressions (#2298)
* Fix constant buffer array size when indexing is used

* Change default QueryConstantBufferUse value

* Fix more regressions

* Ensure proper order
2021-05-20 15:12:15 -03:00
gdkchan
49745cfa37
Move shader resource descriptor creation out of the backend (#2290)
* Move shader resource descriptor creation out of the backend

* Remove now unused code, and other nits

* Shader cache version bump

* Nits

* Set format for bindless image load/store

* Fix buffer write flag
2021-05-19 23:15:26 +02:00
EmulationFanatic
b5c72b44de
Merge pull request #2177 from riperiperi/feature/parallel-shader-cache
Allow parallel shader compilation when loading a shader cache
2021-05-19 11:39:19 -07:00
riperiperi
0129250c2e
Pass CbufSlot when getting info from the texture descriptor (#2291)
* Pass CbufSlot when getting info from the texture descriptor

Fixes some issues with bindless textures, when CbufSlot is not equal to the current TextureBufferIndex.

Specifically fixes a random chance of full screen colour flickering in Super Mario Party.

* Apply suggestions from code review

Oops

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2021-05-19 20:05:43 +02:00
riperiperi
212e472c9f
Use copy dependencies for the Intel/AMD view format workaround (#2144)
* This might help AMD a bit

* Removal of old workaround.
2021-05-16 20:43:27 +02:00
Mary
7aed7808be
misc: Fix default value for GraphicsConfig.MaxAnisotropy (#2274)
As title say.
Doesn't change anything as the Ryujinx project set it.
2021-05-07 13:18:23 -03:00
gdkchan
0e9823d7e6
Fix shader buffer write flag on atomic instructions (#2261)
* Fix shader buffer write flag on atomic instructions

* Shader cache version bump
2021-05-01 20:46:21 +02:00
gdkchan
4770cfa920
Only enable clip distance if written to on shader (#2217)
* Only enable clip distance if written to on shader

* Signal InstanceId use through FeatureFlags

* Shader cache version bump
2021-04-20 12:33:54 +02:00
riperiperi
9e68f5026e Fix skipping missing shaders 2021-04-18 17:34:01 +01:00
riperiperi
b1c3e01691 Nit 2021-04-18 17:34:00 +01:00
riperiperi
35eac315ab The task isn't required for loading compute binary. 2021-04-18 17:33:59 +01:00
riperiperi
a0aa09912c Use event to wake the main thread on task completion 2021-04-18 17:33:59 +01:00
riperiperi
20d560e3f9 The new host program needs to be saved even if it isn't valid. 2021-04-18 17:33:59 +01:00
riperiperi
ddf4b92a9c Implement parallel host shader cache compilation. 2021-04-18 17:33:58 +01:00
gdkchan
40e276c9b5
Improve shader global memory to storage pass (#2200)
* Improve shader global memory to storage pass

* Formatting and more comments

* Shader cache version bump
2021-04-18 12:31:39 +02:00
gdkchan
f665e1b409
Hold reference for render targets in use (#2156) 2021-04-02 16:33:39 +02:00
gdkchan
524fe3bea4
Implement shader HelperThreadNV (#2163)
* Implement shader HelperThreadNV

* Bump shader cache version

* Use gl_HelperInvocation since its supported across all vendors

* Nit
2021-04-02 21:50:35 +11:00
gdkchan
a0b4799f19
Fix ZN flags set for shader instructions using RZ.CC dest (#2147)
* Fix ZN flags set for shader instructions using RZ.CC dest

* Shader cache version bump and nits
2021-03-27 22:59:05 +01:00
mageven
a5d5ca0635
Shader Cache: Move bindless checking from translation to decode (#2145) 2021-03-27 00:50:26 +01:00
mageven
69f8722e79
Fix inconsistencies in progress reporting (#2129)
Signal and setup events correctly
Eliminate possible races
Use a single event
Mark volatiles and reduce scope of waithandles
Common handler
100ms -> 50ms
2021-03-22 19:40:07 +01:00
Mary
aef25980a7
Salieri: Detect and avoid caching shaders using bindless textures (#2097)
* Salieri: Add blacklist system and blacklist shaders using bindless

Currently the shader cache doesn't have the right format to support
bindless textures correctly and may cache shaders that it cannot rebuild
after host invalidation.

This PR address the issue by blacklisting shaders using bindless
textures.

THis also support detection of already cached broken shader and handle removal
of those.

* Move to a feature flags design to avoid intrusive changes in the translator

This remove the auto correct behaviour

* Reduce diff on TranslationFlags

* Reduce comma on last entry of TranslationFlags

* Fix inverted logic and remove leftovers

* remove debug edits oops
2021-03-19 20:07:37 +01:00
riperiperi
9b7335a63b
Improve linear texture compatibility rules (#2099)
* Improve linear texture compatibility rules

Fixes an issue where small or width-aligned (rather than byte aligned) textures would fail to create a view of existing data. Creates a copy dependency as size change may be risky.

* Minor cleanup

* Remove Size Change for Copy Depenedencies

The copy to the target (potentially different sized) texture can properly deal with cropping by itself.

* Move StrideAlignment and GobAlignment into Constants
2021-03-19 02:17:38 +01:00
riperiperi
1623ab524f
Improve Buffer Textures and flush Image Stores (#2088)
* Improve Buffer Textures and flush Image Stores

Fixes a number of issues with buffer textures:

- Reworked Buffer Textures to create their buffers in the TextureManager, then bind them with the BufferManager later.
  - Fixes an issue where a buffer texture's buffer could be invalidated after it is bound, but before use.
- Fixed width unpacking for large buffer textures. The width is now 32-bit rather than 16.
- Force buffer textures to be rebound whenever any buffer is created, as using the handle id wasn't reliable, and the cost of binding isn't too high.

Fixes vertex explosions and flickering animations in UE4 games.

* Set ImageStore flag... for ImageStore.

* Check the offset and size.
2021-03-08 18:43:39 -03:00
riperiperi
8d36681bf1
Improve handling for unmapped GPU resources (#2083)
* Improve handling for unmapped GPU resources

- Fixed a memory tracking bug that would set protection on empty PTEs
- When a texture's memory is (partially) unmapped, all pool references are forcibly removed and the texture must be rediscovered to draw with it. This will also force the texture discovery to always compare the texture's range for a match.
- RegionHandles now know if they are unmapped, and automatically unset their dirty flag when unmapped.
- Partial texture sync now loads only the region of texture that has been modified. Unmapped memory tracking handles cause dirty flags for a texture group handle to be ignored.

This greatly improves the emulator's stability for newer UE4 games.

* Address feedback, fix MultiRange slice

Fixed an issue where the size of the multi-range slice would be miscalculated.

* Update Ryujinx.Memory/Range/MultiRange.cs (feedback)

Co-authored-by: Mary <thog@protonmail.com>

Co-authored-by: Mary <thog@protonmail.com>
2021-03-06 11:43:55 -03:00
mageven
ca5d8e58dd
Add progress reporting to PTC and Shader Cache (#2057)
* UI changes

* Add progress reporting to PTC & ShaderCache

* Account for null events and expand docs

Co-authored-by: Joshi234 <46032261+Joshi234@users.noreply.github.com>
2021-03-03 01:39:36 +01:00
riperiperi
b530f0e110
Texture Cache: "Texture Groups" and "Texture Dependencies" (#2001)
* Initial implementation (3d tex mips broken)

This works rather well for most games, just need to fix 3d texture mips.

* Cleanup

* Address feedback

* Copy Dependencies and various other fixes

* Fix layer/level offset for copy from view<->view.

* Remove dirty flag from dependency

The dirty flag behaviour is not needed - DeferredCopy is all we need.

* Fix tracking mip slices.

* Propagate granularity (fix astral chain)

* Address Feedback pt 1

* Save slice sizes as part of SizeInfo

* Fix nits

* Fix disposing multiple dependencies causing a crash

This list is obviously modified when removing dependencies, so create a copy of it.
2021-03-02 19:30:54 -03:00
gdkchan
4047477866
Simplify handling of shader vertex A (#1999)
* Simplify handling of shader vertex A

* Theres no transformation feedback, its transform

* Merge TextureHandlesForCache
2021-02-08 10:42:17 +11:00
gdkchan
7016d95eb1
Implement ETC2 (RGB) texture format (#2000)
* Implement ETC2 format

* Fix component counts for compressed formats
2021-02-08 10:23:56 +11:00
gdkchan
67033ed8e0
Do not flush multisample textures (#1973) 2021-02-01 08:30:16 +01:00
gdkchan
f93089a64f
Implement geometry shader passthrough (#1961)
* Implement geometry shader passthrough

* Cache version change
2021-01-29 14:38:51 +11:00
riperiperi
c30504e3b3
Use a descriptor cache for faster pool invalidation. (#1977)
* Use a descriptor cache for faster pool invalidation.

* Speed up comparison by casting to Vector256

Now we never need to worry about this ever again
2021-01-29 14:19:06 +11:00
gdkchan
4b7c7dab9e
Support multiple destination operands on shader IR and shuffle predicates (#1964)
* Support multiple destination operands on shader IR and shuffle predicates

* Cache version change
2021-01-28 10:59:47 +11:00
gdkchan
caf049ed15
Avoid some redundant GL calls (#1958) 2021-01-27 08:44:07 +11:00
gdkchan
d6bd0470fb
Fix conditional rendering without queries (#1965) 2021-01-27 08:42:12 +11:00
gdkchan
9551bfdeeb
Fix compute shader code dumping (#1960) 2021-01-26 18:27:18 +01:00
gdkchan
f94acdb4ef
Allow out of bounds storage buffer access by aligning their sizes (#1870)
* Allow out of bounds storage buffer access by aligning their sizes

* Use correct size

* Fix typo and comment on the reason for the change
2021-01-25 09:22:19 +11:00
gdkchan
f565b0e5a6
Match texture if the physical range is the same (#1934)
* Match texture if the physical range is the same

* XML docs and comments
2021-01-23 13:38:00 +01:00
gdkchan
b8353f5639
Enable parallel ASTC decoding by default (#1930) 2021-01-19 14:19:52 +11:00
gdkchan
03aab63e03
Fix out of range exception when a invalid base lod is used (#1931) 2021-01-19 14:04:38 +11:00
riperiperi
a1f77a5b6a
Implement lazy flush-on-read for Buffers (SSBO/Copy) (#1790)
* Initial implementation of buffer flush (VERY WIP)

* Host shaders need to be rebuilt for the SSBO write flag.

* New approach with reserved regions and gl sync

* Fix a ton of buffer issues.

* Remove unused buffer unmapped behaviour

* Revert "Remove unused buffer unmapped behaviour"

This reverts commit f1700e52fb8760180ac5e0987a07d409d1e70ece.

* Delete modified ranges on unmap

Fixes potential crashes in Super Smash Bros, where a previously modified range could lie on either side of an unmap.

* Cache some more delegates.

* Dispose Sync on Close

* Also create host sync for GPFifo syncpoint increment.

* Copy buffer optimization, add docs

* Fix race condition with OpenGL Sync

* Enable read tracking on CommandBuffer, insert syncpoint on WaitForIdle

* Performance: Only flush individual pages of SSBO at a time

This avoids flushing large amounts of data when only a small amount is actually used.

* Signal Modified rather than flushing after clear

* Fix some docs and code style.

* Introduce a new test for tracking memory protection.

Sucessfully demonstrates that the bug causing write protection to be cleared by a read action has been fixed. (these tests fail on master)

* Address Comments

* Add host sync for SetReference

This ensures that any indirect draws will correctly flush any related buffer data written before them. Fixes some flashing and misplaced world geometry in MH rise.

* Make PageAlign static

* Re-enable read tracking, for reads.
2021-01-17 17:08:06 -03:00
gdkchan
c4f56c5704
Support for resources on non-contiguous GPU memory regions (#1905)
* Support for resources on non-contiguous GPU memory regions

* Implement MultiRange physical addresses, only used with a single range for now

* Actually use non-contiguous ranges

* GetPhysicalRegions fixes

* Documentation and remove Address property from TextureInfo

* Finish implementing GetWritableRegion

* Fix typo
2021-01-17 19:44:34 +01:00
gdkchan
3bad321d2b
Fix mipmap base level being ignored for sampled textures and images (#1911)
* Fix mipmap base level being ignored for sampled textures and images

* Fix layer size and max level for textures

* Missing XML doc + reorder comments
2021-01-15 19:14:00 +01:00
gdkchan
5be6ec6364
Fix shader LOP3 predicate write condition (#1910)
* Fix LOP3 predicate write condition

* Bump shader cache version
2021-01-14 01:07:50 +01:00
gdkchan
36c6e67df2
Implement shader CC mode for ISCADD, X mode for ISETP and fix STL/STS/STG with RZ (#1901)
* Implement shader CC mode for ISCADD, X mode for ISETP and fix STS/STG with RZ

* Fix STG too and bump shader cache version

* Fix wrong name

* Fix Carry being inverted on comparison
2021-01-13 08:52:13 +11:00
gdkchan
df820a72de
Implement clear buffer (fast path) (#1902)
* Implement clear buffer (fast path)

* Remove blank line
2021-01-13 08:50:54 +11:00
gdkchan
6ed19c1488
Fix compute reserved constant buffer updates (#1892) 2021-01-10 21:02:58 +01:00
gdkchan
8e0a421264
Fix remap when handle is 0 (#1882)
* Nvservices cleanup and attempt to fix remap

* Unmap if remap handle is 0

* Remove mapped pool add from Remap
2021-01-10 10:11:31 +11:00
gdkchan
b9200dd734
Support conditional on BRK and SYNC shader instructions (#1878)
* Support conditional on BRK and SYNC shader instructions

* Add TODO comment and bump cache version
2021-01-08 22:55:55 -03:00
Ac_K
73f6149bd6
gpu: Implement missing texture formats (#1867)
* gpu: Implement Etc2Rgba texture format

* Add more format

* Fix wrong pixel format
2021-01-05 06:02:49 +01:00
riperiperi
10aa11ce13
Interrupt GPU command processing when a frame's fence is reached. (#1741)
* Interrupt GPU command processing when a frame's fence is reached.

* Accumulate times rather than %s

* Accurate timer for vsync

Spin wait for the last .667ms of a frame. Avoids issues caused by signalling 16ms vsync. (periodic stutters in smo)

* Use event wait for better timing.

* Fix lazy wait

Windows doesn't seem to want to do 1ms consistently, so force a spin if we're less than 2ms.

* A bit more efficiency on frame waits.

Should now wait the remainder 0.6667 instead of 1.6667 sometimes (odd waits above 1ms are reliable, unlike 1ms waits)

* Better swap interval 0 solution

737 fps without breaking a sweat. Downside: Vsync can no longer be disabled on games that use the event heavily (link's awakening - which is ok since it breaks anyways)

* Fix comment.

* Address Comments.
2020-12-17 19:39:52 +01:00
Mary
6bc2733c17
salieri: Support read-only mode if archive is already opened (#1807)
This improves shader cache resilience when people opens another program that touch the cache.zip.
2020-12-13 08:46:07 +01:00
sharmander
8a6607540e
GPU: Improve unnecessary return value in Map function. (#1799)
* Implement VFNMA.F<32/64>

* Update PTC Version

* Update Implementation & Renames & Correct Order

* Add Logging

* Additional logging

* Add additional check to restart loop from beginning if address goes beyond maximum allowed.

* Additional Check that the total range required doesn't exceed capacity of allocator addresses.

* Improve logging

* Ensure hex output

* Update Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Remove extra page at end

* Remove unnecessary return val in Map function.

* Remove incorrect description

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2020-12-11 06:05:53 +01:00