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
This commit is contained in:
committed by
Clément Foucault
parent
c7b91903df
commit
acb2f02910
@@ -377,6 +377,7 @@ set(GLSL_SRC
|
||||
engines/eevee/shaders/eevee_geom_curves_vert.glsl
|
||||
engines/eevee/shaders/eevee_geom_mesh_vert.glsl
|
||||
engines/eevee/shaders/eevee_geom_pointcloud_vert.glsl
|
||||
engines/eevee/shaders/eevee_geom_types_lib.glsl
|
||||
engines/eevee/shaders/eevee_geom_volume_vert.glsl
|
||||
engines/eevee/shaders/eevee_geom_world_vert.glsl
|
||||
engines/eevee/shaders/eevee_hiz_debug_frag.glsl
|
||||
|
||||
@@ -653,11 +653,14 @@ void ShaderModule::material_create_info_amend(GPUMaterial *gpumat, GPUCodegenOut
|
||||
}
|
||||
}
|
||||
|
||||
bool use_ao_node = false;
|
||||
|
||||
if (GPU_material_flag_get(gpumat, GPU_MATFLAG_AO) &&
|
||||
ELEM(pipeline_type, MAT_PIPE_FORWARD, MAT_PIPE_DEFERRED) &&
|
||||
geometry_type_has_surface(geometry_type))
|
||||
{
|
||||
info.define("MAT_AMBIENT_OCCLUSION");
|
||||
use_ao_node = true;
|
||||
}
|
||||
|
||||
if (GPU_material_flag_get(gpumat, GPU_MATFLAG_TRANSPARENT)) {
|
||||
@@ -947,6 +950,7 @@ void ShaderModule::material_create_info_amend(GPUMaterial *gpumat, GPUCodegenOut
|
||||
|
||||
Vector<StringRefNull> dependencies = {};
|
||||
if (use_vertex_displacement) {
|
||||
dependencies.append("eevee_geom_types_lib.glsl");
|
||||
dependencies.append("eevee_nodetree_lib.glsl");
|
||||
dependencies.extend(codegen.displacement.dependencies);
|
||||
}
|
||||
@@ -955,7 +959,12 @@ void ShaderModule::material_create_info_amend(GPUMaterial *gpumat, GPUCodegenOut
|
||||
}
|
||||
|
||||
if (pipeline_type != MAT_PIPE_VOLUME_OCCUPANCY) {
|
||||
Vector<StringRefNull> dependencies = {"eevee_nodetree_lib.glsl"};
|
||||
Vector<StringRefNull> dependencies;
|
||||
if (use_ao_node) {
|
||||
dependencies.append("eevee_ambient_occlusion_lib.glsl");
|
||||
}
|
||||
dependencies.append("eevee_geom_types_lib.glsl");
|
||||
dependencies.append("eevee_nodetree_lib.glsl");
|
||||
|
||||
for (const auto &graph : codegen.material_functions) {
|
||||
frag_gen << graph.serialized;
|
||||
|
||||
@@ -17,7 +17,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_curves)
|
||||
#include "draw_curves_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_geom_types_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
|
||||
@@ -12,7 +12,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_modelmat)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_geom_types_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_vector_safe_lib.glsl"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_pointcloud)
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_pointcloud_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_geom_types_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
|
||||
#include "gpu_shader_math_matrix_transform_lib.glsl"
|
||||
|
||||
@@ -12,7 +12,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_modelmat)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_geom_types_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
|
||||
@@ -4,11 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_geom_types_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name World
|
||||
*
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_base_lib.glsl"
|
||||
#include "gpu_shader_math_safe_lib.glsl"
|
||||
#include "gpu_shader_ray_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -62,13 +62,6 @@ struct LightProbeRay {
|
||||
float perceptual_roughness;
|
||||
};
|
||||
|
||||
/* General purpose 3D ray. */
|
||||
struct Ray {
|
||||
packed_float3 direction;
|
||||
float max_time;
|
||||
packed_float3 origin;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Utils
|
||||
* \{ */
|
||||
|
||||
@@ -16,6 +16,7 @@ SHADER_LIBRARY_CREATE_INFO(eevee_utility_texture)
|
||||
#include "gpu_shader_math_fast_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
#include "gpu_shader_math_vector_safe_lib.glsl"
|
||||
#include "gpu_shader_ray_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "eevee_bxdf_lib.glsl"
|
||||
#include "gpu_shader_ray_lib.glsl"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Oren Nayar BSDF
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
* Sampling of Normal Distribution Function for various BxDF.
|
||||
*/
|
||||
|
||||
#include "eevee_bxdf_diffuse_lib.glsl"
|
||||
#include "eevee_bxdf_lib.glsl"
|
||||
#include "eevee_bxdf_microfacet_lib.glsl"
|
||||
#include "eevee_bxdf_diffuse_lib.glsl" // IWYU pragma: export
|
||||
#include "eevee_bxdf_lib.glsl" // IWYU pragma: export
|
||||
#include "eevee_bxdf_microfacet_lib.glsl" // IWYU pragma: export
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/* SPDX-FileCopyrightText: 2022-2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gpu_shader_compat.hh"
|
||||
|
||||
struct MeshVertex {
|
||||
int _pad; /* TODO(fclem): Add explicit attribute loading for mesh. */
|
||||
METAL_CONSTRUCTOR_1(MeshVertex, int, _pad)
|
||||
};
|
||||
|
||||
struct PointCloudPoint {
|
||||
int _pad; /* TODO(fclem): Add explicit attribute loading for mesh. */
|
||||
METAL_CONSTRUCTOR_1(PointCloudPoint, int, _pad)
|
||||
};
|
||||
|
||||
struct CurvesPoint {
|
||||
int curve_id;
|
||||
int point_id;
|
||||
int curve_segment;
|
||||
|
||||
METAL_CONSTRUCTOR_3(CurvesPoint, int, curve_id, int, point_id, int, curve_segment)
|
||||
};
|
||||
|
||||
struct WorldPoint {
|
||||
int _pad;
|
||||
METAL_CONSTRUCTOR_1(WorldPoint, int, _pad)
|
||||
};
|
||||
|
||||
struct VolumePoint {
|
||||
int _pad; /* TODO(fclem): Add explicit attribute loading for volumes. */
|
||||
METAL_CONSTRUCTOR_1(VolumePoint, int, _pad)
|
||||
};
|
||||
|
||||
struct GPencilPoint {
|
||||
int _pad;
|
||||
METAL_CONSTRUCTOR_1(GPencilPoint, int, _pad)
|
||||
};
|
||||
@@ -11,9 +11,7 @@
|
||||
VERTEX_SHADER_CREATE_INFO(eevee_geom_world)
|
||||
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_reverse_z_lib.glsl"
|
||||
#include "eevee_surf_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ SHADER_LIBRARY_CREATE_INFO(eevee_horizon_scan)
|
||||
|
||||
#include "draw_shape_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_bxdf_lib.glsl"
|
||||
#include "eevee_horizon_scan_lib.glsl"
|
||||
#include "eevee_ray_types_lib.glsl"
|
||||
#include "eevee_sampling_lib.glsl"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
/* This file must replaced at runtime. The following content is only a possible implementation. */
|
||||
#pragma runtime_generated
|
||||
|
||||
#include "eevee_geom_types_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
|
||||
/* Loading of the attributes into GlobalData. */
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gpu_shader_math_vector_reduce_lib.glsl"
|
||||
#include "infos/eevee_common_info.hh"
|
||||
|
||||
SHADER_LIBRARY_CREATE_INFO(eevee_global_ubo)
|
||||
@@ -18,41 +17,9 @@ SHADER_LIBRARY_CREATE_INFO(eevee_utility_texture)
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_base_lib.glsl"
|
||||
#include "gpu_shader_math_safe_lib.glsl"
|
||||
#include "gpu_shader_math_vector_reduce_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
struct MeshVertex {
|
||||
int _pad; /* TODO(fclem): Add explicit attribute loading for mesh. */
|
||||
METAL_CONSTRUCTOR_1(MeshVertex, int, _pad)
|
||||
};
|
||||
|
||||
struct PointCloudPoint {
|
||||
int _pad; /* TODO(fclem): Add explicit attribute loading for mesh. */
|
||||
METAL_CONSTRUCTOR_1(PointCloudPoint, int, _pad)
|
||||
};
|
||||
|
||||
struct CurvesPoint {
|
||||
int curve_id;
|
||||
int point_id;
|
||||
int curve_segment;
|
||||
|
||||
METAL_CONSTRUCTOR_3(CurvesPoint, int, curve_id, int, point_id, int, curve_segment)
|
||||
};
|
||||
|
||||
struct WorldPoint {
|
||||
int _pad;
|
||||
METAL_CONSTRUCTOR_1(WorldPoint, int, _pad)
|
||||
};
|
||||
|
||||
struct VolumePoint {
|
||||
int _pad; /* TODO(fclem): Add explicit attribute loading for volumes. */
|
||||
METAL_CONSTRUCTOR_1(VolumePoint, int, _pad)
|
||||
};
|
||||
|
||||
struct GPencilPoint {
|
||||
int _pad;
|
||||
METAL_CONSTRUCTOR_1(GPencilPoint, int, _pad)
|
||||
};
|
||||
|
||||
packed_float3 g_emission;
|
||||
packed_float3 g_transmittance;
|
||||
float g_holdout;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
/* This file must replaced at runtime. The following content is only a possible implementation. */
|
||||
#pragma runtime_generated
|
||||
|
||||
#include "eevee_geom_types_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
|
||||
/* Loading of the attributes into GlobalData. */
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "draw_math_geom_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_bxdf_lib.glsl" /* Needed for Ray. */
|
||||
#include "gpu_shader_math_matrix_transform_lib.glsl"
|
||||
#include "gpu_shader_math_safe_lib.glsl"
|
||||
#include "gpu_shader_ray_lib.glsl"
|
||||
|
||||
/* Screen-space ray ([0..1] "uv" range) where direction is normalize to be as small as one
|
||||
* full-resolution pixel. The ray is also clipped to all frustum sides.
|
||||
@@ -22,6 +22,7 @@ struct ScreenSpaceRay {
|
||||
};
|
||||
|
||||
void raytrace_screenspace_ray_finalize(inout ScreenSpaceRay ray, float2 pixel_size)
|
||||
|
||||
{
|
||||
/* Constant bias (due to depth buffer precision). Helps with self intersection. */
|
||||
/* Magic numbers for 24bits of precision.
|
||||
|
||||
@@ -19,7 +19,6 @@ FRAGMENT_SHADER_CREATE_INFO(eevee_cryptomatte_out)
|
||||
|
||||
#include "draw_curves_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_ambient_occlusion_lib.glsl"
|
||||
#include "eevee_gbuffer_write_lib.glsl"
|
||||
#include "eevee_nodetree_frag_lib.glsl"
|
||||
#include "eevee_sampling_lib.glsl"
|
||||
|
||||
@@ -15,7 +15,6 @@ FRAGMENT_SHADER_CREATE_INFO(eevee_surf_forward)
|
||||
|
||||
#include "draw_curves_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_ambient_occlusion_lib.glsl"
|
||||
#include "eevee_forward_lib.glsl"
|
||||
#include "eevee_nodetree_frag_lib.glsl"
|
||||
#include "eevee_reverse_z_lib.glsl"
|
||||
|
||||
@@ -19,7 +19,6 @@ FRAGMENT_SHADER_CREATE_INFO(eevee_cryptomatte_out)
|
||||
|
||||
#include "draw_curves_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_ambient_occlusion_lib.glsl"
|
||||
#include "eevee_forward_lib.glsl"
|
||||
#include "eevee_gbuffer_write_lib.glsl"
|
||||
#include "eevee_nodetree_frag_lib.glsl"
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
#include "infos/eevee_material_info.hh"
|
||||
|
||||
SHADER_LIBRARY_CREATE_INFO(eevee_geom_mesh)
|
||||
SHADER_LIBRARY_CREATE_INFO(eevee_global_ubo)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_sampling_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_base_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
#include "gpu_shader_math_vector_safe_lib.glsl"
|
||||
|
||||
#if defined(USE_BARYCENTRICS) && defined(GPU_FRAGMENT_SHADER) && defined(MAT_GEOM_MESH)
|
||||
@@ -86,8 +84,8 @@ void init_globals()
|
||||
g_data.barycentric_dists = float3(0.0f);
|
||||
|
||||
#ifdef GPU_FRAGMENT_SHADER
|
||||
g_data.N = (FrontFacing) ? g_data.N : -g_data.N;
|
||||
g_data.Ni = (FrontFacing) ? g_data.Ni : -g_data.Ni;
|
||||
g_data.N = (gl_FrontFacing) ? g_data.N : -g_data.N;
|
||||
g_data.Ni = (gl_FrontFacing) ? g_data.Ni : -g_data.Ni;
|
||||
g_data.Ng = safe_normalize(cross(gpu_dfdx(g_data.P), gpu_dfdy(g_data.P)));
|
||||
#endif
|
||||
|
||||
|
||||
@@ -35,16 +35,10 @@
|
||||
FRAGMENT_SHADER_CREATE_INFO(eevee_geom_mesh)
|
||||
FRAGMENT_SHADER_CREATE_INFO(eevee_surf_occupancy)
|
||||
|
||||
#include "eevee_nodetree_lib.glsl"
|
||||
#include "eevee_occupancy_lib.glsl"
|
||||
#include "eevee_sampling_lib.glsl"
|
||||
#include "eevee_volume_lib.glsl"
|
||||
|
||||
float4 closure_to_rgba(Closure cl)
|
||||
{
|
||||
return float4(0.0f);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
int2 texel = int2(gl_FragCoord.xy);
|
||||
|
||||
@@ -20,7 +20,6 @@ FRAGMENT_SHADER_CREATE_INFO(eevee_surf_shadow_atomic)
|
||||
# define MAT_SHADOW
|
||||
#endif
|
||||
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_nodetree_frag_lib.glsl"
|
||||
#include "eevee_sampling_lib.glsl"
|
||||
#include "eevee_shadow_tilemap_lib.glsl"
|
||||
@@ -48,7 +47,7 @@ void main()
|
||||
#endif
|
||||
|
||||
/* Clip to light shape. */
|
||||
if (length_squared(shadow_clip.vector) < 1.0f) {
|
||||
if (dot(shadow_clip.vector, shadow_clip.vector) < 1.0f) {
|
||||
discard_result;
|
||||
}
|
||||
|
||||
|
||||
@@ -554,6 +554,7 @@ set(GLSL_SRC
|
||||
shaders/common/gpu_shader_offset_indices_lib.glsl
|
||||
shaders/common/gpu_shader_print_lib.glsl
|
||||
shaders/common/gpu_shader_ray_utils_lib.glsl
|
||||
shaders/common/gpu_shader_ray_lib.glsl
|
||||
shaders/common/gpu_shader_sequencer_lib.glsl
|
||||
shaders/common/gpu_shader_shared_exponent_lib.glsl
|
||||
shaders/common/gpu_shader_smaa_lib.glsl
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "gpu_capabilities_private.hh"
|
||||
#include "gpu_material_library.hh"
|
||||
#include "gpu_shader_create_info.hh"
|
||||
@@ -44,6 +45,8 @@ extern "C" {
|
||||
#undef SHADER_SOURCE
|
||||
}
|
||||
|
||||
static CLG_LogRef LOG = {"gpu.shader_dependencies"};
|
||||
|
||||
namespace blender::gpu {
|
||||
|
||||
using GPUPrintFormatMap = Map<uint32_t, shader::PrintfFormat>;
|
||||
@@ -330,10 +333,6 @@ struct GPUSource {
|
||||
if (result != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (auto *dep : dependency_source->dependencies) {
|
||||
dependencies.append_non_duplicates(dep);
|
||||
}
|
||||
dependencies.append_non_duplicates(dependency_source);
|
||||
}
|
||||
dependencies_names.clear();
|
||||
@@ -342,19 +341,41 @@ struct GPUSource {
|
||||
|
||||
void source_get(Vector<StringRefNull> &result,
|
||||
const shader::GeneratedSourceList &generated_sources,
|
||||
const GPUSourceDictionary &dict) const
|
||||
const GPUSourceDictionary &dict,
|
||||
const GPUSource &from) const
|
||||
{
|
||||
#define CLOG_FILE_INCLUDE(_from, _include) \
|
||||
if ((from).filename.c_str() != (_include).filename.c_str()) { \
|
||||
const char *from_filename = (_from).filename.c_str(); \
|
||||
const char *include_filename = (_include).filename.c_str(); \
|
||||
const int from_size = int((_from).source.size()); \
|
||||
const int include_size = int((_include).source.size()); \
|
||||
CLOG_INFO(&LOG, "%s_%d --> %s_%d", from_filename, from_size, include_filename, include_size); \
|
||||
CLOG_INFO(&LOG, \
|
||||
"style %s_%d fill:#%x%x0", \
|
||||
include_filename, \
|
||||
include_size, \
|
||||
min_uu(15, include_size / 1000), \
|
||||
15 - min_uu(15, include_size / 1000)); \
|
||||
}
|
||||
|
||||
/* Check if this file was already included. */
|
||||
for (const StringRefNull &source_content : result) {
|
||||
/* Yes, compare pointer instead of string for speed.
|
||||
* Each source is guaranteed to be unique and non-moving during the building process. */
|
||||
if (source_content.c_str() == this->source.c_str()) {
|
||||
/* Already included. */
|
||||
CLOG_FILE_INCLUDE(from, *this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bool(this->builtins & shader::BuiltinBits::RUNTIME_GENERATED)) {
|
||||
for (const auto &dependency : this->dependencies) {
|
||||
/* WATCH: Recursive. */
|
||||
dependency->source_get(result, generated_sources, dict, *this);
|
||||
}
|
||||
CLOG_FILE_INCLUDE(from, *this);
|
||||
result.append(this->source);
|
||||
return;
|
||||
}
|
||||
@@ -364,7 +385,7 @@ struct GPUSource {
|
||||
for (const shader::GeneratedSource &generated_src : generated_sources) {
|
||||
if (generated_src.filename == this->filename) {
|
||||
/* Include dependencies before the generated file. */
|
||||
for (auto dependency_name : generated_src.dependencies) {
|
||||
for (const auto &dependency_name : generated_src.dependencies) {
|
||||
BLI_assert_msg(dependency_name != this->filename, "Recursive include");
|
||||
|
||||
GPUSource *dependency_source = dict.lookup_default(dependency_name, nullptr);
|
||||
@@ -373,9 +394,10 @@ struct GPUSource {
|
||||
std::cerr << "Generated dependency not found : " + dependency_name << std::endl;
|
||||
return;
|
||||
}
|
||||
dependency_source->build(result, generated_sources, dict);
|
||||
/* WATCH: Recursive. */
|
||||
dependency_source->source_get(result, generated_sources, dict, *this);
|
||||
}
|
||||
|
||||
CLOG_FILE_INCLUDE(from, *this);
|
||||
result.append(generated_src.content);
|
||||
return;
|
||||
}
|
||||
@@ -383,6 +405,13 @@ struct GPUSource {
|
||||
|
||||
std::cerr << "warn: Generated source not provided. Using fallback for : " << this->filename
|
||||
<< std::endl;
|
||||
/* Dependencies for generated sources are not folded on startup.
|
||||
* This allows for different set of dependencies at runtime. */
|
||||
for (const auto &dependency : this->dependencies) {
|
||||
/* WATCH: Recursive. */
|
||||
dependency->source_get(result, generated_sources, dict, *this);
|
||||
}
|
||||
CLOG_FILE_INCLUDE(from, *this);
|
||||
result.append(this->source);
|
||||
}
|
||||
|
||||
@@ -391,17 +420,14 @@ struct GPUSource {
|
||||
const shader::GeneratedSourceList &generated_sources,
|
||||
const GPUSourceDictionary &dict) const
|
||||
{
|
||||
for (auto *dep : dependencies) {
|
||||
dep->source_get(result, generated_sources, dict);
|
||||
}
|
||||
source_get(result, generated_sources, dict);
|
||||
source_get(result, generated_sources, dict, *this);
|
||||
}
|
||||
|
||||
shader::BuiltinBits builtins_get() const
|
||||
{
|
||||
shader::BuiltinBits out_builtins = builtins;
|
||||
for (auto *dep : dependencies) {
|
||||
out_builtins |= dep->builtins;
|
||||
out_builtins |= dep->builtins_get();
|
||||
}
|
||||
return out_builtins;
|
||||
}
|
||||
@@ -567,7 +593,10 @@ Vector<StringRefNull> gpu_shader_dependency_get_resolved_source(
|
||||
if (src == nullptr) {
|
||||
std::cerr << "Error source not found : " << shader_source_name << std::endl;
|
||||
}
|
||||
CLOG_INFO(&LOG, "Resolved Source Tree (Mermaid flowchart)");
|
||||
CLOG_INFO(&LOG, "flowchart LR");
|
||||
src->build(result, generated_sources, *g_sources);
|
||||
CLOG_INFO(&LOG, " ");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
14
source/blender/gpu/shaders/common/gpu_shader_ray_lib.glsl
Normal file
14
source/blender/gpu/shaders/common/gpu_shader_ray_lib.glsl
Normal file
@@ -0,0 +1,14 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gpu_shader_compat.hh"
|
||||
|
||||
/* General purpose 3D ray. */
|
||||
struct Ray {
|
||||
packed_float3 direction;
|
||||
float max_time;
|
||||
packed_float3 origin;
|
||||
};
|
||||
@@ -12,7 +12,7 @@
|
||||
/* This file must replaced at runtime. The following content is only a possible implementation. */
|
||||
#pragma runtime_generated
|
||||
|
||||
#include "gpu_shader_compat_cxx.hh"
|
||||
#include "gpu_shader_compat_cxx.hh" // IWYU pragma: export
|
||||
/* Other possible implementation. */
|
||||
// #include "gpu_shader_compat_glsl.hh"
|
||||
// #include "gpu_shader_compat_msl.hh"
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gpu_shader_cxx_builtin.hh"
|
||||
#include "gpu_shader_cxx_global.hh"
|
||||
#include "gpu_shader_cxx_image.hh"
|
||||
#include "gpu_shader_cxx_matrix.hh"
|
||||
#include "gpu_shader_cxx_sampler.hh"
|
||||
#include "gpu_shader_cxx_vector.hh"
|
||||
#include "gpu_shader_cxx_builtin.hh" // IWYU pragma: export
|
||||
#include "gpu_shader_cxx_global.hh" // IWYU pragma: export
|
||||
#include "gpu_shader_cxx_image.hh" // IWYU pragma: export
|
||||
#include "gpu_shader_cxx_matrix.hh" // IWYU pragma: export
|
||||
#include "gpu_shader_cxx_sampler.hh" // IWYU pragma: export
|
||||
#include "gpu_shader_cxx_vector.hh" // IWYU pragma: export
|
||||
|
||||
#define assert(assertion)
|
||||
#define printf(...)
|
||||
|
||||
Reference in New Issue
Block a user