This patch refactors the backdrop offset to be stored as a float instead
of an int and to be stored in the image runtime structure instead of the
image itself.
Pull Request: https://projects.blender.org/blender/blender/pulls/119877
This is intended to be used in the new exact mesh boolean algorithm by @howardt.
The new `BLI_fixed_width_int.hh` header provides types like `Int256` and
`UInt256` which are like e.g. `uint64_t` but with higher precision. The code
supports many different integer sizes.
The following operations are supported:
* Addition
* Subtraction
* Multiplication
* Comparisons
* Negation
* Conversion to and from other number types
* Conversion to and from string (based on `GMP`)
Division is not implemented. It could be implemented, but it's more complex and
is not required for the new mesh boolean algorithm.
Some alternatives to having a custom implementation have been discussed in
https://devtalk.blender.org/t/fixed-length-multiprecision-arithmetic/29189/.
Generally, the implementation is fairly straight forward. The main complexity is
the addition/multiplication algorithm which isn't too complicated. It's nice to
have control over this part as it allows us to optimize the code more if
necessary. Also, from what I understand, we might be able to benefit from some
special cases like multiplying a large integer with a smaller one.
I tried some different ways to optimize this already, but so far the normal
compiler optimization turned out to work best. Not sure if the same is true on
windows though, as it doesn't have native support for an `int128` which helps
the compiler understand what I'm doing. Alternatives I tried so far are using
intrinsics directly (mainly `_addcarry_u64` and similar), writing inline
assembly manually and copying the assembly output from the compiler. I assume
the assembly implementation didn't help for me because it prohibited other
compiler optimizations.
Pull Request: https://projects.blender.org/blender/blender/pulls/119528
We already expose two other types that don't have a directly
corresponding socket type-- float2 and byte colors. This also solves
the inability to write to the nurbs_order attribute in geometry nodes.
Fixes#119843
Pull Request: https://projects.blender.org/blender/blender/pulls/119879
This was necessary when attributes were stored embedded in legacy
structs like `MPoly`. Nowadays that isn't the case anymore, and there
doesn't seem to be a reason to restrict the creation of attributes.
update_on_change_ shouldn't be called when creating an attribute but
not setting the array values. In that case it is UB to not set the values
elsewhere anyway, and that will cause its own update tag.
4d0936c7d74bee32cd50 explicitly avoids turning non-geometry object
instances into geometry instances. This code is called to prepare
geometry sets for baking, and baking currently assumes that the baked
instances are always geometry sets.
To fix this, just check the instance type and serialize an empty
geometry set for the crashing object instance case. Compared to before
the crash causing commit, there is no change in behavior, since that
would have created empty geometry sets too.
Pull Request: https://projects.blender.org/blender/blender/pulls/119892
All builtin attributes are now stored as named attributes, so the old
code path from where they were stored with non-generic types can be
removed. The stored type and attribute type don't have to be tracked
separately anymore either.
The change to use generic "capture field on geometry" utilities for this
node and other nodes like it means `AttributeWriter` with its update
tagging isn't being used anymore, the attribute is just being created
with the new values (for some cases anyway). To fix this, call the
attribute provider's update function when creating the attribute too.
This was noted as useful in 130701763bdb9e104486 too.
The initialization of curve and point cloud runtime structs is moved
because they now have to be allocated before any attributes are added.
In the tiled compositor ensure_delta() can be called from multiple threads,
but without any threading synchronization. This worked fine when the node
only supported absolute transform: multiple threads would do the same work
and assign delta to the same values.
With the addition of relative transform in #115947 a code which adjusts
previously calculated delta was added, leading to possible double-applying
relative transform.
The solution is to avoid multiple threads modifying the same data by using
a double-locked check.
This issue does not happen in 4.2 (main branch) because it switched to full
frame compositor, which works differently.
Pull Request: https://projects.blender.org/blender/blender/pulls/119883
Previously, the bake settings in geometry nodes were not
editable even though they were stored on the overridden
object (instead of the not-overridden but linked node tree).
Pull Request: https://projects.blender.org/blender/blender/pulls/119874
USD files are now findable from the cachefile.open() and
cachefile.layer_add() operators. Removed the ".abc" appending when
looking for a file for the first time, as it no longer makes sense.
Pull Request: https://projects.blender.org/blender/blender/pulls/118685
This patch ports the GLSL SMAA library to the CPU compositor in order to
unify the anti-aliasing behavior between the CPU and GPU compositor.
Additionally, the SMAA texture generator was removed since it is now
unused.
Previously, we used an external C++ library for SMAA anti-aliasing,
which is itself a port of the GLSL SMAA library. However, the code
structure and results of the library were different, which made it quite
difficult to match results between CPU and GPU, hence the decision to
port the library ourselves.
The port was performed through a complete copy of the library to C++,
retaining the same function and variable names, even if they are
different from Blender's naming conversions. The necessary code changes
were done to make it work in C++, including manually doing swizzling
which changes the code structure a bit.
Even after porting the library, there were still major differences
between CPU and GPU, due to different arithmetic precision. To fix this
some of the bilinear samplers used in branches and selections were
carefully changed to use point samplers to avoid discontinuities around
branches, also resulting in a nice performance improvement. Some slight
differences still exist due to different bilinear interpolation, but
they shall be looked into later once we have a baseline implementation.
The new implementation is slower than the existing implementation, most
likely due to the liberal use of bilinear interpolation, since it is
quite cheap on GPUs and the code even does more work to use bilinear
interpolation to avoid multiple texture fetches, except this causes a
slow down on CPUs. Some of those were alleviated as mentioned in the
previous section, but we can probably look into optimizing it further.
Pull Request: https://projects.blender.org/blender/blender/pulls/119414
This patch unifies the sRGB to Linear color space conversion between the
CPU and GPU compositors. This is because CPU uses an optimized path that
produces values that are very slightly off. To fix this, for the GPU, we
do the conversion CPU side instead of doing it in a shader. Since images
are cached, the performance implications are not significant.
Another added benefit is that we no longer get differences due to the
order of alpha pre-multiplication and sRGB conversion, demonstrated in
#114305. And we no longer require any preprocessing of the images.
This patch adds some new utilities to the Image Buffer module to assign
float, byte, and compressed buffers along with their color spaces. It
also adds an ownership flag to compressed data. Those were added as a
way to facilitate the implementation.
Pull Request: https://projects.blender.org/blender/blender/pulls/118624
`asset_lib` is null when calling undo in active file browser space.
This causes crash in `asset undo poll`. So exit out of the poll function
when active file space is filebrowser.
Pull Request: https://projects.blender.org/blender/blender/pulls/119870
object_index is not found (-1) when all mesh data is deleted hence it
crashes when accessing base from the vector at index -1.
So skip the further execution to prevent crash.
Pull Request: https://projects.blender.org/blender/blender/pulls/119865
This commit fixes the following assert:
mtl_command_buffer.mm:165, submit(), at 'MTLBackend::get()->is_inside_render_boundary()'
It happens when toggling rendered state of viewport on macOS, and is
caused by incorrect order of setting active GPU context to null and
calling GPU_render_end.
This change makes the flow of GPU_render_{beign, end} and GPU context
activation closer to what it is in the draw manager's functions
DRW_render_context_{enable, disable}.
Pull Request: https://projects.blender.org/blender/blender/pulls/119868
Fix the "Merge Vertices" report, replacing "vertice(s)" with either
"vertex" or "vertices". The singular "vertice" is not a word in English,
and thus the regular "append (s)" approach is incorrect.
Pull Request: https://projects.blender.org/blender/blender/pulls/119863
This caused an ASan abort while looking into #101993.
From what I can tell, the issue is that when you click the render button on
the Render Layer node, RENDER_OT_render sets the callback. Then, when you
hit F12 later, it reuses the Render from before, including the callback,
but the corresponding handle has been freed already.
When areas are dragged very small we want the (visual) vertical minimum
to equal header height, and the horizontal minimum to be equal to the
Properties nav area width. This PR just makes these adjust correctly
with changes of resolution scale and line width.
Pull Request: https://projects.blender.org/blender/blender/pulls/119848
Now that all relevant code is C++, the indirection from the C struct
`GPUVertBuf` to the C++ `blender::gpu::VertBuf` class just adds
complexity and necessitates a wrapper API, making more cleanups like
use of RAII or other C++ types more difficult.
This commit replaces the C wrapper structs with direct use of the
vertex and index buffer base classes. In C++ we can choose which parts
of a class are private, so we don't risk exposing too many
implementation details here.
Pull Request: https://projects.blender.org/blender/blender/pulls/119825
Currently we have a cache for all combinations of "strand/strip" and
the four subdivision levels. Recomputing this data should be very fast
and doesn't require re-uploading data from the CPU. Because they are
scene settings, they will be the same for all render engines too, so we
won't have a case where we're constantly requesting different values.
The extra caches just complicate code, so better to remove them. Now
the final evaluated cache remembers the settings it was created with,
and it's cleared if they are changed.
Pull Request: https://projects.blender.org/blender/blender/pulls/119804
The issue is that a draw call in the sequencer does not have any
knowledge of the viewport's wireframe opacity and threshold settings,
defaulting both to 0.
A similar issue #86956 implemented a quick hack to fix grease pencil
shading in VSE, so I opted to do the same here. In the future, a better
solution could be implemented to preserve the entire v3d.overlay.
I should note that I made `wireframe_threshold = 0.5f` to match the
default value given in `versioning_280.cc` but if this works better
as `1.0f` instead let me know.
Pull Request: https://projects.blender.org/blender/blender/pulls/119811
This allows to use unions on the C++ side and safe type
casting on the GPU side.
The type casting functions are statically verified at
compile time in C++.
This PR doesn't change the size of the light struct
but removes the need of packing floats in the `object_mat`.
The matrix will be changed to a `float4x3` in another PR
and will reduce the struct by 16 bytes.
This remove the need for the light parameters macros and
reveals the padding members that could be used for future
features for each type.
After this, all accesses to light type dependent data in
the shaders should be done using:
- `LightLocalData light_local_data_get(LightData light)`
- `LightSpotData light_spot_data_get(LightData light)`
- `LightAreaData light_area_data_get(LightData light)`
- `LightSunData light_sun_data_get(LightData light)`
Note that these functions are simple passthrough for Metal
since it supports `union` (but enforce for error checking
if option is enabled).
The error check on GPU is a bit costly so it is disabled
by default.
Pull Request: https://projects.blender.org/blender/blender/pulls/119713
It is unknown why/how this can happen, but there are some files out there
that have e.g. Objects flagged as embedded data... See e.g. the
`(Anim) Hero p23 for 2.blend` file from our cloud gallery
(https://cloud.blender.org/p/gallery/5b642e25bf419c1042056fc6).
Not much to be done, but add another checking pass at the end of
readfile process to fix these.
This adds a new exprimental option to automatically convert GP legacy
data to GPv3 one.
It supports also linking and appending cases. Conversion also happens
when opening a file linking GP legacy data saved by an older .blendfile.
Pull Request: https://projects.blender.org/blender/blender/pulls/118705
Currently the overlay text, like stats for example, are drawing with
the widget_label font style size but using widget's weight. This is
just because UI_fontstyle_set is not called. Without this call we can
get a jiggling of the overlay text if these two styles differ in
weight. This PR also makes an (unnoticeable) correction to the font id
used in fontstyle_set_ex. uiFontStyle's uifont_id is not always the
same id as regular font ids, but here they are confused.
Pull Request: https://projects.blender.org/blender/blender/pulls/119808
Cached strip images were not invalidated, which caused, that these
images were kept in memory in incorrect colorspace.
Code readability was improved a bit and clarifying comments were added
to avoid confusion about what is the code supposed to do.
Pull Request: https://projects.blender.org/blender/blender/pulls/119475
This happened, because function returned early if `Editing` was nullptr.
However it is needed only for timeline boundbox, which is already initialized
for case where there are no strips.
Pull Request: https://projects.blender.org/blender/blender/pulls/118864
- Avoid unnecessary redundancy in function and variable names
- Use more consistent variable names in some places
- Avoid duplicate null checks and incorrect "ensure" naming
- Use const in a few places
- Pass more specific arguments besides just the curves
- Remove unnecessary namespace specification
This report includes a file that demonstrates a crash when ctrl-
clicking the "dot" icon to add to the objects in edit mode. This is
because the object has a mesh shared with another object that is
already in edit mode. This PR allows editing only one object at a
time between objects that share data.
Pull Request: https://projects.blender.org/blender/blender/pulls/119704
Caused by 1cca96067781f569c6bced0c4f363d71781df092.
That commit stated that creating the final subdivided attribute didn't
free the "proc" attribute buffer that contains the data from the Curves
control points. However that wasn't the case, given the call to
`GPU_VERTBUF_DISCARD_SAFE` in that function. That caused a crash when
the overlay engine and EEVEE both wanted to access the VBO and it was
discarded the second time. To fix that, only regenerate the
`proc_attributes_buf` when it doesn't already exist.
This matches the "ensure" behavior that already exists for the
`cache.final[subdiv].attributes_buf` buffer, so conceptually it
seems fine.
Pull Request: https://projects.blender.org/blender/blender/pulls/119795
When creating popover with `UI_popover_begin` the popover block
is created just once without a region and since `UI_popover_begin` blocks
are not support refreshing, layout panels may not be compatible
in this kind of popover since open/close state cannot be refreshed either.
Only `UILayout.popover(...)` popovers are supported to have layout panels.
Pull Request: https://projects.blender.org/blender/blender/pulls/119796
When frame capturing cannot be start an error is printed to the console.
Most of the time the issue is that you're not running from within a frame
capturing environment. For example not from your IDE/GPU debugger.
The print statement is often just not that useful. Especially when
running the `WITH_GPU_DRAW_TESTS` where it floods the console.
Pull Request: https://projects.blender.org/blender/blender/pulls/119783
Replace the use of the `LIB_TAG_DOIT` flag which cwas used to
only process each object data ID once with a Set. Return the objects
or bases in a Vector. Now we only iterate over the view layers bases
once instead of three times.
Pull Request: https://projects.blender.org/blender/blender/pulls/119788
Ensure that subdividing "Bone" results in a chain "Bone", "Bone.001",
"Bone.002", etc.
Before this commit the order would be "Bone", "Bone.004", "Bone.003",
etc.
This might break add-ons that assume to know the bone names before the
actual subdivision happens. This would always have been fragile, as
there may, for example, already have been a "Bone.001"; in that case
subdividing "Bone" would result in "Bone", "Bone.002", etc. Instead, the
parent-child chain should be followed.
Pull Request: https://projects.blender.org/blender/blender/pulls/119775
Fix the name uniqueness check for editbones. The function can receive a
"bone to ignore", which would not be properly ignored. If it was found
earlier in `armature->edbo` than another bone with the same name, the
name would incorrectly be marked as unique.
This issue only occurred when a "bone to ignore" was passed to the
uniqueness check. This never actually happens in the current code, but
that's going to change soon.
This PR extends the existing `Ease` operator with a sharpness property.
This means it has two parameters:
* Curve Bend: Define which key to favor. At 0 it's exactly between the two keys.
* Sharpness: Higher values make the change more abrupt.
During modal operation it is possible to switch the slider between those two by pressing `TAB`.
Pull Request: https://projects.blender.org/blender/blender/pulls/117287
No functional changes intended.
The `insert_keyframe` function had a `bAction` argument that could be
a `nullptr`. If it was a `nullptr` it would be queried from the `ID`.
However in all cases where it is passed it is also gotten from the `ID`, making
the argument redundant.
This PR removes the argument to simplify the function.
Pull Request: https://projects.blender.org/blender/blender/pulls/119742
a958ae36e8 introduced support for UI lists to reference items that would
never be shown, regardless of filter settings. This was to skip assets
in the asset view template that were not of the requested type. UI list
sorting code wasn't updated to account for such items that should be
entirely ignored.
Pull Request: https://projects.blender.org/blender/blender/pulls/109157
When previewing an action in the NLA, the drawing code would
calculate the Keylist for the whole action regardless of what is shown.
This patch limits the keylist creation to only do it for the viewport range
increasing performance in the case when less than the whole action is visible.
whole F-Curve visible
* Before 60ms
* After 60ms
zoomed in
* Before 60ms
* After 1.6ms
Pull Request: https://projects.blender.org/blender/blender/pulls/119470
Use the Graph Editor icon for the "View in Graph Editor" operators,
to make a connection with the entry in the list of editors and the
View menu in the Dope Sheet.
Only use icon on the first item of the section, according to the HIG.
By default a URL would be used for the module name of new remote repos,
the '.' characters were removed, joining words together.
Even though this often isn't user visible, it is used for extension
directory names, command-line access & may show up in error messages.
Replace: `{BLENDER_RESOURCE_PATH_USER}/extensions`
With: `{BLENDER_USER_EXTENSIONS}`
This follows BLENDER_USER_CONFIG & BLENDER_USER_SCRIPTS conventions.
Reading the environment variable and accessible via
`bpy.utils.user_resource('SCRIPTS')`
This was only used on WIN32 when the temporary directory didn't exist.
When the check was added [0] this made some sense because it relied on
`U.tempdir` existing, since then additional checks have been added to
ensure a temporary directory can be used. Further, this fall-back
location isn't documented in the user manual.
[0]: 615db01b01c4ad96d8e712aa5469d9eb3ada0d07
Caused by ddcfc46ee6575bc90846e6e0a76ae72cd7313337.
That commit assumed that the cage mesh always had the deformed
position and normal data. But that isn't true, as shown in the example
in the report. To fix the bug, simplify things, and make the goal clearer,
just copy the struct directly.
Pull Request: https://projects.blender.org/blender/blender/pulls/119755
Caused by 25a10c211fe85e8ed1b5bcd89ccb62de6f73ff9a.
The socket_type field for socket declarations wasn't set for declarations
created from the node group interface DNA tree structure. Arguably the
socket types should be set by the constructors, but setting it in one more
place isn't bad either, and is a simple fix for now.