[Bf-blender-cvs] [8f6f28a0dc0] master: GPU: Move common shaders into a common directory

Omar Emara noreply at git.blender.org
Fri May 6 12:59:16 CEST 2022


Commit: 8f6f28a0dc0ad7697863e4dcd78e85f87f9fb8db
Author: Omar Emara
Date:   Fri May 6 12:58:14 2022 +0200
Branches: master
https://developer.blender.org/rB8f6f28a0dc0ad7697863e4dcd78e85f87f9fb8db

GPU: Move common shaders into a common directory

This patch moves some of the utility library shaders into a common
directory and makes the necessary renames across shaders. Additionally,
material-specific transform functions were moved outside of math utils
into a separate transform_utils.glsl file.

This is needed in preparation for the viewport compositor, which will
make use of some of those utilities and will require all material
specific bit to be removed out of those files.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D14688

===================================================================

M	source/blender/gpu/CMakeLists.txt
M	source/blender/gpu/intern/gpu_shader_dependency.cc
R100	source/blender/gpu/shaders/material/gpu_shader_material_color_ramp.glsl	source/blender/gpu/shaders/common/gpu_shader_common_color_ramp.glsl
R100	source/blender/gpu/shaders/material/gpu_shader_material_color_util.glsl	source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl
R100	source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl	source/blender/gpu/shaders/common/gpu_shader_common_hash.glsl
R098	source/blender/gpu/shaders/material/gpu_shader_material_math.glsl	source/blender/gpu/shaders/common/gpu_shader_common_math.glsl
R061	source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl	source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl
R098	source/blender/gpu/shaders/material/gpu_shader_material_mix_rgb.glsl	source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_combine_color.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_combine_hsv.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_gamma.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_hue_sat_val.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_map_range.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_mapping.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_point_info.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_separate_color.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_separate_hsv.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_brick.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_environment.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_musgrave.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_noise.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_voronoi.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_wave.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_white_noise.glsl
A	source/blender/gpu/shaders/material/gpu_shader_material_transform_utils.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_vector_math.glsl
M	source/blender/gpu/shaders/material/gpu_shader_material_vector_rotate.glsl

===================================================================

diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 1e54d5fb7ee..dc542411596 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -303,6 +303,13 @@ set(GLSL_SRC
 
   shaders/gpu_shader_geometry.glsl
 
+  shaders/common/gpu_shader_common_color_ramp.glsl
+  shaders/common/gpu_shader_common_color_utils.glsl
+  shaders/common/gpu_shader_common_hash.glsl
+  shaders/common/gpu_shader_common_math.glsl
+  shaders/common/gpu_shader_common_math_utils.glsl
+  shaders/common/gpu_shader_common_mix_rgb.glsl
+
   shaders/material/gpu_shader_material_add_shader.glsl
   shaders/material/gpu_shader_material_ambient_occlusion.glsl
   shaders/material/gpu_shader_material_anisotropic.glsl
@@ -315,8 +322,6 @@ set(GLSL_SRC
   shaders/material/gpu_shader_material_bump.glsl
   shaders/material/gpu_shader_material_camera.glsl
   shaders/material/gpu_shader_material_clamp.glsl
-  shaders/material/gpu_shader_material_color_ramp.glsl
-  shaders/material/gpu_shader_material_color_util.glsl
   shaders/material/gpu_shader_material_combine_color.glsl
   shaders/material/gpu_shader_material_combine_hsv.glsl
   shaders/material/gpu_shader_material_combine_rgb.glsl
@@ -334,7 +339,6 @@ set(GLSL_SRC
   shaders/material/gpu_shader_material_glossy.glsl
   shaders/material/gpu_shader_material_hair_info.glsl
   shaders/material/gpu_shader_material_hair.glsl
-  shaders/material/gpu_shader_material_hash.glsl
   shaders/material/gpu_shader_material_holdout.glsl
   shaders/material/gpu_shader_material_hue_sat_val.glsl
   shaders/material/gpu_shader_material_invert.glsl
@@ -343,9 +347,6 @@ set(GLSL_SRC
   shaders/material/gpu_shader_material_light_path.glsl
   shaders/material/gpu_shader_material_mapping.glsl
   shaders/material/gpu_shader_material_map_range.glsl
-  shaders/material/gpu_shader_material_math.glsl
-  shaders/material/gpu_shader_material_math_util.glsl
-  shaders/material/gpu_shader_material_mix_rgb.glsl
   shaders/material/gpu_shader_material_mix_shader.glsl
   shaders/material/gpu_shader_material_noise.glsl
   shaders/material/gpu_shader_material_normal.glsl
@@ -383,6 +384,7 @@ set(GLSL_SRC
   shaders/material/gpu_shader_material_tex_wave.glsl
   shaders/material/gpu_shader_material_tex_white_noise.glsl
   shaders/material/gpu_shader_material_toon.glsl
+  shaders/material/gpu_shader_material_transform_utils.glsl
   shaders/material/gpu_shader_material_translucent.glsl
   shaders/material/gpu_shader_material_transparent.glsl
   shaders/material/gpu_shader_material_uv_map.glsl
diff --git a/source/blender/gpu/intern/gpu_shader_dependency.cc b/source/blender/gpu/intern/gpu_shader_dependency.cc
index 460b6d32967..eb2d40f5da9 100644
--- a/source/blender/gpu/intern/gpu_shader_dependency.cc
+++ b/source/blender/gpu/intern/gpu_shader_dependency.cc
@@ -549,7 +549,9 @@ struct GPUSource {
 
   bool is_from_material_library() const
   {
-    return filename.startswith("gpu_shader_material_") && filename.endswith(".glsl");
+    return (filename.startswith("gpu_shader_material_") ||
+            filename.startswith("gpu_shader_common_")) &&
+           filename.endswith(".glsl");
   }
 };
 
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_color_ramp.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_color_ramp.glsl
similarity index 100%
rename from source/blender/gpu/shaders/material/gpu_shader_material_color_ramp.glsl
rename to source/blender/gpu/shaders/common/gpu_shader_common_color_ramp.glsl
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_color_util.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl
similarity index 100%
rename from source/blender/gpu/shaders/material/gpu_shader_material_color_util.glsl
rename to source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_hash.glsl
similarity index 100%
rename from source/blender/gpu/shaders/material/gpu_shader_material_hash.glsl
rename to source/blender/gpu/shaders/common/gpu_shader_common_hash.glsl
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_math.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_math.glsl
similarity index 98%
rename from source/blender/gpu/shaders/material/gpu_shader_material_math.glsl
rename to source/blender/gpu/shaders/common/gpu_shader_common_math.glsl
index 0948ce2c9fa..5f640f64056 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_math.glsl
+++ b/source/blender/gpu/shaders/common/gpu_shader_common_math.glsl
@@ -1,4 +1,4 @@
-#pragma BLENDER_REQUIRE(gpu_shader_material_math_util.glsl)
+#pragma BLENDER_REQUIRE(gpu_shader_common_math_utils.glsl)
 
 void math_add(float a, float b, float c, out float result)
 {
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl
similarity index 61%
rename from source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl
rename to source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl
index 91a8996939a..124654963fd 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl
+++ b/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl
@@ -139,75 +139,3 @@ mat3 euler_to_mat3(vec3 euler)
   mat[2][2] = cy * cx;
   return mat;
 }
-
-void normal_transform_object_to_world(vec3 vin, out vec3 vout)
-{
-  vout = normal_object_to_world(vin);
-}
-
-void normal_transform_world_to_object(vec3 vin, out vec3 vout)
-{
-  vout = normal_world_to_object(vin);
-}
-
-void direction_transform_object_to_world(vec3 vin, out vec3 vout)
-{
-  vout = transform_direction(ModelMatrix, vin);
-}
-
-void direction_transform_object_to_view(vec3 vin, out vec3 vout)
-{
-  vout = transform_direction(ModelMatrix, vin);
-  vout = transform_direction(ViewMatrix, vout);
-}
-
-void direction_transform_view_to_world(vec3 vin, out vec3 vout)
-{
-  vout = transform_direction(ViewMatrixInverse, vin);
-}
-
-void direction_transform_view_to_object(vec3 vin, out vec3 vout)
-{
-  vout = transform_direction(ViewMatrixInverse, vin);
-  vout = transform_direction(ModelMatrixInverse, vout);
-}
-
-void direction_transform_world_to_view(vec3 vin, out vec3 vout)
-{
-  vout = transform_direction(ViewMatrix, vin);
-}
-
-void direction_transform_world_to_object(vec3 vin, out vec3 vout)
-{
-  vout = transform_direction(ModelMatrixInverse, vin);
-}
-
-void point_transform_object_to_world(vec3 vin, out vec3 vout)
-{
-  vout = point_object_to_world(vin);
-}
-
-void point_transform_object_to_view(vec3 vin, out vec3 vout)
-{
-  vout = point_object_to_view(vin);
-}
-
-void point_transform_view_to_world(vec3 vin, out vec3 vout)
-{
-  vout = point_view_to_world(vin);
-}
-
-void point_transform_view_to_object(vec3 vin, out vec3 vout)
-{
-  vout = point_view_to_object(vin);
-}
-
-void point_transform_world_to_view(vec3 vin, out vec3 vout)
-{
-  vout = point_world_to_view(vin);
-}
-
-void point_transform_world_to_object(vec3 vin, out vec3 vout)
-{
-  vout = point_world_to_object(vin);
-}
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_mix_rgb.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl
similarity index 98%
rename from source/blender/gpu/shaders/material/gpu_shader_material_mix_rgb.glsl
rename to source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl
index 157a6a27c15..f9652f1150b 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_mix_rgb.glsl
+++ b/source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl
@@ -1,4 +1,4 @@
-#pragma BLENDER_REQUIRE(gpu_shader_material_color_util.glsl)
+#pragma BLENDER_REQUIRE(gpu_shader_common_color_utils.glsl)
 
 void mix_blend(float fac, vec4 col1, vec4 col2, out vec4 outcol)
 {
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_combine_color.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_combine_color.glsl
index 3a250fcae8b..e68d0d98484 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_combine_color.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_combine_color.glsl
@@ -1,4 +1,4 @@
-#pragma BLENDER_REQUIRE(gpu_shader_material_color_util.glsl)
+#pragma BLENDER_REQUIRE(gpu_shader_common_color_utils.glsl)
 
 void combine_color_rgb(float r, float g, float b, out vec4 col)
 {
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_combine_hsv.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_combine_hsv.glsl
index e8f444080b9..4d9e16afe66 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_combine_hsv.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_combine_hsv.glsl
@@ -1,4 +1,4 @@
-#pragma BLENDER_REQUIRE(gpu_shader_material_color_util.glsl)
+#pragma BLENDER_REQUIRE(gpu_shader_common_color_utils.glsl)
 
 void combine_hsv(float h, float s, float v, out vec4 col)
 {
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl
index 7f502f74c0c..6d52e97cca1 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl
@@ -1,4 +1,4 @@
-#pragma BLENDER_REQUIRE(gpu_shader_material_hash.glsl)
+#pragma BLENDER_REQUIRE(gpu_shader_common_hash.glsl)
 #pragma BLENDER_REQUIRE(gpu_shader_material_noise.glsl)
 
 /* The fractal_noise functions are all exactly the same except for the input type. */
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_gamma.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_gamma.glsl
index 29fb09ceebd..64681cd795a 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_gamma.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_gamma.glsl
@@ -1,4 +1,4 @@
-#pragma BLENDER_REQUIRE(gpu_shader_material_math_util.glsl)
+#pragma BLENDER_REQUIRE(gpu_shader_common_math_utils.glsl)
 
 void node_gamma(vec4 col, float gamma, out vec4 outcol)
 {
diff --

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list