Commit Graph

3047 Commits

Author SHA1 Message Date
Clément Foucault
b5749f8e8a GPU: Fix shader builder
Breakage caused by 1978b4fc92
2023-07-11 11:09:30 +02:00
Clément Foucault
1978b4fc92 GHOST: Replace WITH_OPENGL build option
Replaces it by WITH_OPENGL_BACKEND and cleanup its usage.
Limits visibility of opengl enums and cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/109947
2023-07-11 09:17:31 +02:00
Brecht Van Lommel
f2705dd913 Fix #109683: Cycles and Eevee missing AOVs when no closure connected
No reason to skip these, and this will be useful for faster shader node
preview rendering based on AOVs.

Pull Request: https://projects.blender.org/blender/blender/pulls/109709
2023-07-10 12:41:44 +02:00
Clément Foucault
90448b8b5a GPU: Replace std::cout by std::cerr for dependency errors
This allow seeing them during the build process
2023-07-04 12:45:28 +02:00
Jeroen Bakker
bfda24cae3 Fix: Update Stubs for Shader Builder
Issue introduced by recent changes where `BKE_pbvh_count_grid_quads`
required C++ linkage.
2023-07-04 08:09:38 +02:00
Joseph Eagar
7e2659e4ab Cleanup: Split BKE_pbvh.h into BKE_pbvh_api.hh
Split much of BKE_pbvh.h into BKE_pbvh_api.hh.
BKE_pbvh.h is included by BKE_paint.h, which in
turn is included by large amounts of code including
RNA.

This makes it extremely difficult to change
or clean up the PBVH API, since each modification
of BKE_pbvh.h can take 20-30 minutes to compile,
even on a quad-core system with an SSD. This
commit fixes that by moving most of BKE_pbvh.h
into another file and just having the core,
external-facing interfaces in BKE_pbvh.h.
2023-07-03 20:01:04 -07:00
Campbell Barton
9753e70e37 Cleanup: move BLI_str_replace into BLI_string_utils.h
String search & replace is a higher level function (unlike BLI_string.h)
which handlers lower level replacements for printing and string copying.

Also use BLI_string_* prefix (matching other utilities).

This makes it possible to use BLI_string in Blender's internal utilities
without depending on DynStr, MemArena... etc.
2023-07-04 12:02:25 +10:00
Clément Foucault
c2d693f431 GPU: Print shader dependency errors to error stream
This avoid loosing these messages during the build process
which is the point of WITH_GPU_BUILDTIME_SHADER_BUILDER.
2023-07-03 10:36:20 +02:00
Campbell Barton
69aee8ba6b Cleanup: remove redundant (void) for functions with no args in C++ 2023-07-02 19:54:27 +10:00
Campbell Barton
345d1a4b44 Cleanup: simplify struct declarations in C++
Replace `typedef struct X {} X;` with `struct X {};`

In some cases the first and last name didn't match although this
is rarely useful, even a typo in some cases, e.g. TrachPathPoint.
2023-07-02 19:54:26 +10:00
Clément Foucault
ff62f402da EEVEE-Next: Fix overlap with nodetree UBO
Reserve the slot 0 for nodetree and bind
directly to it in Next engines.
2023-06-29 21:10:08 +02:00
Hans Goudey
a1cc621e1e Cleanup: Remove unused custom data type
`CD_HAIRLENGTH` is not really a custom data type, it was just used to
specify the hair particle "length" attribute to pass it to EEVEE and
material preview. Because of the "typemap" array in `CustomData`,
it's better not to have this unnecessary type. Instead, use the same
mechanism used to request the active color attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/109449
2023-06-28 17:17:31 +02:00
Miguel Pozo
d7dac04193 GPU: Print both resources on ShaderCreateInfo::validate_merge failure
Print both names when two resource slots overlap.

Pull Request: https://projects.blender.org/blender/blender/pulls/109017
2023-06-16 15:13:31 +02:00
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Miguel Pozo
6a77345328 GPU: Fix ShaderBuilder MSVC compilation
Add missing stubs and ensure the correct linker flags.

Note: This applies the linker flags on Linux too.

Pull Request: https://projects.blender.org/blender/blender/pulls/108820
2023-06-12 13:09:42 +02:00
Jeroen Bakker
84f1c4e16c Merge branch 'blender-v3.6-release' 2023-06-12 08:44:14 +02:00
Jason Fielder
99931a5154 Metal: Fix failing texture unit tests
Resolves failing unit tests where missing texture read support for
1D/3D textures was required. Also resolves a number of missing
format support cases when determining texture component
count and byte size for reading/writing.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/108751
2023-06-12 08:43:10 +02:00
Brecht Van Lommel
a2bd080cf3 Cleanup: renaming of GPU contexts for clarity
* opengl_context -> system_gpu_context. This is the operating system OpenGL,
  Metal or Vulkan context provided by GHOST.
* gpu_context -> blender_gpu_context. This is the GPUContext provided by
  the Blender GPU module, which wraps the GHOST context and adds some state.
* Various functions create/destroy/enable/disable both contexts, these have
  just gpu_context in the name now.

Pull Request: https://projects.blender.org/blender/blender/pulls/108723
2023-06-08 15:46:53 +02:00
Jason Fielder
a29f6c854d GPU: Move texture attachment usage flag into Metal backend
This is a backend related workaround and doesn't belong to
the GPU layer.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/108151
2023-06-06 18:01:26 +02:00
Campbell Barton
74dd0ed09e Cleanup: remove redundant struct qualifiers 2023-06-03 08:54:37 +10:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Xavier Hallade
c18cafe748 Merge branch 'blender-v3.6-release' 2023-05-25 20:39:27 +02:00
Xavier Hallade
2533576802 EEVEE: Fix non-deterministic codegen preventing shader cache to work
used_libraries was iterated on to generate shader code depending on
pointers order, which was non-deterministic. It prevented shader caching
by graphics drivers to survive across reboots, as reported in
https://techgage.com/article/blender-3-5-performance-deep-dive-cycles-eevee-viewport/

Co-authored-by: Ray Molenkamp <github@lazydodo.com>

Pull Request: https://projects.blender.org/blender/blender/pulls/108289
2023-05-25 20:37:42 +02:00
Campbell Barton
2708317b25 Merge branch 'blender-v3.6-release' 2023-05-25 20:34:06 +10:00
Jason Fielder
03e4325fa9 Fix: High resolution textures in Metal from Integer overflow
Resolve an issue where a high resolution texutre 16k x 8k
did not update in metal due to integer overflow of size parameter.

This patch contains several changes to address size correctness
across multiple use cases within the Metal backend.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/108238
2023-05-25 08:50:14 +02:00
Campbell Barton
129f6b7b84 Cleanup: spelling in comments, replace slang/informal terms 2023-05-24 20:27:13 +10:00
Campbell Barton
13c815085b Cleanup: spelling in comments 2023-05-24 11:21:18 +10:00
Jeroen Bakker
c0e61afc05 GPU: Make ShaderInterface.debug_print const
Method didn't modified the ShaderInterface but wasn't usable when trying
to debug a const reference to the ShaderInterface. This PR just adds the
const to the method.

Pull Request: https://projects.blender.org/blender/blender/pulls/108190
2023-05-23 15:55:47 +02:00
Miguel Pozo
9ae2dd577a Overlay-Next: Initial implementation
This contains the basis of the new overlay engine.
Only a few overlays are ported for proof of concept of the new design.

This new design unifies the selection drawing with the overlay-next engine.
It now becomes responsible of selection in object mode.
For this we create a dedicated shader module that patches the shaders
for selection.

Note that the gizmo selection still uses the occlusion queries and edit-mode
the current selection engine (select_engine.c).

Related task #102179
Related task #102177

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/107734
2023-05-23 15:00:38 +02:00
Jason Fielder
ae405639e7 Metal: Stencil texture view support
Adds stencil texture view support for Metal, allowing reading of
stencil component during texture sample/read.

Stencil view creation refactored to use additional parameter in
textureview creation function, due to deferred stencil parameter
causing double texture view creation in Metal, when this should
ideally be provided upfront.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/107971
2023-05-22 20:40:38 +02:00
Campbell Barton
ab294b4ebb Cleanup: spelling in comments, colon after doxy parameters 2023-05-20 21:24:42 +10:00
Clément Foucault
c435d2f856 Metal: Always add GPU_TEXTURE_USAGE_ATTACHMENT flag
Texture clearing is done using framebuffer clear.
To avoid adding the flag everywhere we add it as part
of the texture creation process.

This should have no performance impact.
2023-05-19 18:48:07 +02:00
Clément Foucault
8fb6b51410 GPU: Fix false positive include of debug_draw
This created unfulfilled resources binds that would
trigger an assert when running with Metal Backend.
2023-05-16 12:54:29 +02:00
Iliya Katueshenock
f7388e3be5 Cleanup: Move BKE_node.h to C++
See: https://projects.blender.org/blender/blender/issues/103343

Changes:
1. Added `BKE_node.hh` file. New file includes old one.
2. Functions moved to new file. Redundant `(void)`, `struct` are removed.
3. All cpp includes replaced from `.h` on `.hh`.
4. Everything in `BKE_node.hh` is on `blender::bke` namespace.
5. All implementation functions moved in namespace.
6. Function names (`BKE_node_*`) changed to `blender::bke::node_*`.
7. `eNodeSizePreset` now is a class, with renamed items.

Pull Request: https://projects.blender.org/blender/blender/pulls/107790
2023-05-15 15:14:22 +02:00
Omar Emara
d91f0bf8d2 Realtime Compositor: Implement Convert Color Space node
This patch implements the Convert Color Space node for the realtime
compositor. A custom OCIO GpuShaderCreator was implemented to use the
ShaderCreateInfo in constructing the OCIO GPU processor shader. That
shader is then cached inside the cache manager and is invalidated when
the OCIO configuration changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/107878
2023-05-15 07:20:08 +02:00
Campbell Barton
c49a0fa474 Cleanup: remove redundant use of BLI_snprintf (no formatting args given)
The SNPRINTF macro isn't usable as it expectes at least one argument.
2023-05-09 14:08:19 +10:00
Campbell Barton
3958ae7241 Cleanup: use STRNCPY, SNPRINTF macros 2023-05-09 14:08:19 +10:00
Chris Blackbourn
48abc09d84 Cleanup: format 2023-05-05 23:44:56 +12:00
Hans Goudey
d0705bd697 Mesh: Split MLoopTri poly indices into a separate array
For derived mesh triangulation information, currently the three face
corner indices are stored in the same struct as index of the mesh
polygon the triangle is part of. While those pieces of information are
often used together, they often aren't, and combining them prevents
the indices from being used with generic utilities. It also means that
1/3 more memory has to be written when recalculating the triangulation
after deforming the mesh, and that the entire triangle data has to be
read when only the polygon indices are needed.

This commit splits the polygon index into a separate cache on `Mesh`.
The triangulation data isn't saved to files, so this doesn't affect
.blend files at all.

In a simple test deforming a mesh with geometry nodes, the time used
to recalculate the triangulation reduced from 2.0 ms to 1.6 ms,
increasing overall FPS from 14.6 to 15.

Pull Request: https://projects.blender.org/blender/blender/pulls/106774
2023-05-04 15:39:10 +02:00
Clément Foucault
e39c3c600c GPU: ShaderLog: Add more const correctness & notes supports
The metal shader compiler can produce `note` reports.
Treat them as warnings.
2023-05-04 10:59:26 +02:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Jason Fielder
36e1ebc78d Metal: Resolve runtime issues with texture views
When creating a texture view, Metal may require that the original
GPUTexture state is modified in some way. This may be a result
of deferred creation, or, to cache the texture view against the
source.

As a result, GPUTexture passed into GPU_texture_create_view
cannot be const.

Small fixes have also been made in the Metal texture
implementation to ensure correct function of texture views.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/107167
2023-05-01 09:14:00 +02:00
Jason Fielder
680a54c7d0 EEVEE Next: Ensure correct texture usage for views
Add texture usage flags for textures which are used as texture views
or require texture views for backing implementation.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/107163
2023-04-21 10:06:55 +02:00
Campbell Barton
b132118f89 Cleanup: balance doxygen grouping, minor grouping adjustment 2023-04-19 09:02:21 +10:00
Jason Fielder
4d75f10a8a EEVEE: Optimise texture usage flags
Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/107037
2023-04-18 08:11:46 +02:00
Campbell Barton
5f40118899 Cleanup: rename GPU_offscreen_read_{pixels=>color} noted as a TODO 2023-04-16 20:38:19 +10:00
Campbell Barton
6cc2c16d06 Fix #106264: Color picker broken with Wayland & AMD GPU
- Use off-screen drawing when reading from the front-buffer isn't
  supported.

- Add a capabilities flag for reading the front-buffer which is always
  disabled on WAYLAND.

- Add GPU_offscreen_read_pixels_region, used for reading a sub-region of
  an off-screen buffer - use for color-picking a single pixel.
2023-04-16 20:16:54 +10:00
Jeroen Bakker
db47f82626 GPU: Add Texture Usage Parameter to GPUOffscreen.
Currently the Textures used for offscreen rendering don't have
the `GPU_TEXTURE_USAGE_HOST_READ` flag. But some cases it is
needed. This PR adds a parameter when creating an offscreen
buffer.

Other solution could be to add this flag to all textures, but
we chose not to do this as that reduces the amount of fine-tuning
options for Metal/Vulkan backends. GPU can store textures
differently based on its actual usage.

This option isn't available in the python API as we don't expect
add-on developers to fine-tune texture usages to this extent.

For convenience `GPU_TEXTURE_USAGE_ATTACHMENT` is by default
always added.

Pull Request: https://projects.blender.org/blender/blender/pulls/106899
2023-04-14 22:02:51 +02:00
Clément Foucault
7e764ec692 GPU: Texture: Expose depth dimension extent
This function was not exposed outside of internal GPU module.

Renaming `draw::Texture::depth()` to `is_depth` for consistency
and removing the ambiguity.
2023-04-13 14:06:53 +02:00
Miguel Pozo
f8c964de87 GPU: Improve the shader cache GC behavior
Improves the shader cache GC behavior, so the passes are only
deleted after being orphaned for over 1 minute.

Pull Request: https://projects.blender.org/blender/blender/pulls/106386
2023-04-10 11:39:00 +02:00