Commit graph

5003 commits

Author SHA1 Message Date
ReinUsesLisp
a02b4e1df6 buffer_cache: Skip cache on small uploads on Vulkan
Ports from OpenGL the optimization to skip small 3D uniform buffer
uploads. This will take advantage of the previously introduced stream
buffer.

Fixes instances where the staging buffer offset was being ignored.
2021-02-13 02:17:24 -03:00
ReinUsesLisp
35df1d1864 vk_staging_buffer_pool: Add stream buffer for small uploads
This uses a ring buffer similar to OpenGL's stream buffer for small
uploads. This stops us from allocating several small buffers, reducing
memory fragmentation and cache locality.

It uses dedicated allocations when possible.
2021-02-13 02:17:24 -03:00
ReinUsesLisp
8fd518ec40 vulkan_device: Enable robustBufferAccess
Fix regression on Pascal on Animal Crossing: New Horizons, fixing a
validation error.
2021-02-13 02:17:23 -03:00
ReinUsesLisp
82c2601555 video_core: Reimplement the buffer cache
Reimplement the buffer cache using cached bindings and page level
granularity for modification tracking. This also drops the usage of
shared pointers and virtual functions from the cache.

- Bindings are cached, allowing to skip work when the game changes few
  bits between draws.
- OpenGL Assembly shaders no longer copy when a region has been modified
  from the GPU to emulate constant buffers, instead GL_EXT_memory_object
  is used to alias sub-buffers within the same allocation.
- OpenGL Assembly shaders stream constant buffer data using
  glProgramBufferParametersIuivNV, from NV_parameter_buffer_object. In
  theory this should save one hash table resolve inside the driver
  compared to glBufferSubData.
- A new OpenGL stream buffer is implemented based on fences for drivers
  that are not Nvidia's proprietary, due to their low performance on
  partial glBufferSubData calls synchronized with 3D rendering (that
  some games use a lot).
- Most optimizations are shared between APIs now, allowing Vulkan to
  cache more bindings than before, skipping unnecesarry work.

This commit adds the necessary infrastructure to use Vulkan object from
OpenGL. Overall, it improves performance and fixes some bugs present on
the old cache. There are still some edge cases hit by some games that
harm performance on some vendors, this are planned to be fixed in later
commits.
2021-02-13 02:17:22 -03:00
ReinUsesLisp
a39d9c5194 vulkan_common: Expose interop and headless devices 2021-02-13 02:16:21 -03:00
ReinUsesLisp
47d5ec6cfc vulkan_common: Make interop extensions mandatory 2021-02-13 02:16:21 -03:00
ReinUsesLisp
40ed0cb920 vulkan_device: Enable robust buffers 2021-02-13 02:16:21 -03:00
ReinUsesLisp
1a987054c5 vulkan_device: Use designated initializers for features 2021-02-13 02:16:21 -03:00
ReinUsesLisp
79afdeaf08 vulkan_wrapper: Add memory barrier pipeline barrier helper 2021-02-13 02:16:21 -03:00
ReinUsesLisp
004a8d6a7a vulkan_device: Fix formatting of constants 2021-02-13 02:16:21 -03:00
ReinUsesLisp
16f97ded21 vulkan_wrapper: Add interop functions 2021-02-13 02:16:21 -03:00
ReinUsesLisp
9735c34f5d vulkan_instance: Initialize Vulkan instance in a separate thread
Workaround an issue on Nvidia where creating a Vulkan instance from an
active OpenGL thread disables threaded optimization on the driver.
This optimization is important to have good performance on Nvidia
OpenGL.
2021-02-13 02:16:21 -03:00
ReinUsesLisp
dde19e7d75 vulkan_wrapper: Pull Windows symbols 2021-02-13 02:16:21 -03:00
ReinUsesLisp
75ccd9959c gpu: Report renderer errors with exceptions
Instead of using a two step initialization to report errors, initialize
the GPU renderer and rasterizer on the constructor and report errors
through std::runtime_error.
2021-02-13 02:16:19 -03:00
ReinUsesLisp
9d8ca6cc4a buffer_base: Add support for cached CPU writes
Some games usually write memory pages currently used by the GPU, causing
rendering issues (e.g. flashing geometry and shadows on Link's
Awakening). To workaround this issue, Guest CPU writes are delayed until
the command buffer finishes processing, but the pages are updated
immediately.

The overall behavior is:
- CPU writes are cached until they are flushed, they update the page
  state, but don't change the modification state. Cached writes stop
  pages from being flushed, in case games have meaningful data in it.
- Command processing writes (e.g. push constants) update the page state
  and are marked to the command processor as dirty. They don't remove
  the state of cached writes.
2021-02-13 02:15:29 -03:00
bunnei
245d60bfff
Merge pull request #5900 from lioncash/unused-func
video_core: Remove unused functions and variables
2021-02-09 15:29:10 -08:00
Lioncash
10636d2494 gl_rasterizer: Remove unused variables
Resolves warnings on clang 12
2021-02-09 17:31:37 -05:00
Lioncash
783dc9e112 texture_cache/util: Remove unused functions
Silences a few warnings on clang 12.
2021-02-09 17:30:20 -05:00
Ameer J
26669d9e13
Merge pull request #5880 from lat9nq/ffmpeg-external
cmake: FFmpeg linking rework
2021-02-08 21:13:10 -05:00
Rodrigo Locatti
4c82c08897
Merge pull request #5888 from Morph1984/ogl-4.6
renderer_opengl: Update OpenGL backend version requirement to 4.6
2021-02-07 21:44:49 -03:00
Chloe Marcec
c5f109bc50 video_core: Delete morton
moron.h & morton.cpp are not used anywhere and are just empty files
2021-02-08 10:20:21 +11:00
Morph
6e5cc977ad renderer_opengl: Update OpenGL backend version requirement to 4.6 2021-02-07 16:32:35 -05:00
lat9nq
b7e6eca8b2 Address reviewer comments 2021-02-05 16:46:03 -05:00
lat9nq
1d19eac415 CMake: Port citra-emu/citra FindFFmpeg.cmake
Also renames related CMake variables to match both the Find*FFmpeg* and
variables defined within the file. Fixes odd errors produced by the old
FindFFmpeg.

Citra's FindFFmpeg is slightly modified here: adds Citra's copyright at
the beginning, renames FFmpeg_INCLUDES to FFmpeg_INCLUDE_DIR, disables a
few components in _FFmpeg_ALL_COMPONENTS, and adds the missing avutil
component to the comment above.
2021-02-05 15:39:19 -05:00
lat9nq
47401016bf CMake: Implement YUZU_USE_BUNDLED_FFMPEG
For Linux, instructs CMake to use the FFmpeg submodule in externals.
This is HEAVILY based on our usage of the late Unicorn.  Minimal change
to MSVC as it uses the yuzu-emu/ext-windows-bin. MinGW now targets the
same ext-windows-bin libraries as MSVC for FFmpeg. Adds FFMPEG_LIBRARIES
to WIN32 and simplifies video_core/CMakeLists.txt a bit.
2021-02-05 14:49:51 -05:00
lat9nq
fc43eac82a video_core: host_shaders: Don't pass --quiet to glslangValidator if unavailable
Prevents CMake from calling `glslangValidator` with `--quiet` when it is
not available, i.e. on older downstream versions from Ubuntu.
2021-02-01 23:39:54 -05:00
bunnei
5861bacafd
Merge pull request #5795 from ReinUsesLisp/bytes-to-map-end
video_core/memory_manager: Add BytesToMapEnd
2021-01-29 22:56:29 -08:00
LC
16818e952c
Merge pull request #5836 from ReinUsesLisp/unaligned-constr-sched
vk_scheduler: Fix unaligned placement new expressions
2021-01-28 10:53:15 -05:00
ReinUsesLisp
9e88ad8da9 vk_scheduler: Fix unaligned placement new expressions
We were accidentaly creating an object in an unaligned memory address.
Fix this by manually aligning the offset.
2021-01-27 22:28:22 -03:00
bunnei
45b13c3037
Merge pull request #5786 from ReinUsesLisp/glsl-cbuf
gl_shader_decompiler: Fix constant buffer size calculation
2021-01-27 15:27:53 -08:00
Rodrigo Locatti
ef6cc3aa1d
vulkan_device: Blacklist Intel from float16 math (#5798)
Astral Chain crashes Intel's SPIR-V compiler when using fp16.
Disable this while the vendor works on a fix.
2021-01-27 13:31:32 -08:00
bunnei
28b822fe38
Merge pull request #5778 from ReinUsesLisp/shader-dir
renderer_opengl: Avoid precompiled cache and force NV GL cache directory
2021-01-27 11:34:21 -08:00
bunnei
62766b1326
Merge pull request #5785 from ReinUsesLisp/buffer-dma
video_core/memory_manager: Flush destination buffer on CopyBlock
2021-01-24 22:57:00 -08:00
ReinUsesLisp
34c3ec2f8c Revert "Start of Integer flags implementation"
This reverts #4713. The implementation in that PR is not accurate.
It does not reflect the behavior seen in hardware.
2021-01-25 02:48:03 -03:00
ReinUsesLisp
9dc4a80b17 vk_graphics_pipeline: Fix narrowing conversion on MSVC 2021-01-24 21:41:29 -03:00
LC
df0d8c45d2
Merge pull request #5807 from ReinUsesLisp/vc-warnings
video_core: Silence the remaining gcc warnings and enforce them
2021-01-24 17:36:43 -05:00
Rodrigo Locatti
b769b1be26
Merge pull request #5363 from ReinUsesLisp/vk-image-usage
vk_texture_cache: Support image store on sRGB images with VkImageViewUsageCreateInfo
2021-01-24 18:44:51 -03:00
ReinUsesLisp
6b00443bc1 vk_texture_cache: Support image store on sRGB images with VkImageViewUsageCreateInfo
Vulkan 1.0 didn't support creating sRGB image views on an ABGR8 VkImage
with storage usage bits. VK_KHR_maintenance2 addressed this allowing to
reduce the usage bits on a VkImageView.

To allow image store on non-sRGB image views when the VkImage is created
with sRGB, always create VkImages without sRGB and add the sRGB format
on the view.
2021-01-24 18:16:43 -03:00
ReinUsesLisp
6a0143400f vulkan_device: Lift VK_EXT_extended_dynamic_state blacklist on RDNA
It seems to be safe to use this on new drivers.
2021-01-24 20:21:11 -03:00
ReinUsesLisp
748551dafb cmake: Enforce -Warray-bounds and -Wmissing-field-initializers globally 2021-01-24 17:31:29 -03:00
bunnei
19c14589d3
Merge pull request #5796 from ReinUsesLisp/vertex-a-bypass-vk
vk_pipeline_cache: Properly bypass VertexA shaders
2021-01-24 11:22:58 -08:00
ReinUsesLisp
f81c783b5b host_shaders/cmake: Pass --quiet to glslang to keep it quiet
Silences noisy builds on toolchains.
2021-01-24 04:55:23 -03:00
ReinUsesLisp
cc4335a9c6 video_core/cmake: Enforce -Warray-bounds and -Wmissing-field-initializers 2021-01-24 04:42:41 -03:00
ReinUsesLisp
1b76e7e890 video_core: Silence -Wmissing-field-initializers warnings 2021-01-24 04:32:19 -03:00
ReinUsesLisp
80a673a27f maxwell_3d: Silence array bounds warnings 2021-01-24 04:31:41 -03:00
ReinUsesLisp
ad48259d7e maxwell_to_vk: Silence -Wextra warnings about using different enum types 2021-01-24 04:03:36 -03:00
Levi Behunin
9477d23d70
shader_ir: Fix comment typo 2021-01-23 13:16:37 -05:00
ReinUsesLisp
966896daad video_core/cmake: Properly generate fatal errors on Aftermath
Fix "message(ERROR ..." to "message(FATAL_ERROR ..." to properly stop
cmake when Nsight Aftermath can't be configured.
2021-01-23 04:15:30 -03:00
ReinUsesLisp
625a011888 nsight_aftermath_tracker: Fix build issues when enabled
Fixes a bunch of build errors when Nsight Aftermath is properly enabled.
2021-01-23 04:13:39 -03:00
ReinUsesLisp
37ef2ee595 vk_pipeline_cache: Properly bypass VertexA shaders
The VertexA stage is not yet implemented, but Vulkan is adding its
descriptors, causing a discrepancy in the pushed descriptors and the
template. This generally ends up in a driver side crash.

Bypass the VertexA stage for now.
2021-01-23 03:59:59 -03:00