23 Commits

Author SHA1 Message Date
Aras Pranckevicius
ed9fc54e0e Fix #147006: VSE preview crashes with too high output resolution
Check whether creating GPU textures succeeds before using them.
However, currently when that happens there is no indication to the user
that "hey the resolution is maybe too big". Not sure what is the best
way to do that however; e.g. Workbench rendering also does not
indicate that in a similar scenario.

While at it, add GPU_is_safe_texture_size instead of duplicating
the same logic in two places.

Pull Request: https://projects.blender.org/blender/blender/pulls/147043
2025-10-01 10:08:18 +02:00
Clément Foucault
e098441b5a GPU: Material: Improve limit of UBO size
This moves the UBO size limit to be a capability.
This allows to check if size fits the requirements before
creating it and avoids hitting an assert.

Rel #146705

Pull Request: https://projects.blender.org/blender/blender/pulls/146728
2025-09-25 09:44:12 +02:00
Clément Foucault
36151962d6 Cleanup: GL: Remove unused AMD workaround
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/146404
2025-09-17 14:23:32 +02:00
Clément Foucault
03296e6679 GPU: Remove unused workarounds
The line workaround is no longer necessary since the
shader now uses SSBO and is less likely to have
issues (more tested path).

The source patching is now always done in the GL and VK
backend before compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/145240
2025-08-27 16:01:07 +02:00
Clément Foucault
cae6c6d81a GPU: Remove Shader Draw Parameter workaround
With 5.0 we start requiring this extension for GL and VK.
All of our target hardware supports it with up to date
drivers.

Some old drivers were disabling this extension because of
buggy behavior. We simply drop support for them in 5.0.

This allows us to remove a lot of code and the last
shader create info override done at startup. This will
unlock more refactoring of the shader create info into
static classes to reduce binary size and other benefits.

## TODO:
- [x] Remove checks for ARB_shader_draw_parameters
- [x] Remove checks for ARB_clip_control
- [x] Check for the extension on startup for OpenGL
- [x] Check for the extension on startup for Vulkan
- [x] ~~Add user facing popup message about minimum
      requirements not being met.~~ Done using the same
      popup as old hardware.

Pull Request: https://projects.blender.org/blender/blender/pulls/142334
2025-08-12 14:04:41 +02:00
Jeroen Bakker
97f1aeb84c Vulkan: Remove support for render passes
Vulkan 1.0 render passes have been replaced by dynamic rendering in 1.2.
Blender Vulkan backend was implemented with dynamic rendering in mind.
All our supported platforms support dynamic rendering. Render pass support
was added to try to work around an issue with legacy drivers. However these
drivers also fail with render passes.

Using render passes had several limitations (blending and some workbench
features were not supported).  As no GPU uses it and it is quite some code
to support it is better to remove it.

Pull Request: https://projects.blender.org/blender/blender/pulls/144149
2025-08-08 08:08:58 +02:00
Clément Foucault
55a0e427c5 GPU: Remove mip render workaround and recursive downsample
Recursive downsample was only used by workbench DoF
which can be expressed using mip view instead.

The mip render workaround was creating GL error on startup
and is not needed anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/143246
2025-07-28 19:05:36 +02:00
Clément Foucault
1c47e31367 GPU: Enable GL multithreaded compilation by default
This allows to reduce the waiting time caused by
shader compilation on some GPU-driver combo.

A new settings in the User Preferences make it
possible to override the default amount of worker
threads and optionally use subprocesses.

We still use only one worker thread in cases where
there is no benefit with adding more workers
(like AMD pro driver and Intel windows).

It doesn't scale as much as subprocesses for material
shader compilation but that is for other reasons
explained in #139818.

Add some heuristic to avoid too much memory usage
and / or too many stalls.

Also add some heuristic to the default number of subprocess for
the platform that shows scalling.

Historically, multithreaded compilation was prevented by the
need of context per thread inside `DRWShader` module.
Also there was no good scaling at that time. But
nowadays numbers shows different results with
good scaling with reasonable amount of threads on many
platforms.

Even if we are going for vulkan in the next release
most of the legacy hardware will still use OpenGL for
a few other releases. So it is relevant to make this
easy improvement.

See pull request for measurements.

Pull Request: https://projects.blender.org/blender/blender/pulls/139821
2025-06-09 12:36:06 +02:00
Clément Foucault
ca88983af2 EEVEE: Reverse-Z implementation
This feature greatly increase depth buffer precision.
This is very noticeable in large view distance scenes.

This is enabled by default on GPUs that supports it (most of the hardware we
support already supports this). This makes rendering different on the GPUs
that do not support that feature (`glClipControl`).

While this give much better depth precision as before, we also have a lot of
imprecision caused by our vertex transformations. This can be improved in
another task.

Pull Request: https://projects.blender.org/blender/blender/pulls/138898
2025-05-19 16:29:26 +02:00
Miguel Pozo
992e7c95a7 GPU: Converge ShaderCompiler implementations
Part of #136993.

Share as much of the ShaderCompiler implementations as possible.
Remove the ShaderCompiler/ShaderCompilerGeneric split and make most of
its functions non virtual.
Move the `get_compiler` function from `Context` to `GPUBackend` and
creation/deletion to `GPUBackend::init/delete_resources`.
Add a `batch_cancel` function to `ShaderCompiler` (needed for the
GPUPass refactor).

As a nice extra, the multithreaded OpenGL compilation has become faster
too.
The barbershop materials + EEVEE static shaders have gone from 27s to
22s.

I have not observed any performance difference on Vulkan or Metal.

Pull Request: https://projects.blender.org/blender/blender/pulls/136676
2025-05-08 18:16:47 +02:00
Miguel Pozo
41ae990b29 Cleanup: Remove StencilViewWorkaround and GPU_texture_view_support()
Texture views should be fully supported everywhere now.

Pull Request: https://projects.blender.org/blender/blender/pulls/137863
2025-04-23 20:57:00 +02:00
Clément Foucault
04fcf2f907 Merge branch 'blender-v4.4-release' 2025-03-05 12:06:00 +01:00
Clément Foucault
326ce59961 Fix #134509: GPU: Add workaround for Intel ARC nodelink driver bug
This disables the instancing optimization for this specific
hardware.

Pull Request: https://projects.blender.org/blender/blender/pulls/135458
2025-03-05 12:05:34 +01:00
Clément Foucault
86b70143d5 Cleanup: GPU: Remove unused Transform Feedback implementation
Most of the cleanup is inside the metal backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/134349
2025-02-10 17:30:42 +01:00
Aras Pranckevicius
074df4ceeb GPU: ensure viewport does not use uninitialized images (#119685 and others)
GPUViewport is creating a bunch of framebuffer textures for itself, but
some space types never initialize/use them. E.g. Sequencer, Nodes etc.
only ever use the "overlay" texture. Eventually when viewport is
"drawn", it combines this uninitialized texture data and then only by
luck it happens that most of the time it is black. But not always!

The textures were only cleared (right now) on Metal backend, under
GPU_clear_viewport_workaround as if it was some driver workaround. Stop
doing that, and just clear them always.

However, there was seemingly a performance issue on OpenGL, when this
clear was being done. At least on my machine (Win10, Geforce RTX
3080Ti), the overhead of doing the clears is measurable, and is caused
by usage of GL4.4 glClearTexImage instead of a framebuffer clear. As if
glClearTexImage makes "pixel data to exist" on the CPU side and then
later on binding this framebuffer sends off that data to the GPU, or
somesuch.

More details in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/131518
2024-12-09 13:23:18 +01:00
Clément Foucault
ec84fe5fdb Fix #131091: GL: Weird Lines appearing in Gizmo Overlays
This happened because NVidia GPUs require higher alignment
for SSBO binds than for vertex inputs.

This is related to	#131103 which fixed it for vulkan.

Add a common capability option for that.
2024-11-28 17:22:12 +01:00
Jeroen Bakker
272403a6cb Vulkan: Remove empty attachments
Some Vulkan platforms don't support framebuffers with gaps between the
color attachments. Workbench framebuffers can create gaps.
(`in_front_fb`, `main_fb` when used for wire frame drawing).

This PR implements a detection mechanism to detect gaps. It also disables
features that are not able to comply to this requirement.

Detected when working on #129062

Pull Request: https://projects.blender.org/blender/blender/pulls/130258
2024-11-14 13:55:33 +01:00
Clément Foucault
43b5e2d0ed Fix: EEVEE: Add buffer workaround for stencil classification
Adding a dummy storage buffer to the classification shader
seems to fix the issue on Qualcomm drivers (WoA).

The workaround is added to the force workaround option to
allow other platforms to test the fix.

Rel #122837

Pull Request: https://projects.blender.org/blender/blender/pulls/129857
2024-11-05 17:12:28 +01:00
Campbell Barton
004c247670 Cleanup: different declaration names, use r_ prefix for return args 2024-07-29 13:01:10 +10:00
Miguel Pozo
4c314f9a78 GPU: Add --gpu-compilation-subprocesses cmd setting
Allow overriding the `max_parallel_compilations` from the command
line.
Disable compilation subprocesses on RenderDoc sessions.

Pull Request: https://projects.blender.org/blender/blender/pulls/123995
2024-07-01 16:36:01 +02:00
Miguel Pozo
74224b25a5 GPU: Add GPU_shader_batch_create_from_infos
This is the first commit of the several required to support
subprocess-based parallel compilation on OpenGL.
This provides the base API and implementation, and exposes the max
subprocesses setting on the UI, but it's not used by any code yet.

More information and the rest of the code can be found in #121925.

This one includes:
- A new `GPU_shader_batch` API that allows requesting the compilation
  of multiple shaders at once, allowing GPU backed to compile them in
  parallel and asynchronously without blocking the Blender UI.
- A virtual `ShaderCompiler` class that backends can use to add their
  own implementation.
- A `ShaderCompilerGeneric` class that implements synchronous/blocking
  compilation of batches for backends that don't have their own
  implementation yet.
- A `GLShaderCompiler` that supports parallel compilation using
  subprocesses.
- A new `BLI_subprocess` API, including IPC (required for the
  `GLShaderCompiler` implementation).
- The implementation of the subprocess program in
  `GPU_compilation_subprocess`.
- A new `Max Shader Compilation Subprocesses` option in
  `Preferences > System > Memory & Limits` to enable parallel shader
  compilation and the max number of subprocesses to allocate (each
  subprocess has a relatively high memory footprint).

Implementation Overview:
There's a single `GLShaderCompiler` shared by all OpenGL contexts.
This class stores a pool of up to `GCaps.max_parallel_compilations`
subprocesses that can be used for compilation.
Each subprocess has a shared memory pool used for sending the shader
source code from the main Blender process and for receiving the already
compiled shader binary from the subprocess. This is synchronized using
a series of shared semaphores.
The subprocesses maintain a shader cache on disk inside a
`BLENDER_SHADER_CACHE` folder at the OS temporary folder.
Shaders that fail to compile are tried to be compiled again locally for
proper error reports.
Hanged subprocesses are currently detected using a timeout of 30s.

Pull Request: https://projects.blender.org/blender/blender/pulls/122232
2024-06-05 18:45:57 +02:00
Jeroen Bakker
0c2085a316 GPU: Remove GPU_compute_shader_support
Compute shaders are required since 4.0. There was one occasion where
an older AMD driver failed and support was turned off. This driver
is now marked unsupported.

This PR includes:
- removing the check in viewport compositing
- remove properties from system info
- always construct draw manager.
- remove unused pass logic in draw hair/curves
- add deprecation warning when accessed from python

Pull Request: https://projects.blender.org/blender/blender/pulls/120909
2024-04-22 13:28:10 +02:00
Hans Goudey
8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00