Alternative solution to #141392 / #141564.
As a recap, the DST global lock (which prevented running drawing code
from multiple threads concurrently) was removed for 4.5 (#134690).
One unforeseen issue is that Images (and their GPUTextures) are shared
across dependency graphs (and therefore multiple threads), meaning we
are running into data race issues with them.
@fclem did #141392 and I continued it #141564. However, this is only a
partial solution, parts of the GPUTexture API and the whole BKE_image
API are still unsafe.
Trying to solve all the possible underlying issues seems unrealistic for
4.5 given the time frame and that the extension of the code affected by
this issue is quite large.
So this PR just brings the 4.4 locking behavior instead, which, while
risky on its own, seems much safer to me than the alternative.
This effectively undoes the improvements from #134690 by disabling
concurrent rendering, but instead of reverting all the code, it just
ensures we hold the lock in the same places we did in 4.4.
This means there's some redundant code that is not technically needed
anymore, like the `submission_mutex`, but it's probably best to make as
few modifications as possible, given how close we are to release and
that this is only intended as a temporary measure.
Pull Request: https://projects.blender.org/blender/blender/pulls/141618
The feature to display multiple objects in the UV and Image Editor was
added in 24d08e0bae.
This commit did not account the multi-edit mode feature, where there may
be more than one object currently being edited, causing some UVs to
display with a faded opacity.
To fix this, introduce a new `eObjectInfoFlag` flag to indicate this
state, populate it when syncing the object, and use the flag inside the
relevant shaders.
Pull Request: https://projects.blender.org/blender/blender/pulls/141254
Material selection didn't support empty geometries. Geometry list can
have nullptrs, when meshes contain more than 16 materials, but some
materials slots are not actually used in the mesh.
Material selection used to still looped over all the materials and
tried to draw geometry that aren't there.
Regression from !139781
Pull Request: https://projects.blender.org/blender/blender/pulls/141608
Reading from the top-right of the selection buffer could read
past the buffer bounds. Resolve by ensuring the clamped buffer
isn't empty. Relates to #141591.
As noted in [0], locking or atomics are not required for merging
requests for a single mesh, because there is no multithreaded iteration
over objects that will process the same mesh in multiple threads. This
locking was added preemptively over the years and has made code
needlessly complicated, even while the final design for parallel object
iteration isn't completely clear. This PR removes the locks to simplify
some changes necessary for mesh attribute storage refactors.
[0]: b6764e77ef
Pull Request: https://projects.blender.org/blender/blender/pulls/141405
This was only true when the mode was set to World.
Make it consistent with the Custom backgroubnd option and
fallback to Theme background color for lookdev and render.
Previous fix 531bc5ca69 broke the tracing part of planar
probe. This is because the code was relying on assumption that
are no longer true. Fix this by passing the correct
projection matrix and inverse proj mat to the tracing code.
Pull Request: https://projects.blender.org/blender/blender/pulls/141349
Previous fix 531bc5ca69 broke the tracing part of planar
probe. This is because the code was relying on assumption that
are no longer true. Fix this by passing the correct
projection matrix and inverse proj mat to the tracing code.
Pull Request: https://projects.blender.org/blender/blender/pulls/141349
In the viewport, semi-transparent strokes could appear more yellowish.
This was because the `reveal_tx` uses the `GPU_R11F_G11F_B10F` format
(loosing precision in the blue channel).
Now using `GPU_RGB10_A2` for `reveal_tx` to fix the issue.
We don't need to change the format for the `color_tx`.
Pull Request: https://projects.blender.org/blender/blender/pulls/141335
The alpha channel wasn't properly handled when using "multiply" layer
blending.
The formula in `blend_mode_output` for `MODE_MULTIPLY` was first
multiplying the `color.a` by `opacity`, storing the result back into
`color` but then multiplying by `color.a` again.
Instead, multiply `color.a` and `color` by the `opacity` separately.
Pull Request: https://projects.blender.org/blender/blender/pulls/141337
This was used by the legacy Grease Pencil system while using the draw
tool to quickly render a stroke buffer.
Nowadays, we don't use this buffer anymore and just rerender
the Grease Pencil object.
Change `eCustomDataType` to `bke::AttrType` for uses of the attribute
API (the `AttributeAccessor` one anyway). I didn't touch any values that
might be saved in files; those should be handled on a case by case basis.
Part of #122398
Pull Request: https://projects.blender.org/blender/blender/pulls/141301
This patch adds support for viewport compositor for grease pencil pass.
It also comes with an option for viewing grease pencil pass directly
inside the viewport without compositor.
Pull Request: https://projects.blender.org/blender/blender/pulls/140960
This commit moves Curves and Grease Pencil to use `AttributeStorage`
instead of `CustomData`, except for vertex groups. This PR mostly
involves extending the changes from the above commit for point clouds
to generalize to other geometry types.
This is mostly straightforward, though a couple non-trivial places of
note are the joining of Grease Pencil objects (`merge_attributes`), the
"default render fallback" UV for curves objects which was previously
unused at the UI level and just ended up being the first attribute, and
the `update_curve_types()` call in the curves versioning function.
Similar to:
- fa03c53d4a
- f74e304b00
Part of #122398.
Pull Request: https://projects.blender.org/blender/blender/pulls/140936
The crash seems to come from libepoxy GL functions pointing to null.
It seems that libepoxy "Automatically initializes as new GL functions are used."
and that to call a function without a GL context bound, the function
must have been called before with a bound context.
This just modifies the scope of the context binding from
DRW_module_exit to RE_engines_exit, which seems the safest solution
for 4.5.
Pull Request: https://projects.blender.org/blender/blender/pulls/141233
The bias for mapping to log color space was wrong and
was assuming `log(2x)` instead of `log2(x)`.
This made pure black colors result in 0.00008 values
after AA resolve.
Using the correct bias ensures 0 stays at 0 during the
AA process and doesn't exhibit any imprecision.
... using Select Box.
This is caused by our hack to make each triangle always output
at least 1 pixel. It stretches the triangle with a specific
winding order that is correct for any geometry even if it is
backfacing as long as it is subpixel. But if the mesh is
negatively scaled, the culling mode is flipped. Which make the
hardcoded offsets winding inverted, and then culled by the rasterizer
(or the fragment shader code).
The fix is to flip the winding order of the offsets depending on
the object matrix negativity.
This is rather expensive so we only do it for the triangles we know
are subpixels.
For some reason the orco vertex buffer is requested after the position
buffer, but they are computed together. In case that happens, just
discard the position buffer.
Pull Request: https://projects.blender.org/blender/blender/pulls/141043
This happened because the velocity module is referencing
batche to be able to copy them after drawing.
Make sure to call step swap even when shaders are not
ready to ensure we don't dereference these possibly
freed batches on the next draw.
This also fixes the crashing benchmarks.
Pull Request: https://projects.blender.org/blender/blender/pulls/141022
This avoid legacy code inside the DRWContext.
Note that this change the draw order w.r.t. gizmos. Now the
gizmos will hide the text.
Moreover, streamline the condition for enabling text drawing
in order to fix#78971.
Prepare for #140378 by replacing all uses of `ResourceHandle` inside
the engine code with `ResourceHandleRange`.
Aside from the replacement, this changes `ResourceHandleRange` itself
to ensure we use them correctly:
- Prevent direct access to the first handle, to avoid not taking ranges
into account by mistake.
- Add missing functions that are safe to use for ranges
(`has_inverted_handedness` and `is_valid`).
- Add functions that aren't safe to use for ranges, but are required
for the code paths that don't support them yet (these functions assert
that the range points to a single handle, and therefore can be used
safely).
The main change is in `draw_handle.hh`, everything else is just a 1:1
port to use these new functions.
Pull Request: https://projects.blender.org/blender/blender/pulls/140611
CustomData lookup is very expensive compared to everything else
happening in this function. Use a slightly ugly approach to avoid it
when the display type isn't "Attribute" or "Texture". This gives a 5%
FPS playback improvement in the Erindale Flower shop demo file.
Pull Request: https://projects.blender.org/blender/blender/pulls/140547