Pixel buffers will be imported by Cycles in Cuda/OneAPI/HIP
when supported. However the priority and export field is not filled correctly,
resulting in that the priority is always 1 and the buffer is never exported.
Should be backported to 4.5 as Cycles GPU interop isn't working
when using Vulkan.
Regression introduced by: !144422
Pull Request: https://projects.blender.org/blender/blender/pulls/146090
Although this doesn't lead to any different behaviour or fixes any issue
it was an oversight as this would not wait for empty render graphs to be
finished in the order of submission
Pull Request: https://projects.blender.org/blender/blender/pulls/146066
`GHOST_SwapWindowBuffers` doesn't fit well when using swapchains. In
that case an approach where swap chain images are acquired and released
would map better. This PR introduces `GHOST_SwapWindowBufferAcquire`
and `GHOST_SwapWindowBufferRelease` to be more in line with vulkan swap
chains.
Previous implementation would first record all GPU commands based on
the last used swap chain. In case a swapchain needed to be recreated
(window resize, move to other monitor) the recorded commands would
not match the swap chain and could lead to artifacts.
OpenGL only implements the release functions as they don't
have a mechanism to acquire a swap chain image. (Need to validate with
the Metal API how this is working and adapt is needed).
Currently when starting blender on a HDR capable display the first frame
would be based on an sRGB surface and presented on an extended RGB
(or other) surface. As these don't match the first frame could be incorrect and
also lead to UBs as another surface is expected.
Pull Request: https://projects.blender.org/blender/blender/pulls/145728
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
Even when a device is capable to allocate a buffer with a certain size
it can still fail the allocation due to driver internals. This could be that
the memory area doesn't support the required flags or fragmentation.
This PR changes downloading GPU textures to CPU to use at max buffer
sizes of 2GB. Larger textures will be split over multiple buffers.
Pull Request: https://projects.blender.org/blender/blender/pulls/145568
Maintenance4 contains the maxBufferSize property that contains the
maximum allowed buffer allocation.
This PR uses this property to precheck if allocations will fail. It
was an attempt to improve the reliability of failing allocations but
currently they fail at the driver side.
Pull Request: https://projects.blender.org/blender/blender/pulls/145555
Multiple previous changes made resource pools obsolete. Resource
pools were used to keep track of resources when the frame is rendered.
Multiple frames can be rendered at the same time and resources could
overlap.
This has been replaced (not this commit) to be part of the render graph
and when an submission has completed the resources are recycled.
Continuation of: https://projects.blender.org/blender/blender/pulls/145408
Pull Request: https://projects.blender.org/blender/blender/pulls/145511
Multiple previous changes made resource pools obsolete. Resource
pools were used to keep track of resources when the frame is rendered.
Multiple frames can be rendered at the same time and resources could
overlap.
This has been replaced (not this commit) to be part of the render graph
and when an submission has completed the resources are recycled.
Pull Request: https://projects.blender.org/blender/blender/pulls/145408
Moves the descriptor pools from resource pools to thread data.
The descriptor pools uses a recycling approach and don't need
to be guarded anymore inside a resource pool. Now only the
descriptor set tracker is inside the resource pool.
Pull Request: https://projects.blender.org/blender/blender/pulls/145393
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
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
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
Workbench transparency outlines where not working. The cause was that
the incorrect texture was bound in the pipeline due to unused
attachments being removed from the pipeline.
It seems to be an error since we added render pass support. This support
has already been removed.
Pull Request: https://projects.blender.org/blender/blender/pulls/145120
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 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
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
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
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
Swapchain handling of minimized windows wasn't correct. On some
platforms it still tried to create images with no surface.
This PR will discard swapchains of minimized windows, but still being
able to flush the render graph and free resources.
Pull Request: https://projects.blender.org/blender/blender/pulls/144189