Commit Graph

65 Commits

Author SHA1 Message Date
Brecht Van Lommel
1f9f1d0b6e Color Management: Improve wide gamut color buttons and pickers
These should at least show the correct colors and gamut now, following the
color picking space in the OpenColorIO config.

However the ACES config use sRGB as the color_picking role, which means
that the color picker only shows a limited a gamut. There is apparently is
not agreement on the interpretation of this role, so we might have to stop
using it.

Additionally, if you set the color_picking role to something like ACEScg +
sRGB transfer function, the widgets do show all the colors in the gamut,
however the gamut is probably too large to be practical for most uses. So
we need some UI solution for this regardless.

Ref #144911

Pull Request: https://projects.blender.org/blender/blender/pulls/144565
2025-08-21 15:25:15 +02:00
Clément Foucault
9fbf7e9ec2 GPU: Remove wrapper type for gpu::UniformBuf
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144328
2025-08-11 09:46:45 +02:00
Philipp Oeser
c466d1744b Fix #143231: Vulkan Renders Curve Profile Control Points Incorrectly
Resolve using a shader intended for drawing points.

Pull Request: https://projects.blender.org/blender/blender/pulls/143798
2025-08-07 09:05:16 +02:00
Campbell Barton
e8f9e2d1d1 Cleanup: use UTF8 string functions in editors & related logic
Use UTF8 aware functions unless raw bytes are expected.
2025-07-27 16:41:19 +10:00
Aras Pranckevicius
ea9b520a39 Fix: assert in image Luma vectorscope
Commit 9e221a10d3 made it so that IMM shader is unbound
while drawing a scope, and added assert to ensure it is unbound.
But it missed one place where waveform_draw_one is used, and did
not unbind the IMM shader around that.
2025-07-24 10:43:25 +03:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
Guillermo Venegas
091db9d52b Cleanup: UI: Use UI_interface_layout.hh instead of UI_interface.hh
This removes the include `UI_interface_layout.hh` from
`UI_interface_c.hh`, and in many places this swaps the include
from `UI_interface.hh` to `UI_interface_layout.hh`.

Also, cleanups some `UI_interface.hh` includes with
`UI_interface_icons.hh` or `UI_interface_types.hh`
2025-06-20 18:07:47 +02:00
Clément Foucault
db79a2e737 Fix: GPU: Wrong attribute types for UNORM 8bit attributes
This was a mistake inside e57359726f.
Simply replacing SNORM_8 by UNORM_8 fixes the issue.
2025-06-11 14:21:38 +02:00
Clément Foucault
e57359726f GPU: VertexFormat: Use new data types
This prevents the use of unaligned data types in
vertex formats. These formats are not supported on many
platform.

This simplify the `GPUVertexFormat` class a lot as
we do not need packing shenanigans anymore and just
compute the vertex stride.

The old enums are kept for progressive porting of the
backends and user code.

This will break compatibility with python addons.

TODO:
- [x] Deprecation warning for PyGPU (4.5)
  - [x] Deprecate matrix attributes
- [x] Error handling for PyGPU (5.0)
- [x] Backends
  - [x] Metal
  - [x] OpenGL
  - [x] Vulkan

Pull Request: https://projects.blender.org/blender/blender/pulls/138846
2025-06-10 17:20:45 +02:00
Jeroen Bakker
9e221a10d3 Fix #139901: UI: Incorrect flow when drawing scopes
When drawing image scope the vulkan backend raised some asserts. After
checking them the issue was in the calling code, that could lead to
undefined behavior on other platforms as well.

It isn't allowed to have an immediate mode shader bound, when performing
batch drawing. There was also a point batch that didn't use any point
shader resulting in undefined behavior as well.

For 5.0 we should add this as a GPU module check.

Pull Request: https://projects.blender.org/blender/blender/pulls/139926
2025-06-06 14:01:02 +02:00
Hans Goudey
153abc372e GPU: Replace U32/I32 combination with GPU_FETCH_INT_TO_FLOAT in UI code
The conversion from int to float is not supported natively
so it ends up happening beforehand on the CPU or as a
step before the vertex buffer can be used. It's better to just
upload floats in the first place.

Related to:
- 1e1ac2bb9b
- 617858e453

Pull Request: https://projects.blender.org/blender/blender/pulls/138855
2025-05-14 15:15:21 +02:00
Clément Foucault
617858e453 GPU: Unified DataFormat enum
This unifies vertex and texture data formats
into a single base enum class.

`TextureFormat` and `VertexFormat` then mask
the invalid format for their respective usage.

Having a base enum allows casting between
`TextureFormat` and `VertexFormat` possible
(needed for Buffer Textures).

It also makes it easier to write and read data
to buffers/textures as each format will have an
associated host type.

These enum is generated from MACRO expansion.
This allow to centralize all information about
the formats in one place. This avoid duplicating
the list of enums for each backend.

This only creates the new enum. Porting older enums will
be done in other PRs.

Normalized integer CPU format are missing and waiting for #130640

Rel #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/138069
2025-05-13 17:08:32 +02:00
Campbell Barton
9deea7677f Cleanup: use doxygen doc-strings, correct file references in UI headers
Also move implementation note from doc-string into the body of the
function.
2025-05-13 11:14:27 +10:00
Clément Foucault
91dcea8efc Fix: UI: Invalid scissors in interface drawing
These were causing asserts on Metal.

Pull Request: https://projects.blender.org/blender/blender/pulls/138684
2025-05-12 17:49:16 +02:00
Sergey Sharybin
7ceb4495c5 Refactor: OpenColorIO integration
Briefly about this change:
- OpenColorIO C-API is removed.
- The information about color spaces in ImBuf module is removed.
  It was stored in global ListBase in colormanagement.cc.
- Both OpenColorIO and fallback implementation supports GPU drawing.
- Fallback implementation supports white point, RGB curves, etc.
- Removed check for support of GPU drawing in IMB.

Historically it was implemented in a separate library with C-API, this
is because way back C++ code needed to stay in intern. This causes all
sort of overheads, and even calls that are strictly considered bad
level.

This change moves OpenColorIO integration into a module within imbuf,
next to movie, and next to IMB_colormanagement which is the main user
of it. This allows to avoid copy of color spaces, displays, views etc
in the ImBuf: they were used to help quickly querying information to
be shown on the interface. With this change it can be stored in the
same data structures as what is used by the OpenColorIO integration.
While it might not be fully avoiding duplication it is now less, and
there is no need in the user code to maintain the copies.

In a lot of cases this change also avoids allocations done per access
to the OpenColorIO. For example, it is not needed anymore to allocate
image descriptor in a heap.

The bigger user-visible change is that the fallback implementation now
supports GLSL drawing, with the whole list of supported features, such
as curve mapping and white point. This should help simplifying code
which relies on color space conversion on GPU: there is no need to
figure out fallback solution in such cases. The only case when drawing
will not work is when there is some actual bug, or driver issue, and
shader has failed to compile.

The change avoids having an opaque type for color space, and instead
uses forward declaration. It is a bit verbose on declaration, but helps
avoiding unsafe type-casts. There are ways to solve this in the future,
like having a header for forward declaration, or to flatten the name
space a bit.

There should be no user-level changes under normal operation.
When building without OpenColorIO or the configuration has a typo or
is missing a fuller set of color management tools is applies (such as the
white point correction).

Pull Request: https://projects.blender.org/blender/blender/pulls/138433
2025-05-09 14:01:43 +02:00
Aras Pranckevicius
cc2c6692c0 Cleanup: Name more IMB things as "byte" or "float" instead of "rect" and "rectFloat"
- IB_rect -> IB_byte_data
- IB_rectfloat -> IB_float_data
- Rename some functions:
	- IMB_get_rect_len -> IMB_get_pixel_count
	- IMB_rect_from_float -> IMB_byte_from_float
	- IMB_float_from_rect_ex -> IMB_float_from_byte_ex
	- IMB_float_from_rect -> IMB_float_from_byte
	- imb_addrectImBuf -> IMB_alloc_byte_pixels
	- imb_freerectImBuf -> IMB_free_byte_pixels
	- imb_addrectfloatImBuf -> IMB_alloc_float_pixels
	- imb_freerectfloatImBuf -> IMB_free_float_pixels
	- imb_freemipmapImBuf -> IMB_free_mipmaps
	- imb_freerectImbuf_all -> IMB_free_all_data
- Remove IB_multiview (not used at all)
- Remove obsolete "module" comments in public IMB headers

Pull Request: https://projects.blender.org/blender/blender/pulls/135348
2025-03-03 17:11:45 +01:00
Campbell Barton
df3d1bf506 Cleanup: use const arguments & variables where appropriate 2025-02-05 14:38:56 +11:00
Brecht Van Lommel
3725fad82f Cleanup: Various clang-tidy warnings in editors
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Aras Pranckevicius
4275d85158 Fix #133214: image vectorscope has incorrect horizontal scale
Both Image and Sequencer vectorscopes used YUV U,V coordinates
as-is, but their possible ranges are different: +-0.436 and
+-0.615 respectively.

It looks like more other software (ffmpeg, shotcut, etc.)
re-scales the vectorscope UV to fill up a square, i.e. streches
out the horizontal values, so do the same.

This fixes the "skin tone indicator" line, which at 123 degrees
(90 + 33 degrees to match positive I axis of YIQ color space) was
placed assuming the UV values fill up a square. So it was at the
wrong angle before.

The vectorscope horizontal scaling and skin tone indicator line now
matches other open source (ffmpeg, shotcut) and commercial (davinci
resolve, final cut pro) software packages.

Images in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/133316
2025-01-21 13:55:15 +01:00
Jeroen Bakker
74cb86aba4 Vulkan: Fix point shader mismatch in wavevform_draw_one
Pull Request: https://projects.blender.org/blender/blender/pulls/129061
2024-10-15 16:13:40 +02:00
Campbell Barton
40f96afa61 Cleanup: various non-functional changes
- Use const arguments.
- Remove redundant cast.
- Use ELEM macro.
- Use boolean & nullptr literals.
2024-08-26 11:50:12 +10:00
Campbell Barton
74f240c3ce Cleanup: move assignment to outer loop 2024-08-26 11:43:37 +10:00
Aras Pranckevicius
6d93bf6b44 IMB: Speedups, fixes and cleanups to various image scaling functions
API: merged IMB_scalefastImBuf, IMB_scaleImBuf, IMB_scaleImBuf_threaded
into one function IMB_scale with enum IMBScaleFilter {Nearest, Bilinear, Box}
and bool "threaded" param.

Performance:
- Box filtering (nee IMB_scaleImBuf) can be multi-threaded now.
- Nearest filtering (nee IMB_scalefastImBuf) can be multi-threaded now.
  Also fix performance regression on float images caused by fix in #126234
- Bilinear filtering (nee IMB_scaleImBuf_threaded) is several times faster now.

Correctness:
- Nearest and Box filtering: no longer loses half of edge pixels when scaling
  up.
- Box: fixed garbage results (and possible out of bounds reads) for non-4
  channel float images.
- Bilinear: no longer shifts image when scaling up.
- Bilinear: properly filters when scaling down by 2x2.

Test coverage:
- Add gtest coverage for various IMB_scale modes.
- Add a IMB_performance_test performance test, ran manually.

More details, images and performance numbers in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/126390
2024-08-19 16:50:05 +02:00
Harley Acheson
885824540a UI: Increase Size of Curve Control Points
Curve control points are shown quite small regardless of UI scale and
local zooming. This PR increases the minimum, regular, and maximum
sizes so that they are easier to see in all circumstances.

Pull Request: https://projects.blender.org/blender/blender/pulls/125786
2024-08-01 20:51:42 +02:00
Harley Acheson
90e7331d10 Fix #125558: Show UI_BTYPE_CURVE Control Points
The curve control points are almost invisible because it is missing a
call to GPU_program_point_size, which allows the setting of dot size
in the shader.

Pull Request: https://projects.blender.org/blender/blender/pulls/125744
2024-08-01 19:56:32 +02:00
Jeroen Bakker
459b4c7f00 Vulkan: Fix Point rendering in UI (Curves)
`ui_draw_but_CURVE` used a flat color shader to draw points. This
isn't valid as that shader doesn't support point rendering.

This is fixed to replace the `GPU_SHADER_3D_FLAT_COLOR` with
`GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR`.

Regression found when loading `monster.blend` using Vulkan. This
scene has the color management tab open with a custom curve.

Pull Request: https://projects.blender.org/blender/blender/pulls/124025
2024-07-02 09:43:57 +02:00
Hans Goudey
79416a8b96 Refactor: GPU: Simplify access to vertex buffer data
Add a `.data<T>()` method that retrieves a mutable span. This is useful
more and more as we change to filling in vertex buffer data arrays
directly, and compared to raw pointers it's safer too because of asserts
in debug builds.

Pull Request: https://projects.blender.org/blender/blender/pulls/123338
2024-06-18 21:10:45 +02:00
Hans Goudey
84c4ddbbb9 Cleanup: GPU: Use references for some vertex buffer functions
Pull Request: https://projects.blender.org/blender/blender/pulls/122784
2024-06-05 18:47:22 +02:00
Aras Pranckevicius
689fce50bd Fix #120789: Slowness when using image vectorscope opacity slider
Since image vectorscope RGB mode addition (567455124d), changing
the opacity was causing the scope to get recalculated from scratch,
because opacity value was put into vecscope_rgb data directly.

Instead of that, make vecscope_rgb data only contain RGB, and fill in
the GPU vertex buffer alpha values when creating the GPU batch.

Now tweaking the scope opacity slider feels at about the same
performance as in 4.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/120854
2024-04-20 17:08:56 +02:00
Campbell Barton
686605a6dd Cleanup: declare arrays as const where possible 2024-03-28 22:57:57 +11:00
Campbell Barton
b2e00d1285 Cleanup: use const pointer arguments 2024-03-28 20:57:50 +11:00
Hans Goudey
893130e6fe Refactor: Remove unnecessary C wrapper for GPUBatch class
Similar to fe76d8c946

Pull Request: https://projects.blender.org/blender/blender/pulls/119898
2024-03-26 03:06:25 +01:00
Hans Goudey
fe76d8c946 Refactor: Remove unnecessary C wrappers for vertex and index buffers
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
2024-03-24 16:38:30 +01:00
Hans Goudey
8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Campbell Barton
b372ebae68 Cleanup: unused headers for source/blender/editors
Remove 1317 includes from editors.
2024-02-13 10:02:53 +11:00
Aras Pranckevicius
9958cbf614 Fix: UI: fix off by one error in new image vectorscope code
New code in 567455124d was reading one vertex too many while
drawing the colored vectorscope background
2024-02-06 13:55:11 +02:00
Campbell Barton
6154e511ab Cleanup: quiet missing-declarations & unused variable warnings 2024-02-06 22:28:10 +11:00
JonasDichelle
567455124d UI: Image Editor Vectorscope Improvement
Update the look of image editor Vectorscope widget (design #116973):
- Colored and Luma options for the point cloud,
- The circles are no longer very low poly,
- Overall grid/background colors are tuned.
- Primary color locations have text labels.

Images in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/116974
2024-02-06 12:22:48 +01:00
Hans Goudey
7fa5fc02b7 Cleanup: Move BLF headers to C++ 2024-01-31 14:04:56 -05:00
Aras Pranckevicius
a705259b4b Cleanup: move imbuf .h files to .hh 2024-01-19 20:29:38 +01:00
Aras Pranckevicius
fec8461365 Cleanup: move BKE_colorband.h and BKE_colorcools.h to .hh
Also remove includes of those where not needed

Pull Request: https://projects.blender.org/blender/blender/pulls/116416
2023-12-21 10:10:53 +01:00
Leon Schittek
0335b6a3b7 UI: Improve menu dropshadow
Improvements to the drawing of shadows, used with blocks, menus, nodes,
etc. Improvements to shape, especially at the top corner or at extremes
of widget roundness. Allows transparent objects to have shadows. This
is a nice refactor that removes a lot of code.

Pull Request: https://projects.blender.org/blender/blender/pulls/111794
2023-11-24 22:50: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
e7e4e63313 Cleanup: spelling in comments, white-space in comments 2023-10-19 18:53:16 +11:00
Julian Eisel
73460903fa Asset Shelf: Transparent asset shelf header with background for buttons
Draw the background of the asset shelf header fully transparent, with an opaque
background with rounded corners behind sections containing buttons. This
reduces the visual space consumed by the asset shelf, and makes the header
follow a tabbed folder metaphor better. Also, this works much better with our
click-through feature, where transparent parts of regions without buttons are
passed through the region under it (we might want to consider unifying code
here a bit).

The edge to drag for region resizing respects the transparent sections.
When there is little space between sections, the sections get merged so that
there are no small gaps in the bar.

Part of #107881.

----

Note that the core of this is implemented in a generic way, so this can be
reused for other regions.

Pull Request: https://projects.blender.org/blender/blender/pulls/112241
2023-09-26 17:12:37 +02:00
Campbell Barton
1f01a64403 Cleanup: spelling in comments 2023-09-06 14:23:01 +10:00
Harley Acheson
8a3766e241 Fix #111017: Improvements to the drawing of Color Ramps
Color Ramp widget with themed outline, handling of line width changes,
padding fixes, scaling fixes, etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/111903
2023-09-06 00:00:40 +02:00
Aras Pranckevicius
d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Hans Goudey
ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00