Commit Graph

2150 Commits

Author SHA1 Message Date
Jason Fielder 18f7d158fe GPU: cleanup texture view usage flags
Texture usage flag `GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW`
was originally implemented and used too conservatively for many
cases in which the underlying API flags were not required.

Renaming to `GPU_TEXTURE_USAGE_FORMAT_VIEW` to reflect
the only essential use case for when a texture view is initialized with
a different texture format to the source texture. Texture views can
still be created without this flag when mip range or base level is
adjusted,

This flag is still required by stencil views and internally by the Metal
backend for certain feature support such as SRGB render toggling.

Patch also includes some small changes to the Metal backend to
adapt to this new compatibility and correctly capture all texture view
use-cases.

Related to #115269

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/115300
2023-11-24 15:21:00 +01:00
Hans Goudey 3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Campbell Barton 3841addab3 Cleanup: spelling in comments 2023-11-10 09:24:19 +11:00
Jeroen Bakker 59a21a63bb Cleanup: Remove unused r_data_format parameter
The r_data_format parameter from imb_gpu_get_format is always ignored
or overwritten by the r_data_format parameter from imb_gpu_get_data.

It makes more sense to just use the result from the imb_gpu_get_data
function for to determine the data format.

Pull Request: https://projects.blender.org/blender/blender/pulls/114662
2023-11-09 11:21:56 +01:00
Jeroen Bakker 7e95bfbba8 Merge branch 'blender-v4.0-release' 2023-11-09 11:05:48 +01:00
Jason Fielder ed540b4d3a Fix #114414: Alternative fix for greyscale textures retaining perf
Alternative solution to #114414 which reduces the scope of
textures for which single-channel greyscale optimization
is removed from.

Some byte buffers are converted to float buffers during
color management. These cases should retain support in
the optimal path.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/114611
2023-11-09 11:02:20 +01:00
Jeroen Bakker b56382b38a Cleanup: Make format 2023-11-07 08:04:17 +01:00
Campbell Barton 611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Campbell Barton aaf05c2497 Cleanup: various C++ changes (use nullptr, function style casts) 2023-11-07 11:35:16 +11:00
Philipp Oeser 16dd73b895 Merge branch 'blender-v4.0-release' 2023-11-03 15:11:09 +01:00
Jeroen Bakker 2193bd4b89 Fix #114414: Drawing Artifacts Grayscale Byte Images
Single channel JPEG files are stored in 4 channels image buffers, with their
bit planes set to 8.

When creating the GPU texture the number of bit planes is used to identify
if the data could be stored as a single channel texture, but in this case
the source data contains 4 channels and doesn't align with the GPU
texture format.

In Blender 3.6 the way how bit planes were stored changed (the planes
used to be 32 for the grayscale byte images matching the number of channels,
but now is set to 8, matching the original loaded image).

Since Blender 3.5 the grayscale byte images are uploaded using a single channel
GPU format, which leads to the mentioned artifacts. Grayscale byte buffers never
seems to have worked since its introduction in
https://archive.blender.org/developer/D15484

This PR disables using the grayscale GPU textures when it sourced from
a byte image.

Pull Request: https://projects.blender.org/blender/blender/pulls/114441
2023-11-03 13:54:05 +01:00
Jeroen Bakker 747ec05f69 Cleanup: Make format 2023-11-03 12:00:38 +01:00
Bastien Montagne d1e732a114 FFMPEG: Cleanup: Remove storage of last FFMPEG frame read as `ImBuf` in anim data.
The `anim` data (e.g. of a VSE sequence) would store the last frame read from
FFMPEG as an image buffer, increasing its refcounting and preventing it
to be freed until the whole `anim` data itself gets freed.

In current code, there is no reason to keep a reference to this image
buffer in the `anim` data, so removing it. This may also give a few
percent improvement on the memory usage of the VSE in some cases.

Found while investigating #114342.

Pull Request: https://projects.blender.org/blender/blender/pulls/114395
2023-11-03 11:18:21 +01:00
Richard Antalik 4d37fb80b1 Cleanup: Convert VSE headers from .h to .hh 2023-11-03 01:33:54 +01:00
Omar Emara b54a26ede4 IMB: Support rgba and V channels in single-layer EXR
Currently, the EXR reader only considers uppercase RGBA channel names in
single-layer EXRs, which leaves out the lower case rgba channel names we
started using for data and vector passes in Cycles and the compositor.
Further, a single V channel was also ignored, which is by convention
used for BW passes.

This patch extends the single-layer channel recognition methods to
include lowercase rgba and V channels.

Pull Request: https://projects.blender.org/blender/blender/pulls/114339
2023-11-02 11:08:35 +01:00
Brecht Van Lommel 39107b3133 Revert changes from main commits that were merged into blender-v4.0-release
The last good commit was 8474716abb.

After this commits from main were pushed to blender-v4.0-release. These are
being reverted.

Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
2023-10-30 21:40:35 +01:00
Campbell Barton d31c61edee Cleanup: spelling in comments 2023-10-27 12:13:48 +11:00
Jesse Yurkovich 125776e660 Merge branch 'blender-v4.0-release' 2023-10-23 21:51:27 -07:00
Jesse Yurkovich 10eb1ac8e4 Fix #111442: Correctly handle 1-channel image formats during save
It's possible to encounter a true 1-channel image if it's coming
directly from, say, a float-value AOV or similar.

This was not accounted for and would cause issues when saving the image
out to a 3 or 4 channel format (wrong values) or when saving out to
another 1 channel format (unnecessary usage of luminance weight values).

Pull Request: https://projects.blender.org/blender/blender/pulls/111577
2023-10-24 06:50:13 +02:00
Sergey Sharybin 21c8af467d Cleanup: Convert winfunc and utfconv to C++
Basically, the intern/utfconv directory, as well as users of
these headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/113901
2023-10-20 10:27:31 +02:00
Sergey Sharybin 85c557ffa2 Cleanup: Rename BLI_string_utils.h to BLI_string_utils.hh
All users of it are now C++, which opens doors to add C++ to the
public API.
2023-10-20 10:27:26 +02:00
Campbell Barton c0333b811e Merge branch 'blender-v4.0-release' 2023-10-13 10:57:20 +11:00
Campbell Barton aebb32748e Fix UB issue calculating the frame duration for images with FFMPEG
AVFormatContext::duration was used without checking it was set,
calculations for the frame-rate cast -INT64_MAX to a double,
scaled it then cast to an integer - overflowing.
On my system the result was a negative number so the duration was never
usable in practice.

Add an explicit check for this so the duration is left at zero instead.
2023-10-13 10:55:47 +11:00
Brecht Van Lommel 46d32d8966 Merge branch 'blender-v4.0-release' into main 2023-10-10 15:36:39 +02:00
Brecht Van Lommel 478e1ab6d3 Fix build error on Windows after BLI_read changes
Don't use posix-only ssize_t in platform independent code.

Pull Request: https://projects.blender.org/blender/blender/pulls/113493
2023-10-10 15:36:15 +02:00
Campbell Barton 57fc3d48b8 Merge branch 'blender-v4.0-release' 2023-10-10 22:49:58 +11:00
Campbell Barton 8d80d611e9 Use BLI_read instead of read to avoid issues with large files
Follow up to fix for #113473, similar issues exist elsewhere.
2023-10-10 22:47:35 +11:00
Campbell Barton 4afd8ef9a4 Cleanup: add BLI_mmap_get_length, remove duplicate file size access
Remove unnecessary calls to BLI_file_descriptor_size when using
BLI_mmap_open since this stores the file size too.

While accessing the size twice isn't so bad, the additional check
that the file size isn't an error value is unnecessarily verbose.
2023-10-10 15:43:13 +11:00
Campbell Barton ae6b1ead4c Fix failure to check the error value for file-size access
Accessing the file size returns -1 on error, for file packing this
was passed directly to an allocation which would wrap around to
SIZE_T_MAX and fail to allocate. In other cases zero was treated
as an error value but -1 wasn't.

Add checks for the error return value, also warn that packing files over
2gb isn't supported.
2023-10-10 14:56:30 +11:00
Campbell Barton cb51cc7ce8 Fix OpenEXR leak, failure to close a file when BLI_mmap_open fails 2023-10-10 14:16:04 +11:00
Campbell Barton e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Brecht Van Lommel 70ac1e5df1 Fix #112645: switching view transform unnecessarily resets look
AgX and Filmic have different looks in the configuration, but the looks
share the same UI name and purpose. So we can switch to the
corresponding look when switching view transforms.

Thanks to Yiming Wu for helping track down the problem.

Pull Request: https://projects.blender.org/blender/blender/pulls/112686
2023-09-22 12:05:55 +02:00
Campbell Barton 5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10:00
Campbell Barton e3b77cf08a ImBuf: calculate the JPEG DPI with double precision
These were calculated as floats then converted to doubles,
loosing precision unnecessarily.
2023-09-20 12:12:49 +10:00
Campbell Barton bdbf1871ec ImBuf: don't include null bytes for jpeg meta-data markers
JPEG strings aren't null terminated, there is no need to include the
null byte. For reference ImageMagick doesn't do this.
2023-09-20 12:12:40 +10:00
Campbell Barton a0aed358fa BLI_string: assert the len argument to BLI_strdupn is valid
Ensure the string isn't null terminated before len, if this happens
it's likely an error calculating the length argument. Since the length
is passed to memcpy it could result in reading outside `str` bounds.

There was one case where the string was duplicated then grew by 1 byte
afterwards. Replace this with an allocation since it's an uncommon
operation, not especially useful to support.
2023-09-20 12:11:34 +10:00
Campbell Barton 085b094f18 Cleanup: use const arguments & variables 2023-09-19 11:09:20 +10:00
Julian Eisel 3589533908 Thumbnails: Always use cached thumbnails for offline files
bd9f94e917 made it so the file browser doesn't bring files online for
the purpuse of creating their thumbnail, because that can take a while.
Instead it uses a previously cached thumbnail if available. This should
be the behavior for all cases thumbnails are requested, it's not only
the file browser that does this.

In fact it makes sense to move this into the normal function to "manage"
thumbnails (that is, load and if necessary (re)create cached
thumbnails) since there are no currently known use-cases for
different behavior.

Also, seems like the previous solution didn't work when loading ID
previews from offline .blend files. For that we need to use the path to
the .blend file to check the offline status, not the full path to the ID.

Found while working on #109234 (Use UI preview system for async loading of
file/asset previews).

Pull Request: https://projects.blender.org/blender/blender/pulls/112101
2023-09-08 16:41:44 +02:00
Julian Eisel 1b2e29e692 Cleanup: Clarify path variable name in thumbnail create function
"filepath" was misleading since this path could also point into a .blend
file. Further, the convention was to use "filepath" for such files, and
"file_path" for when only an actual file path was expected. This is
highly confusing and non-obvious. Plus a (newer?) function broke with
the convention.

Just be explicit about the type of path, even if a bit verbose. It's
good to always have the reminder that this may be more than just a file
path when passing it around.
2023-09-06 18:46:29 +02:00
Julian Eisel a24fa35120 Cleanup: Avoid redundant/confusing variable in thubnail create function
This confused me plenty of times. If there are two local variables I
assume they contain different things. In fact these two were equal
throughout the function.
2023-09-06 17:41:44 +02:00
Julian Eisel 1ee584c137 Cleanup: Add comments to thumbnail creation function
The function is quite confusing, this should clarify things a bit.
2023-09-06 16:58:07 +02:00
Julian Eisel 6659579abc Cleanup: Move variable declarations close to usage in thumbnail function
This function is rather big and it's not clear what state variables are
in without a bunch of scrolling around. Plus, having the declarations
close to the function calls that set them makes it more clear that these
functions use the variables as output parameters. So this change should
help understanding the function flow.
2023-09-06 16:56:30 +02:00
Julian Eisel ba03948dd2 Cleanup: Move BKE preview image code to separate file
Previously, BKE level preview image code was in `BKE_icons.h` and `icons.hh`.
While these types are related, I always found this quite hard to navigate since
preview image stuff was just in the middle of icon functions. Plus, people
don't expect preview image functions in icon files, the relationship is not
obvious.

Instead, use focused files that make it easy to quickly navigate them
and see what they are dealing with.

Pull Request: https://projects.blender.org/blender/blender/pulls/111709
2023-09-04 18:02:16 +02:00
Hans Goudey 3db523ab3e Cleanup: Move BLO headers to C++
Except for BLO_readfile.h, which is still included by C files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111610
2023-08-28 15:01:05 +02:00
Campbell Barton f66fa32ada Cleanup: spelling in comments 2023-08-23 13:30:55 +10:00
Campbell Barton 5a8cb665e0 Cleanup: various non-functional C++ changes 2023-08-19 23:52:47 +10:00
Sergey Sharybin d0dcfb8159 Color management: Tweak compatible look check
Change compatible look check so that if the view contains
explicitly configured looks the non-explicit looks are not
added to the list.

In practice this means that if there are looks "Low Contrast"
and "AgX - Low Contrast" only the latter one is considered to
be compatible with the "AgX" view.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/111229
2023-08-17 15:40:34 +02:00
Sergey Sharybin 77f6c83bd5 Fix compilation error after recent commits to color management
Individually patches were fine, but they got some conflict
when both are applied.

Pull Request: https://projects.blender.org/blender/blender/pulls/111228
2023-08-17 14:47:49 +02:00
Sergey Sharybin 16c44700e9 Color management: Validate look is compatible with view on load
While currently the only way to reproduce the issue is to modify
the default OCIO configuration, change the view (which does yet
validate look on change) and save-reload, it seems to be a good
thing to validate anyway, to be more future-proof.

Pull Request: https://projects.blender.org/blender/blender/pulls/111209
2023-08-17 14:38:52 +02:00
Sergey Sharybin 241fac09dd Color management: Validate Look on View Transform changes
If the new view transform does not support the currently configured
look reset look to the default None, similar to the color management
verification on .blend file open.

Currently it is not a problem as all views support the same set of
looks. But with an upcoming addition of AgX it will no longer be
true.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/111185
2023-08-17 14:38:07 +02:00