Commit graph

176 commits

Author SHA1 Message Date
GPUCode f8b8b6e53c
core: De-globalize movie (#6659) 2023-08-01 02:57:38 +02:00
GPUCode 06f3c90cfb
Custom textures rewrite (#6452)
* common: Add thread pool from yuzu

* Is really useful for asynchronous operations like shader compilation and custom textures, will be used in following PRs

* core: Improve ImageInterface

* Provide a default implementation so frontends don't have to duplicate code registering the lodepng version

* Add a dds version too which we will use in the next commit

* rasterizer_cache: Rewrite custom textures

* There's just too much to talk about here, look at the PR description for more details

* rasterizer_cache: Implement basic pack configuration file

* custom_tex_manager: Flip dumped textures

* custom_tex_manager: Optimize custom texture hashing

* If no convertions are needed then we can hash the decoded data directly removing the needed for duplicate decode

* custom_tex_manager: Implement asynchronous texture loading

* The file loading and decoding is offloaded into worker threads, while the upload itself still occurs in the main thread to avoid having to manage shared contexts

* Address review comments

* custom_tex_manager: Introduce custom material support

* video_core: Move custom textures to separate directory

* Also split the files to make the code cleaner

* gl_texture_runtime: Generate mipmaps for material

* custom_tex_manager: Prevent memory overflow when preloading

* externals: Add dds-ktx as submodule

* string_util: Return vector from SplitString

* No code benefits from passing it as an argument

* custom_textures: Use json config file

* gl_rasterizer: Only bind material for unit 0

* Address review comments
2023-04-27 07:38:28 +03:00
GPUCode 26d6f9d1c6
Rasterizer cache refactor (#6375)
* rasterizer_cache: Remove custom texture code

* It's a hacky buggy mess, will be reimplemented later when the cache is in a better state

* rasterizer_cache: Refactor surface upload/download

* Switch to the texture_codec header which was written as part of the vulkan backend by steveice and me

* Move most of the upload logic to the rasterizer cache and out of the surface object

* Scaled uploads/downloads have been disabled for now since they require more runtime infrastructure

* rasterizer_cache: Refactor runtime interface

* Remove aspect enum which is the same as SurfaceType

* Replace Subresource with specific structures for each operation (blit/copy/clear). This mimics moderns APIs vulkan much better

* Pass the surface to the runtime instead of the texture

* Implement CopyTextures with glCopyImageSubData which is available on 4.3 and gles.
  This function also has an overload for cubes which will be removed later.

* rasterizer_cache: Move texture allocation to the runtime

* renderer_opengl: Remove TextureDownloaderES

* It's overly compilcated and unused at the moment. Will be replaced with a simple compute shader in a later commit

* rasterizer_cache: Split CachedSurface

* This commit splits CachedSurface into two classes, SurfaceBase which contains the backend agnostic functions and Surface which is the opengl specific part

* For now the cache uses the opengl surface directly and there are a few ugly casts with watchers, those will be taken care of when the template convertion and watcher removal are added respectively

* rasterizer_cache: Move reinterpreters to the runtime

* rasterizer_cache: Move some pixel format function to the cpp file

* rasterizer_cache: Common texture acceleration functions

* They don't contain any backend specific code so they shouldn't be duplicated

* rasterizer_cache: Remove BlitSurfaces

* It's better to prefer copy/blit in the caller anyway

* rasterizer_cache: Only allocate needed levels

* rasterizer_cache: Move texture runtime out of common dir

* Also shorten the util header filename

* surface_params: Cleanup code

* Add more comments, organize it a bit etc

* rasterizer_cache: Move texture filtering to the runtime

* rasterizer_cache: Move to VideoCore

* renderer_opengl: Reimplement scaled uploads/downloads

* Instead of looking up for temporary textures, each allocation now contains both a scaled and unscaled handle
  This allows the scale operations to be done inside the surface object itself and improves performance in general

* In particular the scaled download code has been expanded to use ARB_get_texture_sub_image when possible
  which is faster and more convenient than glReadPixels. The latter is still relevant for OpenGLES though.

* Finally allocations are now given a handy debug name that can be viewed from renderdoc.

* rasterizer_cache: Remove global state

* gl_rasterizer: Abstract common draw operations to Framebuffer

* This also allows to cache framebuffer objects instead of always swapping the textures, something that particularly benefits mali gpus

* rasterizer_cache: Implement multi-level surfaces

* With this commit the cache can now directly upload and use mipmaps
  without needing to sync them with watchers. By using native mimaps
  directly this also adds support for mipmap for cube

* Texture cubes have also been updated to drop the watcher requirement

* host_shaders: Add CMake integration for string shaders

* Improves build time shader generation making it much less prone to errors.
  Also moves the presentation shaders here to avoid embedding them to the cpp file.

* Texture filter shaders now make explicit use of uniform bindings for better vulkan compatibility

* renderer_opengl: Emulate lod bias in the shader

* This way opengles can emulate it correctly

* gl_rasterizer: Respect GL_MAX_TEXTURE_BUFFER_SIZE

* Older Bifrost Mali GPUs only support up to 64kb texture buffers. Citra would try to allocate a much larger buffer the first 64kb of which would work fine but after that the driver starts misbehaving and showing various graphical glitches

* rasterizer_cache: Cleanup CopySurface

* renderer_opengl: Keep frames synchronized when using a GPU debugger

* rasterizer_cache: Rename Surface to SurfaceRef

* Makes it clear that surface is a shared_ptr and not an object

* rasterizer_cache: Cleanup

* Move constructor to the top of the file

* Move FindMatch to the top as well and remove the Invalid flag which was redudant;
  all FindMatch calls used it expect from MatchFlags::Copy which ignores it anyway

* gl_texture_runtime: Make driver const

* gl_texture_runtime: Fix RGB8 format handling

* The texture_codec header, being written with vulkan in mind converts RGB8 to RGBA8. The backend wasn't adjusted to account for this though and treated the data as RGB8.

* Also remove D16 convertions, both opengl and vulkan are required to support this format so these are not needed

* gl_texture_runtime: Reduce state switches during FBO blits

* glBlitFramebuffer is only affected by the scissor rectangle so just disable scissor testing instead of resetting our entire state

* surface_params: Prevent texcopy that spans multiple levels

* It would have failed before as well, with multi-level surfaces it triggers the assert though

* renderer_opengl: Centralize texture filters

* A lot of code is shared between the filters thus is makes it sense to centralize them

* Also fix an issue with partial texture uploads

* Address review comments

* rasterizer_cache: Use leading return types

* rasterizer_cache: Cleanup null checks

* renderer_opengl: Add additional logging

* externals: Actually downgrade glad

* For some reason I missed adding the files to git

* surface_params: Do not check for levels in exact match

* Some games will try to use the base level of a multi level surface. Checking for levels forces another surface to be created and a copy to be made which is both unncessary and breaks custom textures

---------

Co-authored-by: bunnei <bunneidev@gmail.com>
2023-04-21 10:14:55 +03:00
Steveice10 506644b9d6
video_core: Fix distance vector used when calculating lighting distance attenuation. (#6366) 2023-03-30 15:12:09 +03:00
GPUCode b5d6f645bd
Prepare frontend for multiple graphics APIs (#6347)
* externals: Update dynarmic

* settings: Introduce GraphicsAPI enum

* For now it's OpenGL only but will be expanded upon later

* citra_qt: Introduce backend agnostic context management

* Mostly a direct port from yuzu

* core: Simplify context acquire

* settings: Add option to create debug contexts

* renderer_opengl: Abstract initialization to Driver

* This commit also updates glad and adds some useful extensions which we will use in part 2

* Rasterizer construction is moved to the specific renderer instead of RendererBase.
  Software rendering has been disable to achieve this but will be brought back in the next commit.

* video_core: Remove Init/Shutdown methods from renderer

* The constructor and destructor can do the same job

* In addition move opengl function loading to Qt since SDL already does this. Also remove ErrorVideoCore which is never reached

* citra_qt: Decouple software renderer from opengl part 1

* citra: Decouple software renderer from opengl part 2

* android: Decouple software renderer from opengl part 3

* swrasterizer: Decouple software renderer from opengl part 4

* This commit simply enforces the renderer naming conventions in the software renderer

* video_core: Move RendererBase to VideoCore

* video_core: De-globalize screenshot state

* video_core: Pass system to the renderers

* video_core: Commonize shader uniform data

* video_core: Abstract backend agnostic rasterizer operations

* bootmanager: Remove references to OpenGL for macOS

OpenGL macOS headers definitions clash heavily with each other

* citra_qt: Proper title for api settings

* video_core: Reduce boost usage

* bootmanager: Fix hide mouse option

Remove event handlers from RenderWidget for events that are
already handled by the parent GRenderWindow.
Also enable mouse tracking on the RenderWidget.

* android: Remove software from graphics api list

* code: Address review comments

* citra: Port per-game settings read

* Having to update the default value for all backends is a pain so lets centralize it

* android: Rename to OpenGLES

---------

Co-authored-by: MerryMage <MerryMage@users.noreply.github.com>
Co-authored-by: Vitor Kiguchi <vitor-kiguchi@hotmail.com>
2023-03-27 14:29:17 +03:00
emufan4568 2726fe66db renderer_opengl: Header cleanup
* Should help with building times
2022-08-21 02:22:57 +03:00
emufan4568 07a69b7c7b renderer_opengl: Remove amd hacks and legacy paths
* AMDs new driver fixed many issues in the OpenGL driver. No reason to
  keep these hacks. In addition the upgrade to 4.3 guarantees the
  existance of required extensions, so no need to check for them
2022-08-21 01:52:49 +03:00
SachinVin d35a7a8e23
Merge pull request #5804 from weihuoya/minorfx
Minor fx
2022-01-30 21:51:11 +05:30
SachinVin 80799b1e5d gl_shader_gen.cpp: Fix separable shaders when GL_EXT_clip_cull_distance is not supported 2021-10-02 16:38:29 +05:30
xperia64 8a68c58070 Shield TV driver bug workaround
shield tv
2021-10-02 16:38:22 +05:30
SachinVin 703ef0e6f0 gl_shader_gen.cpp:fix implicit type conversion error for gles 2021-10-02 16:38:20 +05:30
bunnei 8a06463c97 android: video_core: Enable HW shadows and texture barrier on GLES. 2021-09-29 22:51:13 +05:30
bunnei a941547c1c android: renderer_opengl: Partially implement glLogicOp on GLES. 2021-07-24 23:37:03 +05:30
weihuoya cddd447506 use separate texture buffer for light and fog
gl_state.cpp: Fix typo in texture buffer LUT

gl_state.cpp: Initialize texture_buffer_lut_lf
2021-07-24 23:36:53 +05:30
weihuoya b7f0e886d9 make sure initialized, prevent garbage data 2021-06-22 15:15:33 +08:00
bunnei 9ff97270cf
Merge pull request #5501 from FearlessTobi/port-1064-3948
Port yuzu-emu/yuzu#1064 and yuzu-emu/yuzu#3948: Changes to Telemetry and CPU feature detection
2021-04-23 22:58:08 -07:00
Marshall Mohror 6b2e7b77cc
Merge pull request #5657 from FearlessTobi/port-5158
Port yuzu-emu/yuzu#5158: "video_core: Remove unnecessary enum class casting in logging messages"
2021-02-04 10:51:29 -06:00
Lioncash 10f440cb59 common/telemetry: Migrate namespace into the Common namespace
Migrates the Telemetry namespace into the Common namespace to make the
code consistent with the rest of our common code.
2021-01-04 05:17:13 +01:00
xperia64 94d1f695ee
Use alternate-form formatting for floats after fmt 7.1.2 update (#5654)
* Use alternate-form formatting for floats after 7.1.2  update

* Last two floats
2020-12-28 18:32:36 -05:00
FearlessTobi 20139141f7 video_core: Remove unnecessary enum class casting in logging messages
fmt now automatically prints the numeric value of an enum class member by default, so we don't need to use casts any more.

Reduces the line noise in our code a bit.

Co-Authored-By: LC <712067+lioncash@users.noreply.github.com>
2020-12-28 16:50:23 +01:00
FearlessTobi 51d348b087 General: Make use of std::nullopt where applicable
Allows some implementations to avoid completely zeroing out the internal
buffer of the optional, and instead only set the validity byte within
the structure.

This also makes it consistent how we return empty optionals.

Co-Authored-By: LC <712067+lioncash@users.noreply.github.com>
2020-10-03 17:25:54 +02:00
Lioncash 2b031e4eaf gl_shader_gen: std::move strings where applicable
Avoids the creation of a copy when returning.
2020-06-08 06:59:05 -04:00
Lioncash 11792682fb gl_shader_gen: Collapse several format calls into one
Same behavior, but performs one formatting pass without altering the
readability of the formatting.
2020-06-08 06:44:03 -04:00
Lioncash e79e991681 gl_shader_gen: Mark local functions as static where applicable
These aren't used outside of the translation unit.
2020-06-08 06:40:39 -04:00
Lioncash 9645c1e1b2 gl_shader_gen: Eliminate unnecessary std::string construction in AppendProcTexCombineAndMap()
We can make use of a std::string_view here, since only string literals
are used within the switch.
2020-06-08 06:37:41 -04:00
Lioncash cd201cd60f gl_shader_gen: Make use of fmt where applicable
Avoids string churn and makes it significantly easier to read the shader
template strings that are being used as the basis for formatting.
2020-05-08 14:50:48 -04:00
Mat M 8b43dff849
gl_shader_gen: Convert file-scope std::string into a std::string_view (#5263)
Same behavior, no heap allocations at program start up
2020-04-21 20:31:58 -05:00
James Rowe cf4125a6a5 Only load precompiled shaders if their sanitize_mul setting matches 2020-01-15 21:10:37 -07:00
Pengfei Zhu 4bc22aa350
Merge pull request #4918 from vitor-k/warnings
Silence warnings from unused code and mismatched declaration
2019-09-06 22:08:06 +08:00
vitor-k 61f9710d95 remove unused call to nodiscard function 2019-09-05 17:11:38 -03:00
Weiyi Wang dd3ba7bd21 opengl: remove hw geometry shader related stuff 2019-08-18 20:07:50 -04:00
weihuoya 899e3eb003 minor fix for opengles 2019-07-28 21:18:38 +08:00
Weiyi Wang 909d04ddea Remove unused stuff
Some unused variables are still kept in services, as they are parameters passed from the command buffer and might be used in the future
2019-07-16 20:27:03 -04:00
Aner Torre 4b0ce1b770 video_core: Fix fragment_shader compilation failure due to different type variable multiplication 2019-05-19 14:45:41 +02:00
Weiyi Wang 0ec45f694c
Merge pull request #3910 from wwylele/mipmap
gl_rasterizer: implement mipmap by forwarding PICA mipmap configuration
2019-04-17 14:10:42 -04:00
fearlessTobi d755a15891 fix compilation problems 2019-03-23 12:43:03 +01:00
wwylele fa141c799b gl_shader_gen: use accurate LOD formula for texture 2D 2019-03-08 09:37:25 -05:00
Weiyi Wang f409342ab5
Merge pull request #4613 from BreadFish64/gles5
video_core: add GLES support
2019-02-17 15:44:39 -05:00
SachinVin d63acfc1e9 video_core: add workarounds to enable GLES support
video_core: shorten GetGLSLVersionString

video_core: make GLES version and extensions consistent

video_core: move some logic to LoadShader

video_core: deduplicate fragment shader precision specifier
2019-02-12 16:57:18 -06:00
Weiyi Wang b5f2318ae7 gl_rasterizer: change shadow_texture_bias from shader config var to shader uniform
Games can frequently change this register. Using it as shader config var would generates a lot of shaders
2019-02-02 20:40:08 -05:00
Tobias 46e8237e7e Port yuzu-emu/yuzu#1137: "renderer_opengl: Namespace OpenGL code" (#4423)
* renderer_opengl: Namespace OpenGL code

Namespaces all OpenGL code under the OpenGL namespace.

Prevents polluting the global namespace and allows clear distinction
between other renderers' code in the future.

* Also namespace TextureCubeConfig
2018-11-16 23:29:10 -08:00
B3n30 d37a2270d6 Replace boost::optional with std::optional where possible 2018-10-05 13:51:09 +02:00
Weiyi Wang 7d8f115185 Prefix all size_t with std::
done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
2018-09-06 16:03:28 -04:00
Weiyi Wang 99f4ea999c gl_rasiterzer/proctex: revert back to round() for Nearest sampling
This change to floor() was made in 2927c88, which was a result of doing some hwtest. It turned out that it was buggy edge cases in PICA, and for most cases round() still applies
2018-09-01 09:11:15 -04:00
Weiyi Wang 78685065cf
Merge pull request #3916 from wwylele/mipmap-proctex
gl_rasterizer: implement mipmap for procedural texture
2018-07-19 11:51:57 +03:00
Weiyi Wang 7c7adc64fd
Merge pull request #3898 from wwylele/shut-up-texture5
swrasterizer, gl_shader_gen: return 0.0 for Disabled texture unit 0
2018-07-07 18:45:13 +03:00
wwylele 2927c88fd3 gl_rasterizer: implement mipmap for proctex 2018-07-06 01:13:02 +03:00
Valentin Vanelslande b12942a231
gl_shader_gen: remove newline in logging macro 2018-06-30 19:15:15 -05:00
wwylele 4d4b833a00 swrasterizer, gl_shader_gen: return 0.0 for Disabled texture unit 0 2018-06-30 11:36:39 +03:00
wwylele 0eab948728 reformat all files with clang-format 2018-06-29 16:56:12 +03:00