This change does some preparations before we implement persistent
caching for static shaders.
- Move ownership of pipeline cache to the pipeline pool.
- Use two pools. one is only used for static shaders
other for non static shaders.
Related to #126229
Pull Request: https://projects.blender.org/blender/blender/pulls/127100
`atan2(0, 0)` is undefined on many platforms. To ensure consistent
result across platforms, we return `0` in this case.
Note only the behavior of the shader node `Artan2` is changed here.
During shading, we might still produce `atan2(0, 0)` internally and
cause different results across platforms, but that usually happens with
single samples and is not obvious, plus checking this condition all the
time is costly. If later we find out it's indeed necessary to change all
the invocation of `atan2(0, 0)`, we could change the wrapper functions
in `metal/compat.h` and `mtl_shader_defines.msl`.
Pull Request: https://projects.blender.org/blender/blender/pulls/126951
VSE timeline, when many (hundreds/thousands) of thumbnails were visible, was
very slow to redraw. This PR makes them 3-10x faster to redraw, by stopping
doing things that are slow :) Part of #126087 thumbnail improvements task.
- No longer do mute semitransparency or corner rounding on the CPU, do it in
shader instead.
- Stop creating a separate GPU texture for each thumbnail, on every repaint,
and drawing each thumbnail as a separate draw call. Instead, put thumbnails
into a single texture atlas (using a simple shelf packing algorithm), and
draw them in batch, passing data via UBO. The atlas is still re-created every
frame, but that does not seem to be a performance issue. Thumbnails are
cropped horizontally based on how much of their parts are visible (e.g. a
narrow strip on screen), so realistically the atlas size is kinda
proportional to screen size, and ends up being just several megabytes of data
transfer between CPU -> GPU each frame.
On this Sprite Fright edit timeline view (612 visible thumbnails), time taken
to repaint the timeline window:
- Mac (M1 Max, Metal): 68.1ms -> 4.7ms
- Windows (Ryzen 5950X, RTX 3080Ti, OpenGL): 23.7ms -> 6.8ms
This also fixes a visual issue with thumbnails, where when strips are very
tall, the "rounded corners" that were poked right into the thumbnail bitmap
on the CPU were showing up due to actual bitmap being scaled up a lot.
Pull Request: https://projects.blender.org/blender/blender/pulls/126972
This adds a new launch argument when building with
renderdoc support. It allows to trigger the capture
of a specific capture scope. This allows selective
capture of some commonly captured parts.
Pull Request: https://projects.blender.org/blender/blender/pulls/126791
Solved by not supporting complex reordering at this moment. It
is currently better to focus on quality and add back performance
later. During tests I didn't detect any user noticeable performance
degradation. Could also be because we support rendering
suspending/resuming.
Fixes artifacts in EEVEE volumes and raytracing.
Pull Request: https://projects.blender.org/blender/blender/pulls/126974
- Resource pools are shared between multiple swap chains to reduce
code complexity
- Fix issue where activating a new graphical context could still leave
the previous context rendering.
- Known issue: opening files with more windows require a redraw.
Reference: #126499
Pull Request: https://projects.blender.org/blender/blender/pulls/126961
When 'really' large buffers are allocated the incorrect clamping
function was used and the actual buffer allocated was smaller than
expected.
This was detected during investigation of #126863.
Pull Request: https://projects.blender.org/blender/blender/pulls/126915
Add Metallic BSDF Node to the shader editor.
This node can primarily be used to create more realistic looking
metallic materials than the existing Glossy BSDF node.
This commit does not add any new closures to Cycles, it simply exposes
existing closures that were previous hard to access on their own.
- Exposes the F82 fresnel type that is currently used by the
metallic component of the Principled BSDF. Results should match
between the Metallic BSDF and Principled BSDF when using the same
settings.
- Exposes the Physical Conductor fresnel type that was previously
limited to custom OSL scripts. The Conductor fresnel type accepts
IOR and Extinction coefficients to define the appearance of the
material based off real life measurements.
EEVEE only supports the F82 fresnel type with internal code to convert
the the physical conductor inputs in to a colour format for F82,
which can lead to noticeable rendering differences with
some configurations.
Pull Request: https://projects.blender.org/blender/blender/pulls/114958
When orcos are not available in the geometry data it is bound with
a default buffer. This buffer was initialized with only zeros. But
orcos required to read the 0, 0, 0, 1.
Fixes `render/shader/tex_voronoi.blend` render test.
Pull Request: https://projects.blender.org/blender/blender/pulls/126838
When rendering in background there is no swap chain in play and
resources would never be collected. Resulting in out of resources and
crashes.
This PR is an initial fix what cycles resource pools every time a layer
has been rendered. It counts the render hierarchy
(GPU_rendering_begin/end) to identify if the background render is
completed and if so would cycle to the next resource pool.
Pull Request: https://projects.blender.org/blender/blender/pulls/126819
Workaround for RDNA2 shadow rendering when the geometry it needs
to render is to tiny. In this case the rasterizer can skip triangles
leading to incorrect shadow.
This issue has been forwarded to AMD, but this is a temp workaround
for the current drivers. Note that this workaround adds a performance
penalty of around 50% in selected scenes.
Pull Request: https://projects.blender.org/blender/blender/pulls/126693
Fix crash when using EEVEE irradiance baking. When reading back the
intermediate result the active rendering was not ended, resulting
in an assert as the rendergraph is cleared and assumed to be in an
initial state (not rendering).
Pull Request: https://projects.blender.org/blender/blender/pulls/126688
Metal doesn't support RGB textures and the backend converts them to RGBA textures.
During the conversion missing RGB components should be set to 0 and missing A
component should be set to 1.
In the current implementation this was not the case and A components where also set
to 0.
PR should be backported to 4.2
Pull Request: https://projects.blender.org/blender/blender/pulls/126630
Vulkan has different depth limits then opengl. We fix this by
retargetting the opengl limits into the limits that vulkan supports.
This is done in the vertex shader, or in the geometry shader. When
viewport index or layer isn't supported a geometry shader is added to
workaround these missing features. In this case the depth range was
could be done twice (vertex shader and geometry shader).
Pull Request: https://projects.blender.org/blender/blender/pulls/126634
When using multi view only the first layer could be selected as the
rendering info only had a single layer in its main struct.
- Add failsafe for unsupported platforms
Use snake style naming for all the kernel nodes functions.
Omit kernel prefix in the names since of the using namespace.
Use full forms of the terms
('iter' -> 'iterator', 'ntree' -> 'node_tree', 'rem' -> 'remove', ...).
Pull Request: https://projects.blender.org/blender/blender/pulls/126416
This PR implements #126353; In short: keep discard list as part of swap chain images. This allows
better determination when resources are actually not in use anymore.
## Resource pool
Resource pools keep track of the resources for a swap chain image.
In Blender this is a bit more complicated due to the way GPUContext work. A single thread can have
multiple contexts. Some of them have a swap chain (GHOST Window) other don't (draw manager). The
resource pool should be shared between the contexts running on the same thread.
When opening multiple windows there are also multiple swap chains to consider.
### Discard pile
Resource handles that are deleted and stored in the discard pile. When we are sure that these
resources are not used on the GPU anymore these are destroyed.
### Reusable resources
There are other resources as well like:
- Descriptor sets
- Descriptor pools
## Open issues
There are some limitations that require future PRs to fix including:
- Background rendering
- Handling multiple windows
- Improve CPU/GPU synchronization
- Reuse staging buffers
Pull Request: https://projects.blender.org/blender/blender/pulls/126353
On Legacy AMD devices EEVEE doesn't render any geometry. During testing
we found that it was based on reading normal attribute. Further testing
it was detected that enabling the high quality normals would solve the
rendering.
This is a known issue on legacy AMD drivers. This PR updates the check
to enable the high quality normals workaround for the latest known AMD
legacy drivers (22.6.1/21.Q1.2). Both drivers still have this issue.
Pull Request: https://projects.blender.org/blender/blender/pulls/126483
This patch improves the isotropic Gabor noise UI controls such that
variations happen in both directions of the base orientation, as opposed
to being biased in the positive direction only.
Thanks to Charlie Jolly for suggesting this improvement.
This patch optimizes the Gabor noise standard deviation estimation by
computing the upper limit of the integral as the frequency approaches
infinity, since the integral is mostly constant for the relevant
frequency range. The limits are 0.25 for the 2D case and 1 / 4 * sqrt2
for the 3D case.
This also improves normalization for low frequencies, possibly due to
the effect of windowing.
Thanks to Charlie Jolly for spotting the optimization.
Optimize the Gabor noise texture code with an early exit for points that
are further away from the kernel center. This was already done for the
kernel, but is now being done earlier before computing the weight, so
its computation is now skipped.
Thanks to Charlie Jolly for the suggestion.
No need to enable the GL_ARB_conservative_depth extension as it is
core in GLSL 4.20. Some drivers still complain that the
extension was explicitly enabled.
Detected on AMD 21.Q2.1 (27.20.21026.2006) legacy driver.
Pull Request: https://projects.blender.org/blender/blender/pulls/126223
The encoded material names used by cryptomatte were incorrect. Reason
was that it used the name including the object type.
NOTE: reference images needs to be updated
Pull Request: https://projects.blender.org/blender/blender/pulls/126267
This includes the port of the edit edge shader to the new
primitive expansion API, removing split codepath and
code duplication.
Some of the shader code is duplicated for keeping the
legacy engine untouched.
Rel #102179
Pull Request: https://projects.blender.org/blender/blender/pulls/125921
Blender crashes when adding any Color compositor node when both the
viewport and the interactive compositors are active at the same time.
This is caused by a threading issue where both threads try to compile
the same GPU material at the same time.
To fix this, we protects GPU material pass compilation using a mutex.
Pull Request: https://projects.blender.org/blender/blender/pulls/126084
When we use icons that are multi-color, like for Tool icons, we'll
still need the ability to change their alpha at runtime. We do this
for hover effects, and as a theme setting.
Pull Request: https://projects.blender.org/blender/blender/pulls/126063
This PR introduces the concept of primitive expansion draws.
This allows to create a drawcall that will generate N amount of new
primitive for an original primitive in a `gpu::Batch`. The intent is to
phase out the use of geometry shader for this purpose.
This adds a new `Frequency::GEOMETRY` only available for SSBOs.
The resources using this will be fed the current `gpu::Batch` VBOs
using name matching.
A dedicated slot is reserved for the index buffer, which has its own
internal lib to decode the index buffer content.
A new attribute lib is added to ease the loading of unaligned attribute.
This should be revisited and made obsolete once more refactor
lands.
It is similar to the Metal backend SSBO vertex fetch path but it is
defined on a different level. The main difference is that this PR is
backend independant and modify the draw module instead of the GPU
module. However, it doesn't cover all possible attribute conversion
cases. This will only be added if needed.
This system is less automatic than the Metal backend one and needs
more care to make sure the data matches what the shader expects.
The Metal system will be removed once all its usage have been
converted.
This PR only shows example usage for workbench shadows. Cleanup PRs
will follow this one.
Rel #105221
Pull Request: https://projects.blender.org/blender/blender/pulls/125782