This is the first step of moving the create infos
back inside shader sources.
All info files are now treated as source files.
However, they are not considered in the include tree
yet. This will come in another following PR.
Each shader source file now generate a `.info` file
containing only the create info declarations.
This renames all info files so that they do not
conflict with their previous versions that were
copied (non-generated).
Pull Request: https://projects.blender.org/blender/blender/pulls/146676
This allows to reduce the number of includes for each
tree graph (surface, volume, displacement) and
reduce the code size significantly for most vertex
shaders, speeding up compile time.
Rel #145347
Pull Request: https://projects.blender.org/blender/blender/pulls/146419
Dependencies were previously merged manually
inside the generated_sources by EEVEE.
This caused issues with double includes.
Instead, we now only gather the name of the
nodetree dependencies and add them to the
dependencies of the `GeneratedSource`.
This also make the compositor use the `GeneratedSource`
mechanism.
Pull Request: https://projects.blender.org/blender/blender/pulls/146106
The goal of this patch is to reduce final shader code footprint to
hopefully reduce shader compile time (see #145347).
This also contains a pass over most shader file to remove unused
include or use more granular ones to reduce final shader code
length.
Testing with the same setup as #145347:
| | main (ms) | PR (ms) | Delta (ms) |
| -------- | ----------- | ------------ |------------ |
| Nvidia | 257 | 207 (1.24x) | 50 |
| Mesa AMD | 323 | 295 (1.09x) | 28 |
In barbershop test scene however the saving are not so noticeable:
| | main (s) | PR (s) | Delta (s) |
| -------- | ----------- | ------------ |------------ |
| Nvidia (OpenGL) | 40 | 39 (1.02x) | 1 |
| Nvidia (Vulkan) | 29 | 29 (1.0x) | 0 |
Pull Request: https://projects.blender.org/blender/blender/pulls/145803
This adds a function that can turn an existing `bNodeTree` into an inlined one.
The new node tree has all node groups, repeat zones, closures and bundles
inlined. So it's just a flat tree that ideally can be consumed easily by render
engines. As part of the process, it also does constant folding.
The goal is to support more advanced features from geometry nodes (repeat zones,
etc.) in shader nodes which the evaluator is more limited because it has to be
able to run on the GPU. Creating an inlined `bNodeTree` is likely the most
direct way to get but may also be limiting in the future. Since this is a fairly
local change, it's likely still worth it to support these features in all render
engines without having to make their evaluators significantly more complex.
Some limitations apply here that do not apply in Geometry Nodes. For example,
the iterations count in a repeat zone has to be a constant after constant
folding.
There is also a `Test Inlining Shader Nodes` operator that creates the inlined
tree and creates a group node for it. This is just for testing purposes.
#145811 will make this functionality available to the Python API as well so that
external renderers can use it too.
The link buffer was not free on exit.
Previous implementation was freing it with the
gpu::Batch which is registered as preset.
This commit introduces buffer registration
to free them on exit.
Pull Request: https://projects.blender.org/blender/blender/pulls/145921
Functions for convert between the color types and ostream support are
now outside the classes.
Many files were changed to fix cases where direct includes for headers
were missing.
Pull Request: https://projects.blender.org/blender/blender/pulls/145756
See the code comments for detailed explanation. But overall we use particular
combinations of sRGB and gamma 2.2 encode/decode to match SDR applications
while still ensuring HDR values are passed on linearly.
This means the user interface and SDR content will display different in
Windows HDR mode off and on, but that is consistent with other applications.
Split use_hdr variable into use_hdr_buffer about the graphics buffer,
and use_hdr_display about the chosen display in Blender.
Ref #145022
Pull Request: https://projects.blender.org/blender/blender/pulls/145025
162a24e05d had to be reverted, since it
didn't take into account other types of dynamically generated
`ShaderCreateInfo` (external shaders like OCIO or Python ones).
This just marks `ShaderCreateInfo`s as generated by default and only
sets the ones from gpu_shader_create_info_list as non generated.
Pull Request: https://projects.blender.org/blender/blender/pulls/145128
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
The OpenGL specs require that the storage image qualifier in shaders
(e.g., "rgba32f") needs to be compatible with the format of a bound image
(see https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf#page=318).
We know that Blender currently does not handle this correctly in
multiple places. AMD and NVIDIA seem to silently ignore a mismatch and
just seem to use the format of the bound image. However, for the
Intel Windows drivers, this seems to lead to visual corruptions
(#141436, #141173). While a more graceful handling of a mismatch may
be nice, this is in line with the OpenGL specs.
This PR adds code for validating image formats for bindings.
Pull Request: https://projects.blender.org/blender/blender/pulls/143791
Use SSBO loads instead.
Contains a cleanup pass to bring this shader to current shader
standards.
This removes the non-instance version of the shader as it is
not necessary anymore.
The motivation for this is to remove the instance buffer from
the batch API.
Pull Request: https://projects.blender.org/blender/blender/pulls/145238
Implementation of the design task #142969.
This adds the following:
- Exact GPU interpolation of curves of all types.
- Radius attribute support.
- Cyclic curve support.
- Resolution attribute support.
- New Cylinder hair shape type.

What changed:
- EEVEE doesn't compute random normals for strand hairs anymore. These are considered legacy now.
- EEVEE now have an internal shadow bias to avoid self shadowing on hair.
- Workbench Curves Strip display option is no longer flat and has better shading.
- Legacy Hair particle system evaluates radius at control points before applying additional subdivision. This now matches Cycles.
- Color Attribute Node without a name do not fetch the active color attribute anymore. This now matches Cycles.
Notes:
- This is not 100% matching the CPU implementation for interpolation (see the epsilons in the tests).
- Legacy Hair Particle points is now stored in local space after interpolation.
The new cylinder shape allows for more correct hair shading in workbench and better intersection in EEVEE.
| | Strand | Strip | Cylinder |
| ---- | --- | --- | --- |
| Main |  |  | N/A |
| PR |  |  |  |
| | Strand | Strip | Cylinder |
| ---- | --- | --- | --- |
| Main |  | | N/A |
| PR | ||  |
Cyclic Curve, Mixed curve type, and proper radius support:

Test file for attribute lookup: [test_attribute_lookup.blend](/attachments/1d54dd06-379b-4480-a1c5-96adc1953f77)
Follow Up Tasks:
- Correct full tube segments orientation based on tangent and normal attributes
- Correct V resolution property per object
- More attribute type support (currently only color)
TODO:
- [x] Attribute Loading Changes
- [x] Generic Attributes
- [x] Length Attribute
- [x] Intercept Attribute
- [x] Original Coordinate Attribute
- [x] Cyclic Curves
- [x] Legacy Hair Particle conversion
- [x] Attribute Loading
- [x] Additional Subdivision
- [x] Move some function to generic headers (VertBuf, OffsetIndices)
- [x] Fix default UV/Color attribute assignment
Pull Request: https://projects.blender.org/blender/blender/pulls/143180
When using multiple planar probes only the last one would
be visible. The other probes would use the world probe.
Reason is that the data of planar probes are stored in
layered textures. When updating planar probes framebuffers
are created with the correct layer attached.
Vulkan backend missed some code paths to clear a single layer
when clearing a framebuffer where the previous action had depth
write disabled. This PR adds the missing code path.
Pull Request: https://projects.blender.org/blender/blender/pulls/145170
This is motivated by the latest changes to the preprocessor
which outputs a lot of line directives when code is
generated or unrolled.
In this case the reported line would be correct but not
correctly displayed.
Moreover the system of outputing hashes inside the
`#line` directive proved to be incompatible with some
compilers and tools (renderdoc).
This commit always comments the line directives before
compilation (solves the compatibility issue).
When error logging, we then scan the commented
directives to output the correct filename and source
line. The log line is kept untouched and will show
the correct final generated code that triggered the
error.
This also fixed the error line parsing for vulkan.
Pull Request: https://projects.blender.org/blender/blender/pulls/145096
Faster and better looking VSE scopes & "show overexposed". Waveform &
RGB Parade now can also show HDR color intensities. (Note: this is
only about VSE scopes; Image Space scopes are to be improved separately)
- Waveform, RGB Parade, Vectorscope scopes are done on the GPU now, by
drawing points for each input pixel, and placing them according to
scope logic. The point drawing is implemented in a compute shader,
with a fragment shader resolve pass; this is because drawing lots of
points in the same location is very slow on some GPUs (e.g. Apple).
The compute shader rasterizer is several times faster on regular
desktop GPU as well.
- If a non-default color management is needed (e.g. VSE colorspace is
not the same as display colorspace, or a custom look transform is used
etc. etc.), then transform the VSE preview texture into display space
RGBA 16F texture using OCIO GPU machinery, and calculate scopes
from that.
- The "show overexposed" (zebra) preview option is also done on the
GPU now.
- Waveform/Parade scopes unlock zoom X/Y aspect for viewing HDR scope,
similar to how it was done for HDR histograms recently.
- Added SEQ_preview_cache.hh that holds GPU textures of VSE preview,
this is so that when you have a preview and several scopes, each of
them does not have to create/upload their own GPU texture (that would
both waste memory, and be slow).
Screenshots and performance details in the PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/144867
This does a few things:
- Add support for templated struct.
- Change parsing of template scope.
Now all template scope `<..>` are parsed properly.
- Rework to support better match syntax.
- Avoid warning from scope guard processing. Now initialize
the return value to zero.
Pull Request: https://projects.blender.org/blender/blender/pulls/145132
Running valgrind on a render test exhibit a lot of warnings
about `Conditional jump or move depends on uninitialised value(s)`.
This patch makes sure to initialize the memory to avoid
platform dependent bugs.
Pull Request: https://projects.blender.org/blender/blender/pulls/144995
This PR adds HDR support for Windows for `VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT`
on `VK_FORMAT_R16G16B16A16_SFLOAT` swapchains .
For nonlinear surface formats (sRGB and extended sRGB) the back buffer is blit into the swapchain,
When VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT is used as surface format a compute shader
is used to flip and invert the gamma.
SDR white level is updated from a few window event changes, but actually
none of them immediately respond to SDR white level changes in the system.
That requires using the WinRT API, which we don't do so far.
Current limitations:
- Intel GPU support
- Dual GPU support
In the future we may add controls inside Blender for absolute HDR nits,
across different platforms. But this makes behavior closer to macOS.
See !144565 for details
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/144717
This was a temporary solution until we had proper HDR displays.
* Auto detect from the display + view transform if they are HDR, and
enable it automatically. This is based on encoding hdr-video in the config.
* If a HDR transform is selected and there is no HDR display support, an
info message will be shown in the color management panel.
* It is now possible to view HDR images in the image editor, without
needing to use "View as Render".
* There is no versioning to switch to a HDR display, because that also
affects image saving. So users will have to manually select the
"Rec.2100 PQ" display to see HDR colors again.
Ref #144911
Pull Request: https://projects.blender.org/blender/blender/pulls/144565
* Change meaning of display device to be the device that we are trying
to emulate, not the monitor configuration.
* The display transform is now:
* User specified view and display transform
* Clamp to 0 to limit colors to gamut
* Inverse untonemapped display transform
* Convert to extended sRGB
* When using the display space in the color management API, it now needs to
be specified if it's for drawing (with emulation) or file output or color
inspection (without).
Like HDR, this only works on macOS and Linux + Wayland + Vulkan currently.
Support for Windows/Vulkan is under development in #144717.
Ref #144911
Pull Request: https://projects.blender.org/blender/blender/pulls/144565
This allows to control the type of data inside the create infos for
easy variation of the same shader.
Also this wraps the last global shader resource usage for the future
SRD.
Pull Request: https://projects.blender.org/blender/blender/pulls/144769
Add a command line argument --gpu-vsync on/off/auto.
Prefer command line arguments for GPU settings,
as it means the value is error checked and set when Blender starts.
Also refactor GHOST_Context to take a parameter argument which
includes the stereo-visual & debug arguments and includes the newly
added vsync setting. This makes it possible to add GPU context
parameters more easily in the future.
It also removes redundant parsing & setting the VSync setting for
off-screen contexts.
Changes to recent PR !143049.
Ref !144473
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
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
On some drivers, the GLSL compiler doesn't reflect the omitted
`local_size_*` of a compute shader inside `gl_WorkGroupSize`.
This lead to the 2D size computation of 1D workgroups to become
0 which was bypassing the parallel reduction algorithms.
Ensuring `local_size_*` are always set fixes the issue.
For clarity, also fix the 1D shaders to not use `gl_WorkGroupSize.y`.
This also fix a copy paste error in the Metal backend.
This issue affected AMD drivers on Windows.
Rel #142046
Candidate for backporting to 4.5 LTS.
Pull Request: https://projects.blender.org/blender/blender/pulls/144056
The Map UV node does not work when the UV input is a single value, where
it is expected that the output will also be single value. This was
simply not implemented for GPU, so this patch does that.
Pull Request: https://projects.blender.org/blender/blender/pulls/143096
When creating `GPUSecondaryContext`s, `epoxy_gl_version` returns 0 and
`epoxy_has_gl_extension` always returns false.
This is caused by `GPU_context_create` being called without the ghost
context being activated.
Activating it fixes the issue.
Pull Request: https://projects.blender.org/blender/blender/pulls/142715