Commit Graph

6211 Commits

Author SHA1 Message Date
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
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/142732
2025-07-22 09:48:10 +02:00
Campbell Barton
996210999b Cleanup: use C style comments for descriptive text, doxygen doc-strings
Also replace add-hoc groups in BKE_collision.h with doxy groups.
2025-07-22 11:59:43 +10:00
Campbell Barton
81e4558ab6 Cleanup: reduce right-shift in Python scripts 2025-07-22 11:59:43 +10:00
Miguel Pozo
a8975bf651 Fix #142097: Vulkan: Crash with unbound textures
On the Vulkan side, ensure that unbound textures don't result in
accessing uninitialized or out of bounds memory.
On the Draw side, ensure all Hair and Curves attributes have, at least,
a dummy attribute bound.

Pull Request: https://projects.blender.org/blender/blender/pulls/142265
2025-07-21 15:14:10 +02:00
илья _
3e8250e60c GPU: Do not fill index buffer object with zero on allocation
There is no need to initialize index buffers with zero since such
buffers always have to be filled by the caller. This change replaces
the allocation with malloc, so that GPU_indexbuf_init results in an
uninitialized buffer. In debug, and with asan, the buffer will be still
filled by something, but the caller should initialize zero indices
manually instead of relying on a default value.

For example, sometimes the cost of zeroing on allocation is similar to
the cost of filling the buffer with actual data. For a point cloud with
1'000'000 points, octahedron topology update on each frame of simulation
takes:

|                            | Main    | PR      |
| -------------------------- | ------- | ------- |
| GPU_indexbuf_init          | 2.75 ms | 5233 ns |
| pointcloud_extract_indices | 6.95 ms | 4.64 ms |

Pull Request: https://projects.blender.org/blender/blender/pulls/141110
2025-07-18 21:22:18 +02:00
YimingWu
37df7ea850 Fix #137429: GPU: Allow missing attribute in pygpu_shader_attrs_info_get
In `pygpu_shader_attrs_info_get`, it tries to check information for all
vertex attributes that are added via `VERTEX_IN`, however some drivers
will optimize compiled shaders so some vertex attributes that are not
used will be removed. This fix makes sure that the input length that
is used in `GPU_shader_get_attribute_len` does not exceed actual max
binding number.

Pull Request: https://projects.blender.org/blender/blender/pulls/137584
2025-07-17 15:54:12 +02:00
Clément Foucault
ec9bef6425 Fix: GPU: Build issue caused by missing directories
When running `make` it can happen that the target directory
was not created before the invocation of `glsl_preprocess`.

This patch copies #141404 and creates the output directory
before creating the output files.
2025-07-16 14:51:33 +02:00
John Kiril Swenson
d910fb88b0 VSE: Clamp strip handles to video/audio bounds
This initial commit properly clamps handles for video/audio strips, and
provides functionality to enable/disable the behavior for all strip types
(addresses #90280).

Toggling handle clamping is done with "C",
just like with the redesigned slip operator (#137072).

If a strip is not already clamped when you start moving its handles,
then clamping behavior is disabled starting out. This means no abrupt
clamp until you explicitly ask for it.

Transform logic was altered, fixing a few bugs:
- When initializing a transform, `createTransSeqData` would already
  create some clamping data for channels. This patch replaces it with
  `offset_clamp` (for unconditional clamping which cannot be disabled)
  and `handle_xmin/xmax` (for hold offset clamping, which is optional).
    - Collecting this data ahead of time is necessary for the double
      handle tweak case -- `flushTransSeq` only works one strip at a
      time, so we can't clamp post-hoc.
- In `applySeqSlideValue`, we apply `transform_convert_sequencer_clamp`
  before values are printed to the header, but let the unclamped values
  get flushed to the strips themselves. This is so that we can have the
  data later at the individual strip level to recalculate clamps.
  Otherwise, if transform values are clamped preemptively, then we have
  no idea whether strips are clamped vs. merely resting at their
  boundaries.

Note that currently, handle clamping is drawn identically to overlaps.

More information in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/134319
2025-07-16 06:16:19 +02:00
Clément Foucault
4ebaee0aa1 Fix #106312: Workbench: Texture interpolation is shared across material
This was caused by the Material Sub pass being
shared for all materials using a same texture.
This patch simply adds the sampler state inside the
Map key. This will create one unique subpass for each
texture and for each sampler state.

Pull Request: https://projects.blender.org/blender/blender/pulls/141978
2025-07-15 22:47:17 +02:00
Miguel Pozo
05dcc0377b Fix: GPU: Missing error logs
Regression from d5f84d0016.
2025-07-14 18:53:35 +02:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Brecht Van Lommel
b0d7e6d15f Fix: EEVEE glass BSDF broken after recent thin film addition
Caused by cf92af3ac4.
2025-07-10 16:55:06 +02:00
Brecht Van Lommel
d7cc940825 Logging: Log GHOST backend, GPU backend and GPU device
Important information that could not be found directly in the logs yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Miguel Pozo
f46aa9a1ea Core: Add BLI_thread_queue priority and cancel support
Add functionality required for using BLI_thread_queue for shader compilation, as
discussed in #140214.

Pull Request: https://projects.blender.org/blender/blender/pulls/140992
2025-07-09 18:04:51 +02:00
Jeroen Bakker
4d9c5ebd97 Vulkan: Move Wayland/HDR support out of experimental
This PR moves Wayland/HDR support out of experimental.
This allows more people to test and provide feedback. We
can always decide later to disable it for the release, but so
far we only got positive feedback.

Pull Request: https://projects.blender.org/blender/blender/pulls/141666
2025-07-09 13:24:31 +02:00
Jeroen Bakker
807931166a Merge branch 'blender-v4.5-release' 2025-07-09 08:59:36 +02:00
Jeroen Bakker
2170739ba3 Fix #141628: Vulkan: Crash when index buffer could not be allocated
Added an early exit when the index buffer could not be allocated. Most
likely when there is an out of memory issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/141653
2025-07-09 08:57:57 +02:00
Campbell Barton
1eb9933e5e Merge branch 'blender-v4.5-release' 2025-07-08 22:20:25 +10:00
Jeroen Bakker
402cf10760 Fix #141476: Vulkan: Disable descriptor buffer on Windows/Intel
Windows/Intel GPU crashes when descriptor buffer cannot be allocated
anymore. This PR enables a workaround by not using descriptor buffers.

In future we should investigate how to improve the GC of descriptor
buffers and review the limits.

Pull Request: https://projects.blender.org/blender/blender/pulls/141600
2025-07-08 14:02:51 +02:00
Omar Emara
3fcf4b4763 Merge branch 'blender-v4.5-release' 2025-07-08 08:59:03 +03:00
Omar Emara
1c98f29ed3 Fix: Wrong GL data format for RG integer textures
The GPU_RG16I format was assigned a wrong GL data format, which is
probably a typo.

Pull Request: https://projects.blender.org/blender/blender/pulls/141409
2025-07-08 07:57:33 +02:00
Campbell Barton
09260bf6c0 Merge branch 'blender-v4.5-release' 2025-07-08 15:38:58 +10:00
Campbell Barton
20ee5c2283 Fix buffer overflow reading the selection buffer
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.
2025-07-08 15:38:18 +10:00
Germano Cavalcante
289adf8616 Merge branch 'blender-v4.5-release' 2025-07-07 11:56:35 -03:00
Jeroen Bakker
b4e8ee02cc Fix #141238: Vulkan: Crash during upload huge geometry
In case Blender was able to allocate a vertex buffer for huge geometry,
but isn't able to allocate its staging buffer it would crash. In this
case errors will be reported in the console.

This PR fixes this by clearing the data in stead of uploading.

Pull Request: https://projects.blender.org/blender/blender/pulls/141553
2025-07-07 15:33:42 +02:00
Campbell Barton
0ceedc2a7d Cleanup: various non-functional changes in C++ 2025-07-05 09:03:09 +10:00
Clément Foucault
644fb2b679 Fix #98654: GPUOffScreen example has wrong color management
This was because the display shader never did the correct
color transformation.

This is a risky fix as it expects all input texture to be in
the correct colorspace (srgb). If they aren't this will
produce darker result.

If this is a huge issue we can introduce a global setting
(like line width) to set if the attached texture is
in srgb space or linear. This would avoid to change the
drawing code all over the place.

Pull Request: https://projects.blender.org/blender/blender/pulls/141237
2025-07-03 14:07:58 +02:00
Jeroen Bakker
4cd31eb5db Merge branch 'blender-v4.5-release' 2025-06-30 13:57:34 +02:00
Jeroen Bakker
9ff4328246 Fix #141078: Vulkan: Assert when uploading to large vertex buffers
When vertex buffers cannot be uploaded (buffer is to large) the buffer
will get a null handle. However it can still try to upload data to the
null handle.

Pull Request: https://projects.blender.org/blender/blender/pulls/141218
2025-06-30 13:57:06 +02:00
Jeroen Bakker
8b1b9ecae4 Merge branch 'blender-v4.5-release' 2025-06-30 13:55:57 +02:00
Jeroen Bakker
e3f2d8804f Fix #139189: Fix incorrect base and vertex offset in index buffers
When drawing batches the base and vertex offset were incorrectly
interpreted leading to artifacts.

Pull Request: https://projects.blender.org/blender/blender/pulls/141214
2025-06-30 13:55:13 +02:00
Jeroen Bakker
00d746059e Fix #140927, #140912: OpenGL: Annotate draw on surface broken
Recently we switched from Depth24S8 to Depth32FS8. On OpenGL the read
back of depth was not working as it asked the driver to download both
the depth and stencil part of the texture. This isn't supported when using floats
and would not return any data.

This PR forces OpenGL to read back depth component when a depth/stencil
texture is used.

Pull Request: https://projects.blender.org/blender/blender/pulls/141009
2025-06-26 10:05:27 +02:00
Jeroen Bakker
28add6cfea Merge branch 'blender-v4.5-release' 2025-06-26 08:50:36 +02:00
Jeroen Bakker
40eaaf089f Vulkan: Switch Qualcomm to switch to OpenGL
Due to driver issues qualcomm devices that try to start Blender with
a driver below 31.0.112.0 will automatically switch to OpenGL.

Pull Request: https://projects.blender.org/blender/blender/pulls/140902
2025-06-26 08:49:37 +02:00
Clément Foucault
872c8fb189 Fix #77909: Viewport Render Image clamps output
The issue was that this operator is using the same
path as the viewport display. So the colors are
clamped if the display is not HDR.
This fix is easy now that we have an HDR path for
the viewport display. We just enforce using it
when doing the viewport render preview.
2025-06-25 11:28:50 +02:00
Jeroen Bakker
e63a20fee1 Vulkan: HDR support for Wayland
This change enables HDR support for wayland as an experimental feature.
It supports both non-linear extended sRGB and un-clamped sRGB.

Windows isn't supported as the HDR settings are not accessible via an
API and would require similar settings that games use to configure the
monitor. Adding those sliders isn't what we would like to add.

Vulkan (working group) is working on new extensions that might change
the shortcomings. It isn't clear yet what the extension will do and what
the impact is for applications that want to use it. When the extension
is out we should review at the situation again.

Pull Request: https://projects.blender.org/blender/blender/pulls/133159
2025-06-24 11:51:14 +02:00
Jeroen Bakker
03caffe540 GPU: Deprecate GPU_DATA_UINT_24_8
GPU_DATA_UINT_24_8 isn't used anymore. We cannot phase out the data type
as it can still be used by add-ons. This PR will deprecate
`GPU_DATA_UINT_24_8`. When used in an add-on a deprecation message will
be shown.

Pull Request: https://projects.blender.org/blender/blender/pulls/140715
2025-06-20 12:17:20 +02:00
Jeroen Bakker
cdf538e1a7 Merge branch 'blender-v4.5-release' 2025-06-20 09:51:44 +02:00
Jeroen Bakker
d2e88494e1 Cleanup: Vulkan: Remove unused code
Removes `VKTexture::current_layout_` and `VKTexture::init`. The code
was unused since the introduction of the render graph.

Pull Request: https://projects.blender.org/blender/blender/pulls/140708
2025-06-20 09:51:19 +02:00
Jeroen Bakker
09af302457 GPU: Remove depth24 texture format
Metal and AMD/Intel/Vulkan don't support depth24 texture formats
natively. The backends implemented fallback to use depth32f in
stead.

Recently we removed all usages of depth24 to use depth32 and the
next step is to remove the depth24 format and the workarounds in
the backend.

Note: The removal of `GPU_DATA_UINT_24_8` isn't part of this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/140659
2025-06-19 16:24:06 +02:00
Jeroen Bakker
6f8bc55cef Merge branch 'blender-v4.5-release' 2025-06-19 14:13:47 +02:00
Jeroen Bakker
fefbdefbca Fix: Vulkan: Crash on exit
We detected that the gpu/draw tests could lead to
crashes after the tests where finished. It was
identified that the crash happened as the submission
runner wasn't exited, uses a mutex, that is being
destroyed by the main thread.

Solution is to wait until the submission runner has
finished, before destroying resources.

Pull Request: https://projects.blender.org/blender/blender/pulls/140650
2025-06-19 14:13:00 +02:00
Jeroen Bakker
a5e30aaa9e Refactor: GPU: Use Depth32F
Blender uses depth24 for legacy reasons. All backends that we support
have support for depth32f.

This PR updates all usages of depth24 with depth32f.

- depth24 are not supported on AMD/Intel/Vulkan and Metal. There depth32f
  was already used to work around this limitation.
- This allows us to implement reverse depth in workbench, overlay and
grease pencil in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/140531
2025-06-19 13:30:50 +02:00
Campbell Barton
954b492914 Cleanup: remove unused "use_bgl" from the GPU StateManager 2025-06-19 11:57:56 +10:00
Campbell Barton
05631085f8 Cleanup: spelling in comments (make check_spelling_*) 2025-06-19 11:40:00 +10:00
Alaska
b561c78f93 Nodes: Remove legacy combine/separate nodes
In Blender 3.3 (1) the individual combine and separate color nodes were
combined together into a single combine/separate color node.

To ensure legacy addons still worked, the old nodes were left in
Blender, but hidden from the Add menus.

It has been nearly 3 years since that change was made, most if not all
addons should have been updated by now. So this commit removes these
hidden legacy nodes.

(1) blender/blender@82df48227b

Pull Request: https://projects.blender.org/blender/blender/pulls/135376
2025-06-17 15:36:33 +02:00
Jeroen Bakker
e7a8ed0eab GPU: Fix testcase due to recent cleanups
Issue was introduced by !140340. This test has 2 different array sizes
and used the parameter for its range.
2025-06-17 12:28:04 +02:00
Jeroen Bakker
8b9bdf8236 Merge branch 'blender-v4.5-release' 2025-06-17 11:17:40 +02:00
Jeroen Bakker
ea1652dca3 Fix #140229: Vulkan: Crash during depth aware-navigation
Depth navigation sends many small render graphs to the device. It can be
that a subsequent render graph uses the same shader as the previous one
with the same descriptor set tracker. The descriptor set tracker didn't
cleared its full state and a subsequent render graph was generating
commands assuming that the device was in a certain state.

However it wasn't and a command to bind a descriptor set was skipped
resulting in a device out of bound write. Depending on the platform this
could overwrite any data on the GPU, including shader programs as the
select shader writes to a storage buffer. This clarifies why the issue
resulted in very odd and none consistent behavior.

This PR fixes this by clearing the VKPipelineData and
VKDescriptorTracker.

Pull Request: https://projects.blender.org/blender/blender/pulls/140526
2025-06-17 11:17:03 +02:00