summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_cache.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-01-21renderer_opengl: Avoid precompiled cache and force NV GL cache directoryReinUsesLisp1-5/+8
Setting __GL_SHADER_DISK_CACHE_PATH we can force the cache directory to be in yuzu's user directory to stop commonly distributed malware from deleting our driver shader cache. And by setting __GL_SHADER_DISK_CACHE_SKIP_CLEANUP we can have an unbounded shader cache size. This has only been implemented on Windows, mostly because previous tests didn't seem to work on Linux. Disable the precompiled cache on Nvidia's driver. There's no need to hide information the driver already has in its own cache.
2020-12-30video_core: Rewrite the texture cacheReinUsesLisp1-1/+0
The current texture cache has several points that hurt maintainability and performance. It's easy to break unrelated parts of the cache when doing minor changes. The cache can easily forget valuable information about the cached textures by CPU writes or simply by its normal usage.The current texture cache has several points that hurt maintainability and performance. It's easy to break unrelated parts of the cache when doing minor changes. The cache can easily forget valuable information about the cached textures by CPU writes or simply by its normal usage. This commit aims to address those issues.
2020-12-07video_core: Make use of ordered container contains() where applicableLioncash1-1/+1
With C++20, we can use the more concise contains() member function instead of comparing the result of the find() call with the end iterator.
2020-12-05video_core: Resolve more variable shadowing scenarios pt.3Lioncash1-4/+3
Cleans out the rest of the occurrences of variable shadowing and makes any further occurrences of shadowing compiler errors.
2020-12-04video_core: Resolve more variable shadowing scenariosLioncash1-3/+3
Resolves variable shadowing scenarios up to the end of the OpenGL code to make it nicer to review. The rest will be resolved in a following commit.
2020-09-06video_core: Remove all Core::System references in rendererReinUsesLisp1-32/+31
Now that the GPU is initialized when video backends are initialized, it's no longer needed to query components once the game is running: it can be done when yuzu is booting. This allows us to pass components between constructors and in the process remove all Core::System references in the video backend.
2020-08-24gl_shader_util: Use std::string_view instead of star pointerReinUsesLisp1-0/+1
This allows us passing any type of string and hinting the length of the string to the OpenGL driver.
2020-08-12gl_shader_cache: Use std::max() for determining num_workersMorph1-1/+1
Does not allocate more threads than available in the host system for boot-time shader compilation and always allocates at least 1 thread if hardware_concurrency() returns 0.
2020-07-21video_core: Remove unused variablesLioncash1-3/+0
Silences several compiler warnings about unused variables.
2020-07-21video_core: Allow copy elision to take place where applicableLioncash1-1/+1
Removes const from some variables that are returned from functions, as this allows the move assignment/constructors to execute for them.
2020-07-17async shadersDavid Marcec1-49/+132
2020-06-24gl_shader_cache: Avoid use after move for program sizeReinUsesLisp1-5/+7
All programs had a size of zero due to this bug, skipping invalidations. While we are at it, remove some unused forward declarations.
2020-06-12gl_arb_decompiler: Implement an assembly shader decompilerReinUsesLisp1-1/+3
Emit code compatible with NV_gpu_program5. This should emit code compatible with Fermi, but it wasn't tested on that architecture. Pascal has some issues not present on Turing GPUs.
2020-06-07vk_pipeline_cache: Use generic shader cacheReinUsesLisp1-3/+3
Trivial port the generic shader cache to Vulkan.
2020-06-07gl_shader_cache: Use generic shader cacheReinUsesLisp1-45/+42
Trivially port the generic shader cache to OpenGL.
2020-06-01glsl: Squash constant buffers into a single SSBO when we hit the limitReinUsesLisp1-5/+7
Avoids compilation errors at the cost of shader build times and runtime performance when a game hits the limit of uniform buffers we can use.
2020-05-19renderer_opengl: Add assembly program code pathsReinUsesLisp1-21/+80
Add code required to use OpenGL assembly programs based on NV_gpu_program5. Decompilation for ARB programs is intended to be added in a follow up commit. This does **not** include ARB decompilation and it's not in an usable state. The intention behind assembly programs is to reduce shader stutter significantly on drivers supporting NV_gpu_program5 (and other required extensions). Currently only Nvidia's proprietary driver supports these extensions. Add a UI option hidden for now to avoid people enabling this option accidentally. This code path has some limitations that OpenGL compatibility doesn't have: - NV_shader_storage_buffer_object is limited to 16 entries for a single OpenGL context state (I don't know if this is an intended limitation, an specification issue or I am missing something). Currently causes issues on The Legend of Zelda: Link's Awakening. - NV_parameter_buffer_object can't bind buffers using an offset different to zero. The used workaround is to copy to a temporary buffer (this doesn't happen often so it's not an issue). On the other hand, it has the following advantages: - Shaders build a lot faster. - We have control over how floating point rounding is done over individual instructions (SPIR-V on Vulkan can't do this). - Operations on shared memory can be unsigned and signed. - Transform feedbacks are dynamic state (not yet implemented). - Parameter buffers (uniform buffers) are per stage, matching NVN and hardware's behavior. - The API to bind and create assembly programs makes sense, unlike ARB_separate_shader_objects.
2020-04-26shader/memory_util: Deduplicate codeReinUsesLisp1-72/+10
Deduplicate code shared between vk_pipeline_cache and gl_shader_cache as well as shader decoder code. While we are at it, fix a bug in gl_shader_cache where compute shaders had an start offset of a stage shader.
2020-04-22ShaderCache/PipelineCache: Cache null shaders.Fernando Sahmkow1-4/+13
2020-04-17Revert "gl_shader_cache: Use CompileDepth::FullDecompile on GLSL"Rodrigo Locatti1-3/+1
2020-04-14gl_shader_cache: Use CompileDepth::FullDecompile on GLSLReinUsesLisp1-1/+3
From my testing on a Splatoon 2 shader that takes 3800ms on average to compile changing to FullDecompile reduces it to 900ms on average. The shader decoder will automatically fallback to a more naive method if it can't use full decompile.
2020-04-06Shader/Pipeline Cache: Use VAddr instead of physical memory for addressing.Fernando Sahmkow1-22/+24
2020-04-06shader_decode: SULD.D implement bits64 and reverse shader ir init method to removed shader stage.namkazy1-3/+3
2020-04-05add shader stage when init shader irnamkazy1-3/+3
2020-03-26Address review and fix broken yuzu-tester buildJames Rowe1-1/+1
2020-03-25Frontend/GPU: Refactor context managementJames Rowe1-3/+2
Changes the GraphicsContext to be managed by the GPU core. This eliminates the need for the frontends to fool around with tricky MakeCurrent/DoneCurrent calls that are dependent on the settings (such as async gpu option). This also refactors out the need to use QWidget::fromWindowContainer as that caused issues with focus and input handling. Now we use a regular QWidget and just access the native windowHandle() directly. Another change is removing the debug tool setting in FrameMailbox. Instead of trying to block the frontend until a new frame is ready, the core will now take over presentation and draw directly to the window if the renderer detects that its hooked by NSight or RenderDoc Lastly, since it was in the way, I removed ScopeAcquireWindowContext and replaced it with a simple subclass in GraphicsContext that achieves the same result
2020-03-09gl_shader_decompiler: Add identifier to decompiled codeReinUsesLisp1-2/+4
2020-03-09gl_shader_cache: Reduce registry consistency to debug assertReinUsesLisp1-3/+1
Registry consistency is something that practically can't happen and it has a measurable runtime cost. Reduce it to a DEBUG_ASSERT.
2020-03-09shader/registry: Store graphics and compute metadataReinUsesLisp1-12/+16
Store information GLSL forces us to provide but it's dynamic state in hardware (workgroup sizes, primitive topology, shared memory size).
2020-03-09video_core: Rename "const buffer locker" to "registry"ReinUsesLisp1-32/+33
2020-03-09gl_shader_cache: Rework shader cache and remove post-specializationsReinUsesLisp1-345/+158
Instead of pre-specializing shaders and then post-specializing them, drop the later and only "specialize" the shader while decoding it.
2020-02-28gl_state_tracker: Implement dirty flags for clip distances and shadersReinUsesLisp1-0/+5
2020-02-28gl_rasterizer: Remove dirty flagsReinUsesLisp1-4/+0
2020-01-24Shader_IR: Store Bound buffer on Shader UsageFernando Sahmkow1-1/+3
2020-01-21gl_shader_cache: Disable fastmath on NvidiaReinUsesLisp1-0/+4
2020-01-14gl_shader_cache: Remove unused STAGE_RESERVED_UBOS constantLioncash1-3/+0
Given this isn't used, this can be removed entirely.
2020-01-14gl_shader_cache: std::move entries in CachedShader constructorLioncash1-3/+4
Avoids several reallocations of std::vector instances where applicable.
2020-01-14gl_shader_cache: Remove unused entries variable in BuildShader()Lioncash1-1/+0
Eliminates a few unnecessary constructions of std::vectors.
2019-12-21gl_shader_cache: Update commentary for shared memoryReinUsesLisp1-9/+6
Remove false commentary. Not dividing by 4 the size of shared memory is not a hack; it describes the number of integers, not bytes. While we are at it sort the generated code to put preprocessor lines on the top.
2019-12-21gl_shader_cache: Remove unused entry in GetPrimitiveDescriptionReinUsesLisp1-11/+9
2019-12-11gl_shader_cache: Add missing new-line on emitted GLSLReinUsesLisp1-2/+2
Add missing new-line. This caused shaders using local memory and shared memory to inject a preprocessor GLSL line after an expression (resulting in invalid code). It looked like this: shared uint smem[8];#define LOCAL_MEMORY_SIZE 16 It should look like this (addressed by this commit): shared uint smem[8]; \#define LOCAL_MEMORY_SIZE 16
2019-11-23gl_shader_cache: Hack shared memory sizeReinUsesLisp1-2/+3
The current shared memory size seems to be smaller than what the game actually uses. This makes Nvidia's driver consistently blow up; in the case of FE3H it made it explode on Qt's SwapBuffers while SDL2 worked just fine. For now keep this hack since it's still progress over the previous hardcoded shared memory size.
2019-11-23gl_shader_cache: Remove dynamic BaseBinding specializationReinUsesLisp1-36/+8
2019-11-23video_core: Unify ProgramType and ShaderStage into ShaderTypeReinUsesLisp1-127/+100
2019-11-23gl_rasterizer: Bind graphics images to draw commandsReinUsesLisp1-0/+1
Images were not being bound to draw invocations because these would require a cache invalidation.
2019-11-23gl_shader_cache: Specialize local memory size for compute shadersReinUsesLisp1-0/+5
Local memory size in compute shaders was stubbed with an arbitary size. This commit specializes local memory size from guest GPU parameters.
2019-11-23gl_shader_cache: Specialize shared memory sizeReinUsesLisp1-0/+7
Shared memory was being declared with an undefined size. Specialize from guest GPU parameters the compute shader's shared memory size.
2019-11-23gl_shader_cache: Specialize shader workgroupReinUsesLisp1-35/+28
Drop the usage of ARB_compute_variable_group_size and specialize compute shaders instead. This permits compute to run on AMD and Intel proprietary drivers.
2019-11-23shader/texture: Deduce texture buffers from lockerReinUsesLisp1-12/+0
Instead of specializing shaders to separate texture buffers from 1D textures, use the locker to deduce them while they are being decoded.
2019-11-08gl_shader_cache: Fix locker constructorsReinUsesLisp1-2/+4
Properly pass engine when a shader is being constructed from memory.
2019-11-08gl_shader_cache: Enable extensions only when availableReinUsesLisp1-6/+14
Silence GLSL compilation warnings.
2019-11-08gl_shader_decompiler: Reimplement shuffles with platform agnostic intrinsicsReinUsesLisp1-0/+1
2019-10-25gl_shader_cache: Implement locker variants invalidationReinUsesLisp1-27/+75
2019-10-25gl_shader_disk_cache: Store and load fast BRXReinUsesLisp1-2/+17
2019-10-25gl_shader_decompiler: Move entries to a separate functionReinUsesLisp1-238/+251
2019-10-25Shader_Cache: setup connection of ConstBufferLockerFernando Sahmkow1-16/+29
2019-09-21shader/image: Implement SULD and remove irrelevant codeReinUsesLisp1-8/+8
* Implement SULD as float. * Remove conditional declaration of GL_ARB_shader_viewport_layer_array.
2019-09-17shader_ir/warp: Implement SHFLReinUsesLisp1-1/+2
2019-09-04gl_shader_cache: Remove special casing for geometry shadersReinUsesLisp1-59/+9
Now that ProgramVariants holds the primitive topology we no longer need to keep track of individual geometry shaders topologies.
2019-08-30video_core: Silent miscellaneous warnings (#2820)Rodrigo Locatti1-1/+1
* texture_cache/surface_params: Remove unused local variable * rasterizer_interface: Add missing documentation commentary * maxwell_dma: Remove unused rasterizer reference * video_core/gpu: Sort member declaration order to silent -Wreorder warning * fermi_2d: Remove unused MemoryManager reference * video_core: Silent unused variable warnings * buffer_cache: Silent -Wreorder warnings * kepler_memory: Remove unused MemoryManager reference * gl_texture_cache: Add missing override * buffer_cache: Add missing include * shader/decode: Remove unused variables
2019-08-21shader_ir: Implement VOTEReinUsesLisp1-1/+3
Implement VOTE using Nvidia's intrinsics. Documentation about these can be found here https://developer.nvidia.com/reading-between-threads-shader-intrinsics Instead of using portable ARB instructions I opted to use Nvidia intrinsics because these are the closest we have to how Tegra X1 hardware renders. To stub VOTE on non-Nvidia drivers (including nouveau) this commit simulates a GPU with a warp size of one, returning what is meaningful for the instruction being emulated: * anyThreadNV(value) -> value * allThreadsNV(value) -> value * allThreadsEqualNV(value) -> true ballotARB, also known as "uint64_t(activeThreadsNV())", emits VOTE.ANY Rd, PT, PT; on nouveau's compiler. This doesn't match exactly to Nvidia's code VOTE.ALL Rd, PT, PT; Which is emulated with activeThreadsNV() by this commit. In theory this shouldn't really matter since .ANY, .ALL and .EQ affect the predicates (set to PT on those cases) and not the registers.
2019-07-18gl_shader_cache: Fix newline on buffer preprocessor definitionsReinUsesLisp1-2/+6
2019-07-17Maxwell3D: Rework the dirty system to be more consistant and scaleableFernando Sahmkow1-1/+1
2019-07-16gl_shader_cache: Fix clang-format issuesReinUsesLisp1-2/+1
2019-07-15gl_shader_cache: Address review commentariesReinUsesLisp1-7/+4
2019-07-15gl_shader_cache: Address CI issuesReinUsesLisp1-1/+2
2019-07-15gl_rasterizer: Implement compute shadersReinUsesLisp1-35/+122
2019-07-09shader_ir: propagate shader size to the IRFernando Sahmkow1-7/+15
2019-07-08gl_shader_decompiler: Implement gl_ViewportIndex and gl_Layer in vertex shadersReinUsesLisp1-2/+5
This commit implements gl_ViewportIndex and gl_Layer in vertex and geometry shaders. In the case it's used in a vertex shader, it requires ARB_shader_viewport_layer_array. This extension is available on AMD and Nvidia devices (mesa and proprietary drivers), but not available on Intel on any platform. At the moment of writing this description I don't know if this is a hardware limitation or a driver limitation. In the case that ARB_shader_viewport_layer_array is not available, writes to these registers on a vertex shader are ignored, with the appropriate logging.
2019-07-05texture_cache: Address FeedbackFernando Sahmkow1-2/+4
2019-07-04gl_shader_cache: Make CachedShader constructor privateZach Hilman1-2/+2
Fixes missing review comments introduced.
2019-06-21texture_cache: Style and CorrectionsFernando Sahmkow1-1/+1
2019-06-21shader_cache: Correct versioning and size calculation.Fernando Sahmkow1-1/+6
2019-06-21gl_shader_decompiler: Implement image binding settingsReinUsesLisp1-0/+4
2019-06-21gl_rasterizer: Track texture buffer usageReinUsesLisp1-34/+44
2019-06-08gl_shader_cache: Use static constructors for CachedShader initializationReinUsesLisp1-42/+34
2019-05-30gl_shader_cache: Store a system class and drop global accessorsReinUsesLisp1-7/+8
2019-05-30gl_shader_cache: Add commentaries explaining the intention in shaders creationReinUsesLisp1-0/+2
2019-05-30gl_shader_cache: Flip if condition in GetStageProgram to reduce indentationReinUsesLisp1-25/+26
2019-05-27gl_shader_gen: Always declare extensions after the version declarationReinUsesLisp1-1/+2
This addresses a bug on geometry shaders where code was being written before all #extension declarations were done. Ref to #2523
2019-05-21gl_shader_cache: Fix clang strict standard build issuesReinUsesLisp1-3/+4
2019-05-21gl_shader_cache: Use shared contexts to build shaders in parallelReinUsesLisp1-34/+82
2019-05-10video_core/renderer_opengl/gl_shader_cache: Correct member initialization orderLioncash1-1/+1
Silences a -Wreorder warning.
2019-04-23Re added new lines at the end of filesFreddyFunk1-1/+1
2019-04-23gl_shader_disk_cache: Use VectorVfsFile for the virtual precompiled shader cache fileunknown1-1/+11
2019-04-16Document unsafe versions and add BlockCopyUnsafeFernando Sahmkow1-6/+7
2019-04-16Use ReadBlockUnsafe for Shader CacheFernando Sahmkow1-5/+7
2019-04-14gl_shader_decompiler: Use variable AOFFI on supported hardwareReinUsesLisp1-27/+27
2019-04-07Permit a Null Shader in case of a bad host_ptr.Fernando Sahmkow1-0/+4
2019-04-06video_core/texures/texture: Remove unnecessary includesLioncash1-0/+1
Nothing in this header relies on common_funcs or the memory manager. This gets rid of reliance on indirect inclusions in the OpenGL caches.
2019-03-28gl_shader_manager: Remove unnecessary gl_shader_manager inclusionLioncash1-2/+0
This isn't used at all in the OpenGL shader cache, so we can remove it's include here, meaning one less file needs to be recompiled if any changes ever occur within that header. core/memory.h is also not used within this file at all, so we can remove it as well.
2019-03-27video_core: Amend constructor initializer list order where applicableLioncash1-6/+6
Specifies the members in the same order that initialization would take place in. This also silences -Wreorder warnings.
2019-03-21gpu: Move GPUVAddr definition to common_types.bunnei1-2/+2
2019-03-16video_core: Refactor to use MemoryManager interface for all memory access.bunnei1-20/+17
# Conflicts: # src/video_core/engines/kepler_memory.cpp # src/video_core/engines/maxwell_3d.cpp # src/video_core/morton.cpp # src/video_core/morton.h # src/video_core/renderer_opengl/gl_global_cache.cpp # src/video_core/renderer_opengl/gl_global_cache.h # src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
2019-03-15gpu: Use host address for caching instead of guest address.bunnei1-19/+24
2019-02-07gl_shader_disk_cache: Use unordered containersReinUsesLisp1-3/+3
2019-02-07gl_shader_cache: Fixup GLSL unique identifiersReinUsesLisp1-2/+2
2019-02-07gl_shader_cache: Link loading screen with disk shader cache loadReinUsesLisp1-3/+26
2019-02-07gl_shader_cache: Set GL_PROGRAM_SEPARABLE to dumped shadersReinUsesLisp1-0/+1
i965 (and probably all mesa drivers) require GL_PROGRAM_SEPARABLE when using glProgramBinary. This is probably required by the standard but it's ignored by permisive proprietary drivers.
2019-02-07gl_shader_disk_cache: Pass core system as argument and guard against games without title idsReinUsesLisp1-1/+2
2019-02-07gl_shader_disk_cache: Address miscellaneous feedbackReinUsesLisp1-3/+3
2019-02-07gl_shader_disk_cache: Pass return values returning instead of by parametersReinUsesLisp1-7/+5
2019-02-07gl_shader_disk_cache: Save GLSL and entries into the precompiled fileReinUsesLisp1-32/+39
2019-02-07gl_shader_cache: Refactor to support disk shader cacheReinUsesLisp1-105/+345
2019-02-07rasterizer_interface: Add disk cache entry for the rasterizerReinUsesLisp1-0/+2
2019-02-03video_core: Assert on invalid GPU to CPU address queriesReinUsesLisp1-2/+4
2019-01-30gl_shader_cache: Use explicit bindingsReinUsesLisp1-63/+83
2019-01-30gl_rasterizer: Implement global memory managementReinUsesLisp1-3/+15
2019-01-15video_core: Rename glsl_decompiler to gl_shader_decompilerReinUsesLisp1-1/+1
2019-01-15video_core: Replace gl_shader_decompilerReinUsesLisp1-2/+6
2019-01-07gl_shader_cache: Use dirty flags for shadersReinUsesLisp1-1/+5
2018-12-11gl_shader_cache: Dehardcode constant in CalculateProgramSize()Lioncash1-2/+2
This constant is related to the size of the instruction.
2018-12-11gl_shader_cache: Resolve truncation compiler warningLioncash1-1/+1
The previous code would cause a warning, as it was truncating size_t (64-bit) to a u32 (32-bit) implicitly.
2018-12-09Implemented a shader unique identifier.Fernando Sahmkow1-0/+45
2018-11-20shader_cache: Only lock covered instructions.Markus Wick1-0/+1
2018-11-10gl_shader_decompiler: Guard out of bound geometry shader input readsReinUsesLisp1-2/+6
Geometry shaders follow a pattern that results in out of bound reads. This pattern is: - VSETP to predicate - Use that predicate to conditionally set a register a big number - Use the register to access geometry shaders At the time of writing this commit I don't know what's the intent of this number. Some drivers argue about these out of bound reads. To avoid this issue, input reads are guarded limiting reads to the highest posible vertex input of the current topology (e.g. points to 1 and triangles to 3).
2018-11-08rasterizer_cache: Remove reliance on the System singletonLioncash1-1/+3
Rather than have a transparent dependency, we can make it explicit in the interface. This also gets rid of the need to put the core include in a header.
2018-10-29video_core: Move OpenGL specific utils to its rendererReinUsesLisp1-2/+3
2018-10-22Use standard UBO and fix/stylize the codeFernandoS271-20/+0
2018-10-22Cache uniform locations and restructure the implementationFernandoS271-8/+16
2018-10-22Implemented Alpha TestingFernandoS271-0/+12
2018-10-07gl_shader_decompiler: Implement geometry shadersReinUsesLisp1-5/+29
2018-09-23Added glObjectLabels for renderdoc for textures and shader programs (#1384)David1-0/+2
* Added glObjectLabels for renderdoc for textures and shader programs * Changed hardcoded "Texture" name to reflect the texture type instead * Removed string initialize
2018-09-15Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi1-3/+3
2018-09-09video_core: fixed arithmetic overflow warnings & improved code stylePatrick Elsässer1-4/+4
- Fixed all warnings, for renderer_opengl items, which were indicating a possible incorrect behavior from integral promotion rules and types larger than those in which arithmetic is typically performed. - Added const for variables where possible and meaningful. - Added constexpr where possible.
2018-09-04gl_shader_cache: Use an u32 for the binding point cache.Markus Wick1-8/+8
The std::string generation with its malloc and free requirement was a noticeable overhead. Also switch to an ordered_map to avoid the std::hash call. As those maps usually have a size of two elements, the lookup time shall not matter.
2018-08-31gl_renderer: Cache textures, framebuffers, and shaders based on CPU address.bunnei1-11/+7
2018-08-28gl_shader_cache: Remove unused program_code vector in GetShaderAddress()Lioncash1-2/+1
Given std::vector is a type with a non-trivial destructor, this variable cannot be optimized away by the compiler, even if unused. Because of that, something that was intended to be fairly lightweight, was actually allocating 32KB and deallocating it at the end of the function.
2018-08-28renderer_opengl: Implement a new shader cache.bunnei1-0/+131