Commit Graph

5 Commits

Author SHA1 Message Date
Clément Foucault
fe213f80a4 GPU: Shader: Make info files generated
This is the first step of moving the create infos
back inside shader sources.

All info files are now treated as source files.
However, they are not considered in the include tree
yet. This will come in another following PR.

Each shader source file now generate a `.info` file
containing only the create info declarations.

This renames all info files so that they do not
conflict with their previous versions that were
copied (non-generated).

Pull Request: https://projects.blender.org/blender/blender/pulls/146676
2025-09-25 10:57:02 +02:00
Clément Foucault
acb2f02910 EEVEE: Reduce necessary includes
This saves a few milisecond of compile time per shader.

This removes the need for occlusion lib when not using occlusion
node.

To improve detection of uneeded includes, we add a new logging
system which output can be fed to mermaid to inspect dependencies.

The new dependencies can be inspected using `--log "gpu.shader_dependencies"`

Example pasted here:
```mermaid
flowchart LR
draw_curves_lib.glsl_7298 --> gpu_shader_math_constants_lib.glsl_600
style gpu_shader_math_constants_lib.glsl_600 fill:#0f0
gpu_shader_math_matrix_conversion_lib.glsl_1032 --> gpu_shader_math_base_lib.glsl_1406
style gpu_shader_math_base_lib.glsl_1406 fill:#1e0
gpu_shader_math_matrix_conversion_lib.glsl_1032 --> gpu_shader_math_euler_lib.glsl_461
style gpu_shader_math_euler_lib.glsl_461 fill:#0f0
gpu_shader_math_matrix_compare_lib.glsl_2964 --> gpu_shader_math_vector_compare_lib.glsl_2489
style gpu_shader_math_vector_compare_lib.glsl_2489 fill:#2d0
gpu_shader_math_matrix_conversion_lib.glsl_1032 --> gpu_shader_math_matrix_compare_lib.glsl_2964
style gpu_shader_math_matrix_compare_lib.glsl_2964 fill:#2d0
gpu_shader_math_matrix_conversion_lib.glsl_1032 --> gpu_shader_math_quaternion_lib.glsl_395
style gpu_shader_math_quaternion_lib.glsl_395 fill:#0f0
gpu_shader_math_matrix_conversion_lib.glsl_1032 --> gpu_shader_utildefines_lib.glsl_3112
style gpu_shader_utildefines_lib.glsl_3112 fill:#3c0
draw_curves_lib.glsl_7298 --> gpu_shader_math_matrix_conversion_lib.glsl_1032
style gpu_shader_math_matrix_conversion_lib.glsl_1032 fill:#1e0
draw_curves_lib.glsl_7298 --> gpu_shader_math_matrix_transform_lib.glsl_706
style gpu_shader_math_matrix_transform_lib.glsl_706 fill:#0f0
eevee_surf_deferred_frag.glsl_4531 --> draw_curves_lib.glsl_7298
style draw_curves_lib.glsl_7298 fill:#780
eevee_surf_deferred_frag.glsl_4531 --> draw_view_lib.glsl_3551
style draw_view_lib.glsl_3551 fill:#3c0
eevee_gbuffer_lib.glsl_14598 --> gpu_shader_math_vector_reduce_lib.glsl_1383
style gpu_shader_math_vector_reduce_lib.glsl_1383 fill:#1e0
eevee_gbuffer_lib.glsl_14598 --> gpu_shader_codegen_lib.glsl_6143
style gpu_shader_codegen_lib.glsl_6143 fill:#690
eevee_gbuffer_lib.glsl_14598 --> gpu_shader_math_vector_lib.glsl_5038
style gpu_shader_math_vector_lib.glsl_5038 fill:#5a0
eevee_gbuffer_lib.glsl_14598 --> gpu_shader_utildefines_lib.glsl_3112
style gpu_shader_utildefines_lib.glsl_3112 fill:#3c0
eevee_gbuffer_write_lib.glsl_7324 --> eevee_gbuffer_lib.glsl_14598
style eevee_gbuffer_lib.glsl_14598 fill:#e10
eevee_surf_deferred_frag.glsl_4531 --> eevee_gbuffer_write_lib.glsl_7324
style eevee_gbuffer_write_lib.glsl_7324 fill:#780
eevee_ambient_occlusion_lib.glsl_10738 --> draw_view_lib.glsl_3551
style draw_view_lib.glsl_3551 fill:#3c0
draw_math_geom_lib.glsl_5172 --> gpu_shader_math_vector_lib.glsl_5038
style gpu_shader_math_vector_lib.glsl_5038 fill:#5a0
draw_math_geom_lib.glsl_5172 --> gpu_shader_math_vector_reduce_lib.glsl_1383
style gpu_shader_math_vector_reduce_lib.glsl_1383 fill:#1e0
eevee_ray_types_lib.glsl_2390 --> draw_math_geom_lib.glsl_5172
style draw_math_geom_lib.glsl_5172 fill:#5a0
eevee_ray_types_lib.glsl_2390 --> draw_view_lib.glsl_3551
style draw_view_lib.glsl_3551 fill:#3c0
eevee_ray_types_lib.glsl_2390 --> gpu_shader_math_matrix_transform_lib.glsl_706
style gpu_shader_math_matrix_transform_lib.glsl_706 fill:#0f0
gpu_shader_math_safe_lib.glsl_1235 --> gpu_shader_math_constants_lib.glsl_600
style gpu_shader_math_constants_lib.glsl_600 fill:#0f0
eevee_ray_types_lib.glsl_2390 --> gpu_shader_math_safe_lib.glsl_1235
style gpu_shader_math_safe_lib.glsl_1235 fill:#1e0
eevee_ray_types_lib.glsl_2390 --> gpu_shader_ray_lib.glsl_137
style gpu_shader_ray_lib.glsl_137 fill:#0f0
eevee_ambient_occlusion_lib.glsl_10738 --> eevee_ray_types_lib.glsl_2390
style eevee_ray_types_lib.glsl_2390 fill:#2d0
eevee_sampling_lib.glsl_4291 --> gpu_shader_math_base_lib.glsl_1406
style gpu_shader_math_base_lib.glsl_1406 fill:#1e0
eevee_sampling_lib.glsl_4291 --> gpu_shader_math_constants_lib.glsl_600
style gpu_shader_math_constants_lib.glsl_600 fill:#0f0
eevee_sampling_lib.glsl_4291 --> gpu_shader_math_safe_lib.glsl_1235
style gpu_shader_math_safe_lib.glsl_1235 fill:#1e0
eevee_ambient_occlusion_lib.glsl_10738 --> eevee_sampling_lib.glsl_4291
style eevee_sampling_lib.glsl_4291 fill:#4b0
eevee_ambient_occlusion_lib.glsl_10738 --> eevee_utility_tx_lib.glsl_1225
style eevee_utility_tx_lib.glsl_1225 fill:#1e0
eevee_ambient_occlusion_lib.glsl_10738 --> gpu_shader_math_base_lib.glsl_1406
style gpu_shader_math_base_lib.glsl_1406 fill:#1e0
gpu_shader_math_fast_lib.glsl_921 --> gpu_shader_math_constants_lib.glsl_600
style gpu_shader_math_constants_lib.glsl_600 fill:#0f0
eevee_ambient_occlusion_lib.glsl_10738 --> gpu_shader_math_fast_lib.glsl_921
style gpu_shader_math_fast_lib.glsl_921 fill:#0f0
gpu_shader_math_vector_safe_lib.glsl_5847 --> gpu_shader_math_safe_lib.glsl_1235
style gpu_shader_math_safe_lib.glsl_1235 fill:#1e0
eevee_ambient_occlusion_lib.glsl_10738 --> gpu_shader_math_vector_safe_lib.glsl_5847
style gpu_shader_math_vector_safe_lib.glsl_5847 fill:#5a0
eevee_ambient_occlusion_lib.glsl_10738 --> gpu_shader_utildefines_lib.glsl_3112
style gpu_shader_utildefines_lib.glsl_3112 fill:#3c0
eevee_nodetree_frag_lib.glsl_395 --> eevee_ambient_occlusion_lib.glsl_10738
style eevee_ambient_occlusion_lib.glsl_10738 fill:#a50
eevee_nodetree_frag_lib.glsl_395 --> eevee_geom_types_lib.glsl_682
style eevee_geom_types_lib.glsl_682 fill:#0f0
draw_model_lib.glsl_2563 --> draw_view_lib.glsl_3551
style draw_view_lib.glsl_3551 fill:#3c0
eevee_nodetree_lib.glsl_16051 --> draw_model_lib.glsl_2563
style draw_model_lib.glsl_2563 fill:#2d0
draw_object_infos_lib.glsl_1114 --> draw_model_lib.glsl_2563
style draw_model_lib.glsl_2563 fill:#2d0
eevee_nodetree_lib.glsl_16051 --> draw_object_infos_lib.glsl_1114
style draw_object_infos_lib.glsl_1114 fill:#1e0
eevee_nodetree_lib.glsl_16051 --> draw_view_lib.glsl_3551
style draw_view_lib.glsl_3551 fill:#3c0
eevee_nodetree_lib.glsl_16051 --> eevee_renderpass_lib.glsl_1793
style eevee_renderpass_lib.glsl_1793 fill:#1e0
eevee_nodetree_lib.glsl_16051 --> eevee_utility_tx_lib.glsl_1225
style eevee_utility_tx_lib.glsl_1225 fill:#1e0
eevee_nodetree_lib.glsl_16051 --> gpu_shader_codegen_lib.glsl_6143
style gpu_shader_codegen_lib.glsl_6143 fill:#690
eevee_nodetree_lib.glsl_16051 --> gpu_shader_math_base_lib.glsl_1406
style gpu_shader_math_base_lib.glsl_1406 fill:#1e0
eevee_nodetree_lib.glsl_16051 --> gpu_shader_math_safe_lib.glsl_1235
style gpu_shader_math_safe_lib.glsl_1235 fill:#1e0
eevee_nodetree_lib.glsl_16051 --> gpu_shader_math_vector_reduce_lib.glsl_1383
style gpu_shader_math_vector_reduce_lib.glsl_1383 fill:#1e0
eevee_nodetree_lib.glsl_16051 --> gpu_shader_utildefines_lib.glsl_3112
style gpu_shader_utildefines_lib.glsl_3112 fill:#3c0
eevee_nodetree_frag_lib.glsl_395 --> eevee_nodetree_lib.glsl_16051
style eevee_nodetree_lib.glsl_16051 fill:#f00
gpu_shader_material_ambient_occlusion.glsl_558 --> gpu_shader_math_vector_safe_lib.glsl_5847
style gpu_shader_math_vector_safe_lib.glsl_5847 fill:#5a0
eevee_nodetree_frag_lib.glsl_395 --> gpu_shader_material_ambient_occlusion.glsl_558
style gpu_shader_material_ambient_occlusion.glsl_558 fill:#0f0
eevee_nodetree_frag_lib.glsl_395 --> gpu_shader_material_emission.glsl_380
style gpu_shader_material_emission.glsl_380 fill:#0f0
gpu_shader_material_output_material.glsl_850 --> gpu_shader_material_transform_utils.glsl_2136
style gpu_shader_material_transform_utils.glsl_2136 fill:#2d0
eevee_nodetree_frag_lib.glsl_395 --> gpu_shader_material_output_material.glsl_850
style gpu_shader_material_output_material.glsl_850 fill:#0f0
eevee_nodetree_frag_lib.glsl_395 --> gpu_shader_material_world_normals.glsl_128
style gpu_shader_material_world_normals.glsl_128 fill:#0f0
eevee_surf_deferred_frag.glsl_4531 --> eevee_nodetree_frag_lib.glsl_395
style eevee_nodetree_frag_lib.glsl_395 fill:#0f0
eevee_surf_deferred_frag.glsl_4531 --> eevee_sampling_lib.glsl_4291
style eevee_sampling_lib.glsl_4291 fill:#4b0
eevee_surf_lib.glsl_3650 --> draw_view_lib.glsl_3551
style draw_view_lib.glsl_3551 fill:#3c0
eevee_surf_lib.glsl_3650 --> gpu_shader_codegen_lib.glsl_6143
style gpu_shader_codegen_lib.glsl_6143 fill:#690
eevee_surf_lib.glsl_3650 --> gpu_shader_math_base_lib.glsl_1406
style gpu_shader_math_base_lib.glsl_1406 fill:#1e0
eevee_surf_lib.glsl_3650 --> gpu_shader_math_vector_safe_lib.glsl_5847
style gpu_shader_math_vector_safe_lib.glsl_5847 fill:#5a0
eevee_surf_deferred_frag.glsl_4531 --> eevee_surf_lib.glsl_3650
style eevee_surf_lib.glsl_3650 fill:#3c0
```

Pull Request: https://projects.blender.org/blender/blender/pulls/146580
2025-09-23 17:21:56 +02:00
Clément Foucault
e19e9e57ee EEVEE: Split eevee_shader_shared.hh into multiple files
The goal of this patch is to reduce final shader code footprint to
hopefully reduce shader compile time (see #145347).

This also contains a pass over most shader file to remove unused
include or use more granular ones to reduce final shader code
length.

Testing with the same setup as #145347:
|          | main (ms) |  PR (ms) |   Delta (ms) |
| -------- | ----------- | ------------ |------------ |
| Nvidia   |         257 |  207 (1.24x) |         50 |
| Mesa AMD |         323 |  295 (1.09x)    |        28 |

In barbershop test scene however the saving are not so noticeable:
|          | main (s) |  PR (s) |   Delta (s) |
| -------- | ----------- | ------------ |------------ |
| Nvidia (OpenGL)  |         40 |  39 (1.02x) |         1 |
| Nvidia (Vulkan)   |         29 |  29 (1.0x) |         0 |

Pull Request: https://projects.blender.org/blender/blender/pulls/145803
2025-09-12 14:09:35 +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
894c7fa4e2 EEVEE: Remove EEVEE Next mention inside the code
This only changes file and function names.
The EEVEE identifier is still `BLENDER_EEVEE_NEXT`.

No functional changes.
2025-03-17 15:37:04 +01:00