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 disables support for NVIDIA 580.76.05 drivers as it can hang
on startup with Wayland. There are reports from other applications
that this driver is faulty and NVIDIA confirmed that an updated driver
is in the making.
For now we will blacklist this specific driver on any Linux system.
Pull Request: https://projects.blender.org/blender/blender/pulls/145094
This PR adds recycling of descriptor pools. Currently descriptor pools
are discarded when full or context is flushed. This PR allows
descriptor pools to be discarded for reuse.
It is also more conservative and only discard
Descriptor pools when they are full or fragmented.
When using the Vulkan backend a small amount of descriptor memory can leak. Even
when we clean up all resources, drivers can still keep data around on the
GPU. Eventually this can lead to out of memory issues depending on how
the GPU driver actually manages descriptor sets.
When the descriptor sets of the descriptor pool aren't used anymore
the VKDiscardPool will recycle the pools back to its original VKDescriptorPools.
It needs to be the same instance as descriptor pools/sets are owned by
a single thread.
Pull Request: https://projects.blender.org/blender/blender/pulls/144992
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 is a workaround for an issue in SPIRV-Optimizer. When optimizing
large shaders the optimizer can crash. This can be fixed by altering the
maximum object ids and performing a compact ids in the end. However this
part of the API is not accessible via ShaderC.
To work around the issue shader optimizations are being disabled for
large shaders. The issue has been reported upstream.
Pull Request: https://projects.blender.org/blender/blender/pulls/144774
In `init_submission_pool`, the submission runner was started before
initializing the queues it uses, leading to a race condition that could
result in a crash.
Pull Request: https://projects.blender.org/blender/blender/pulls/144795
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
This makes the new parser code output correct errors.
Also simplify error logging.
Simplify a few things inside the parser interface.
Add debug string to the `Token` and `Scope`.
Pull Request: https://projects.blender.org/blender/blender/pulls/144708
VK_KHR_maintenance4 is enabled when available. VMA isn't aware that we
enabled it and could still use less optimized code-paths. This PR will
inform VMA that it can use the optimized code-paths.
The improvement is that we can decide in which memory area a specific
resource will be allocated, without the need of allocating the resource
header (VkImage/VkBuffer).
Pull Request: https://projects.blender.org/blender/blender/pulls/144552
Use the lately introduced parser for that.
This allows to use preprocessor directive inside them.
By extension, it alows having resource accessors inside
templates.
Also error report is less confusing on most shader compilers.
The counterpart is that the shader files that are shipped
with blender are inflated.
Pull Request: https://projects.blender.org/blender/blender/pulls/144588
Text drawing can be improved. At this moment a vertex buffer is
allocated for 2048 chars. When drawing a string the vertex buffer is
filled from the beginning with the string to draw. The next string will
replace the chars of the previous string. This locks up GPUs as the data
can only be overwritten when the buffer isn't used anymore.
Vulkan backend had an issue that uploading the new data would always
send over 2048 chars even when some chars were only used. By fixing this
the scene in the report went from 0.6 fps to 2.6 fps. OpenGL is 6 fps as
vulkan has to manage a rendergraph with 100.000 of nodes.
Text drawing performance can be improved by continue using the space of
the vertex buffers. In this case more drawing calls can be done, before
the vertex buffer needs to be updated.
Pull Request: https://projects.blender.org/blender/blender/pulls/144604
Blender had some support for using MoltenVK. However there are some key
issues why MotlenVK cannot be used. Bugs have been reported up-stream.
As it doesn't work and holds back regular developments it will be removed
from the main branch.
Any efforts on making Vulkan run on Apple (including KosmicKrisp)
is considered a community effort and can be done in a development
branch.
Pull Request: https://projects.blender.org/blender/blender/pulls/144602
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
This PR proposes to add a new flag `--shader-debug-info` that enables the generation of shader debug information.
I created this PR as WIP due to the following reasons:
- Currently it only works for the Vulkan backend. I do not know if it makes sense for other backends. For example, OpenGL directly receives the GLSL code, so there no need for this might exist.
- So far `--debug-gpu-renderdoc` already turns on the following changes for GLSL shader compilation with shaderc:
```
options.SetOptimizationLevel(shaderc_optimization_level_zero);
options.SetGenerateDebugInfo();
```
- While combining optimization level zero with debug info is a sensible choice for frame debuggers like RenderDoc, my use case for creating this PR is shader profiling. In this case, one does not want compiler optimizations to be turned off. At the current point in time, the only information my profiler uses (which is unfortunately not public at this point in time) is the name of the shader. When turning on debug information, shaderc/glslang store this information in the generated SPIR-V data. Otherwise, it would be impossible for the profiler to tell the user what the name of the shader it is that is profiled.
- An alternative solution would be to rename the entry point `main` of a shader to the name of the shader. But this might be an even uglier hack, as it requires editing the source code (and the name of the shader then needs to be a valid GLSL function name).
- We should first clarify if there is interest in the Blender side in upstreaming an option like this. While I could just keep this in my local fork of Blender, there is merit in having the possibility to profile arbitrary Blender builds.
Pull Request: https://projects.blender.org/blender/blender/pulls/142986
This PR moves the responsibility of destroying discarded resources to
the submission thread. Previous implementation could be blocked and
would not always run.
This solves memory leak when rendering in background and keeps the
overall memory usage lower as all is done in a single location.
Pull Request: https://projects.blender.org/blender/blender/pulls/144440
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
This PR will swap device local memory to system ram. It relies on
VK_EXT_external_memory and VK_EXT_pageable_device_local_memory
extensions to be supported by the system.
Most platforms support these extensions.
Pull Request: https://projects.blender.org/blender/blender/pulls/144422
There are stability issues with the vulkan backend. Some scenes indicate
that there is no space left to allocate the next descriptor buffer. For
stability reasons we will disable descriptor buffers and look into a
better solution.
Pull Request: https://projects.blender.org/blender/blender/pulls/144421
Use signed range and indices to avoid dereferencing tokens
before the start of the Token array.
# Conflicts:
# source/blender/gpu/glsl_preprocess/shader_parser.hh
This removes one limitation of the guarded scopes that needed to
not have return statement. Now a dummy return statement is created.
See #139233 for original implementation.
This adds the following features:
- `class` keyword support: checked by C++, mutated to struct for shader.
- `private` and `public` keywords: checked by C++, removed for shader.
- `static` methods.
- `const` and non-const methods.
What is not supported:
- Constructors
- Destructors
- operators
- Method definition outside of class definition
- member reference without `this` keyword.
This is implemented using a very simple lexer/parser allowing semantic traversal.
Pull Request: https://projects.blender.org/blender/blender/pulls/144025