Commit Graph

334 Commits

Author SHA1 Message Date
Clément Foucault
6c4b410d3e Cleanup: Remove unused draw_common_shader_shared.hh 2025-04-30 09:55:48 +02:00
Jeroen Bakker
3aba58b94a Cleanup: Make format 2025-04-29 13:49:24 +02:00
Falk David
1d6f313995 Grease Pencil: Remove minimum thickness clamping
This removes the minimum thickness clamping in the shader.
The reason why this was clamped in the first place was to reduce
aliasing artifacts. With the new super sampling method for
rendering, this should no longer be an issue.

Note: This can break visual compatibility, but the previous radii
were arguably "wrong". This essentially fixes this and renders
the strokes with the actual radii from the attribute.
Previous files that might have relied on the clamping will have
to be updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/138119
2025-04-29 12:46:48 +02:00
Clément Foucault
db22802652 DRW: Avoid warning in subdiv shader code
Was missing a return statement.
2025-04-28 00:55:57 +02:00
Clément Foucault
59df50c326 GPU: Refactor Qualifier and ImageType
This allow to use types closer to GLSL in resource
declaration.

These are aliased for clarity in the GPU
module (i.e. `isampler2D` is shortened to `Int2D`).

Rel #137446

Pull Request: https://projects.blender.org/blender/blender/pulls/137954
2025-04-24 14:38:13 +02:00
Clément Foucault
3f11d16501 Cleanup: DRW: Make all shader resource snake case
This make sure that the DRW folder is compliant to our codestyle.

Pull Request: https://projects.blender.org/blender/blender/pulls/137673
2025-04-24 12:50:45 +02:00
Clément Foucault
0f71bb6c71 GPU: Rename shader_shared.h files to .hh
This makes more sense now that everything is C++.
2025-04-16 20:26:48 +02:00
Clément Foucault
a6fa1b5969 DRW: Rename common_*_lib.glsl to follow module prefix 2025-04-16 20:19:09 +02:00
Clément Foucault
f2025f28e7 DRW: Move fullscreen vertex shader to gpu common
This makes no sense to have in the draw namespace.

Also take the opportunity for making the coordinates
a float2 and rename them to something more descriptive.
2025-04-16 20:09:28 +02:00
Clément Foucault
3b3a5731df GPU: Shader: Change vector and matrix type to use blender convention
This unify the C++ and GLSL codebase style.

The GLSL types are still in the backend compatibility
layers to support python shaders. However, the C++
shader compilation layer doesn't have them to enforce
correct type usage.

Note that this is going to break pretty much all PRs
in flight that targets shader code.

Rel #137261

Pull Request: https://projects.blender.org/blender/blender/pulls/137369
2025-04-14 13:46:41 +02:00
Clément Foucault
9990273d04 GPU: Change Type enum to use lower case values
This is to help for future resource declaration
using macros.

Rel #137261

Pull Request: https://projects.blender.org/blender/blender/pulls/137367
2025-04-11 22:39:01 +02:00
Clément Foucault
bb52754652 GPU: Use f suffix for float literals
They are actually already some literals with the `f` suffix
that are in our shader codebase and we never had problem in
the past 5 years (or even 8 years).

So I think it is safe to do and improves convergence of codestyles.

Pull Request: https://projects.blender.org/blender/blender/pulls/137352
2025-04-11 18:28:45 +02:00
Clément Foucault
890e00cecb DRW: DebugDraw: Revamp the module and make it global
- Make the module global and allow usage from anywhere.
- Remove the matrix API for thread safety reason
- Add lifetime management
- Make display linked to the overlays for easy toggling

## Notes
- Lifetime is in redraw. If there is 4 viewport redrawing, the lifetime decrement by 4 for each window redraw. This allows one viewport to be producer and another one being the consumer.
- Display happens at the start of overlays. Any added visuals inside of the overlays drawing functions will be displayed the next redraw.
- Redraw is not given to happen. It is only given if there is some scene / render update which tags the viewport to redraw.
- Persistent lines are not reset on file load.

Rel #137006

Pull Request: https://projects.blender.org/blender/blender/pulls/137106
2025-04-09 21:37:23 +02:00
Campbell Barton
f89cf19ba6 Cleanup: indentation for CMake files, strip trailing space 2025-04-02 03:01:59 +00:00
Jeroen Bakker
3ad5721a1c Fix #136767: SubDiv: Incorrect attribute interpolation
177bbf12df solved the out of bound read
by limiting the input search. However this lead to incorrect
interpolation. This has been fixed by moving the bound check as a
post check.

Pull Request: https://projects.blender.org/blender/blender/pulls/136769
2025-03-31 15:43:01 +02:00
Jeroen Bakker
177bbf12df Fix #136239: SubDiv: Read out of bounds
GPU subdivision shaders can read out of bound when evaluating
the last face. This seems to be always been the case, but Metal + Vulkan
has validation to detect these mis-usages.

Binary search was initialized with out of bound values so the last
face could select out of bound index due to rounding.

Pull Request: https://projects.blender.org/blender/blender/pulls/136242
2025-03-20 12:17:58 +01:00
Clément Foucault
e36cc4dcf7 Cleanup: Grease Pencil: Remove uneeded push-constants
All of these push-constants were either redundant or
not used anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/135561
2025-03-06 15:14:05 +01:00
Clément Foucault
bb2d123fbd Cleanup: DRW: Remove ObjectInfos legacy GLSL macros
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/135542
2025-03-06 11:06:26 +01:00
Campbell Barton
d951428422 Cleanup: spelling in comments
Address warnings from check_spelling.py
2025-03-06 10:49:51 +11:00
Clément Foucault
bacc58b142 Cleanup: DRW: Remove duplicated glsl library 2025-03-05 15:31:35 +01:00
Clément Foucault
9bddb57960 Cleanup: DRW: Relace drw_view macros by function calls 2025-03-05 15:31:35 +01:00
Clément Foucault
a92f6ebf13 Cleanup: DRW: Remove ModelMatrix legacy GLSL macros 2025-03-05 15:31:35 +01:00
Clément Foucault
5916c39fa4 Cleanup: DRW: Simplify resource id and custom id 2025-03-05 15:31:35 +01:00
Clément Foucault
783472671e Cleanup: GPU: Add macro for default constructor compatibility on MSL 2025-03-03 12:50:45 +01:00
Jeroen Bakker
22aad0fde7 SubDiv: Use shader create info for patch evaluation shader
This PR migrates the subdiv_patch_evaluation_comp.glsl to use
shader create info.

The part of OSD that is used is included as a typedef source (osd_patch_basis.glsl).

Pull Request: https://projects.blender.org/blender/blender/pulls/134917
2025-02-27 15:42:08 +01:00
Jeroen Bakker
fcc5681624 SubDiv: Use shader create info for custom data
This PR migrates the custom_data_interp_comp.glsl to use
shader create info.

During development tests have been conducted to use specialization constants,
but due to limitations inside Metal we didn't use them.

Number of ShaderCreateInfos have been reduced by using macros. Variadic macros
have not been used as they don't support CPP compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/134932
2025-02-27 09:50:36 +01:00
Jeroen Bakker
e2793ab3da Fix: SubDiv: CPP Shader compilation
Some shaders were missing and didn't
compile using CPP compilation

Pull Request: https://projects.blender.org/blender/blender/pulls/135090
2025-02-27 08:54:34 +01:00
Clément Foucault
f47f990594 Cleanup: DRW: Remove uniforms declaration and dangerous defines 2025-02-25 23:46:27 +01:00
Clément Foucault
b2ed7eb45c Cleanup: DRW: Remove unused legacy shader libraries 2025-02-25 23:10:19 +01:00
Clément Foucault
3a7d086200 Cleanup: DRW: Remove legacy create info and rename new ones
This is just mass renaming
2025-02-25 23:05:12 +01:00
Hans Goudey
24e67d9d49 Point Cloud: Remove multiplication in radius extraction and shaders
This multiplication by 100/0.01 was there for historical reasons.
This commit just removes it everywhere.

Pull Request: https://projects.blender.org/blender/blender/pulls/135123
2025-02-25 19:10:45 +01:00
Clément Foucault
cb7d9222cf Cleanup: DRW: Remove legacy object data create infos
Remove deprecated (and unused) create infos and mass
rename the `*_new` ones.
2025-02-25 18:46:42 +01:00
Clément Foucault
d8387a82ff Cleanup: DRW: Remove legacy common_math_lib 2025-02-25 18:12:33 +01:00
Jeroen Bakker
3b5c3e70b1 SubDiv: Use shader create info for stretch overlays
This PR migrates subdiv_vbo_edituv_strech_*_comp.glsl to use
shader create info.

Pull Request: https://projects.blender.org/blender/blender/pulls/135038
2025-02-24 13:32:53 +01:00
Jeroen Bakker
1f0bc6bbe6 SubDiv: Use shader create info for sculpt data
This PR migrates subdiv_vbo_sculpt_data_comp.glsl to use
shader create info.

Pull Request: https://projects.blender.org/blender/blender/pulls/135032
2025-02-24 12:58:13 +01:00
Jeroen Bakker
3e030e3de0 SubDiv: Use shader create info for edge fac shader
This PR migrates the subdiv_vbo_edge_fac.glsl to use
shader create info.

Pull Request: https://projects.blender.org/blender/blender/pulls/134907
2025-02-21 16:26:28 +01:00
Jeroen Bakker
8299b30269 SubDiv: Use shader create info for lnor shader
This PR migrates the subdiv_vbo_lnor_comp.glsl to use
shader create info.

Pull Request: https://projects.blender.org/blender/blender/pulls/134916
2025-02-21 15:43:09 +01:00
Jeroen Bakker
8e72bf937f SubDiv: Use shader create info for triangle indices shader
This PR migrates the subdiv_ibo_tris_comp.glsl to use
shader create info. Due to naming collision shader_data
needs to be accessed directly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134867
2025-02-21 14:55:18 +01:00
Jeroen Bakker
c436972b2b SubDiv: Use shader create info for lines shader
This PR migrates the subdiv_ibo_lines_comp.glsl to use
shader create info.

Pull Request: https://projects.blender.org/blender/blender/pulls/134857
2025-02-21 14:16:57 +01:00
Jeroen Bakker
310d103600 SubDiv: Use shader create info for normal accumulation shader
This PR migrates the subdiv_normal_accumulation_comp.glsl to use
shader create info.

Pull Request: https://projects.blender.org/blender/blender/pulls/134837
2025-02-21 12:38:57 +01:00
Jeroen Bakker
3969e30c6f SubDiv: Add base for polygon offset
Subdiv shader library contains an optional part that shaders can include.
As we are migrating each shader at a time there are now multiple PRs doing
the same thing. Best to add the changes to main already so it doesn't add
confusion during review.

Pull Request: https://projects.blender.org/blender/blender/pulls/134906
2025-02-21 10:21:44 +01:00
Jeroen Bakker
e39669e3c3 SubDiv: Use shader create info for SubdivNormalsFinalize shaders.
This change migrates the first 2 subdiv shaders  to use the ShaderCreateInfo.
Other shaders will follow in separate PRs.

- Should compile when using `WITH_GPU_SHADER_CPP_COMPILATION`
- A `subdiv_` prefix is added only to the functions related to `PosNorLoop`.
    But eventually the prefix should also be added to other lib functions.
- Due to Metal restrictions `subdiv_set_vertex_*` is implemented using a
    functional paradigma. Our Metal backend only supports `inout` qualifier
    on thead local data structures.

Pull Request: https://projects.blender.org/blender/blender/pulls/134218
2025-02-20 12:30:51 +01:00
Clément Foucault
f8195e0bb4 Fix: Overlay: Broken shader compilation
Caused by the changes in UBO members.
This removes the duplicated lib used by overlay
and reuse the same side clip plane UBO mechanism
as workbench.
2025-02-19 17:46:47 +01:00
Clément Foucault
a961c9050d Cleanup: GPU: Remove dependency on legacy common_math_lib.glsl
Replace usage of `common_math_lib.glsl` (deprecated) with gpu shader libs.

Pull Request: https://projects.blender.org/blender/blender/pulls/131579
2025-02-10 18:14:50 +01:00
Campbell Barton
e659e87a67 Cleanup: cmake formatting, sort file lists 2025-02-10 19:40:06 +11:00
Jeroen Bakker
d496e69eca Cleanup: Subdiv: Remove common_ prefix
The `common_` prefix can be confusing as there are other common_ files as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/134184
2025-02-07 07:48:49 +01:00
Clément Foucault
1ac4651778 Cleanup: DRW: Remove legacy common_view_lib.glsl
No functional changes. Only moving and renaming stuff.

Pull Request: https://projects.blender.org/blender/blender/pulls/131558
2025-01-23 18:06:22 +01:00
Campbell Barton
a3213dc82a Cleanup: trailing space 2024-12-09 09:23:23 +11:00
Miguel Pozo
e3c6c2c6fc Cleanup: CMake: De-duplicate with_shader_cpp_compilation code
Move the common setup and function to `macros.cmake`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131391
2024-12-06 21:03:11 +01:00
Miguel Pozo
72aaaa0c24 Fix: GPU: Errors and warnings for CPP shaders in MSVC
Pull Request: https://projects.blender.org/blender/blender/pulls/131332
2024-12-04 17:33:12 +01:00