[Bf-blender-cvs] [26beaa2d901] master: Cleanup: Eevee: Use SET_FLAG_FROM_TEST

Clément Foucault noreply at git.blender.org
Fri May 17 13:38:51 CEST 2019


Commit: 26beaa2d901004cdba4b3811e353929a49c18a87
Author: Clément Foucault
Date:   Thu May 16 14:12:32 2019 +0200
Branches: master
https://developer.blender.org/rB26beaa2d901004cdba4b3811e353929a49c18a87

Cleanup: Eevee: Use SET_FLAG_FROM_TEST

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

M	source/blender/draw/engines/eevee/eevee_materials.c
M	source/blender/gpu/intern/gpu_material.c

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

diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index c6b228c29d3..79987bba6d1 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -751,27 +751,14 @@ struct GPUMaterial *EEVEE_material_mesh_get(struct Scene *scene,
   const void *engine = &DRW_engine_viewport_eevee_type;
   int options = VAR_MAT_MESH;
 
-  if (use_blend) {
-    options |= VAR_MAT_BLEND;
-  }
-  if (use_multiply) {
-    options |= VAR_MAT_MULT;
-  }
-  if (use_refract) {
-    options |= VAR_MAT_REFRACT;
-  }
-  if (use_sss) {
-    options |= VAR_MAT_SSS;
-  }
-  if (use_sss && effects->sss_separate_albedo) {
-    options |= VAR_MAT_SSSALBED;
-  }
-  if (use_translucency) {
-    options |= VAR_MAT_TRANSLUC;
-  }
-  if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) {
-    options |= VAR_MAT_VOLUME;
-  }
+  SET_FLAG_FROM_TEST(options, use_blend, VAR_MAT_BLEND);
+  SET_FLAG_FROM_TEST(options, use_multiply, VAR_MAT_MULT);
+  SET_FLAG_FROM_TEST(options, use_refract, VAR_MAT_REFRACT);
+  SET_FLAG_FROM_TEST(options, use_sss, VAR_MAT_SSS);
+  SET_FLAG_FROM_TEST(options, use_sss && effects->sss_separate_albedo, VAR_MAT_SSSALBED);
+  SET_FLAG_FROM_TEST(options, use_translucency, VAR_MAT_TRANSLUC);
+  SET_FLAG_FROM_TEST(
+      options, ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend, VAR_MAT_VOLUME);
 
   options |= eevee_material_shadow_option(shadow_method);
 
@@ -832,16 +819,9 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get(struct Scene *scene,
   const void *engine = &DRW_engine_viewport_eevee_type;
   int options = VAR_MAT_MESH;
 
-  if (use_hashed_alpha) {
-    options |= VAR_MAT_HASH;
-  }
-  else {
-    options |= VAR_MAT_CLIP;
-  }
-
-  if (is_shadow) {
-    options |= VAR_MAT_SHADOW;
-  }
+  SET_FLAG_FROM_TEST(options, use_hashed_alpha, VAR_MAT_HASH);
+  SET_FLAG_FROM_TEST(options, !use_hashed_alpha, VAR_MAT_CLIP);
+  SET_FLAG_FROM_TEST(options, is_shadow, VAR_MAT_SHADOW);
 
   GPUMaterial *mat = DRW_shader_find_from_material(ma, engine, options, true);
   if (mat) {
@@ -914,15 +894,10 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(EEVEE_ViewLaye
   ssr_id = (use_ssr) ? 1 : -1;
   int options = VAR_MAT_MESH;
 
-  if (is_hair) {
-    options |= VAR_MAT_HAIR;
-  }
-  if (use_blend) {
-    options |= VAR_MAT_BLEND;
-  }
-  if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) {
-    options |= VAR_MAT_VOLUME;
-  }
+  SET_FLAG_FROM_TEST(options, is_hair, VAR_MAT_HAIR);
+  SET_FLAG_FROM_TEST(options, use_blend, VAR_MAT_BLEND);
+  SET_FLAG_FROM_TEST(
+      options, ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend, VAR_MAT_VOLUME);
 
   options |= eevee_material_shadow_option(shadow_method);
 
@@ -954,9 +929,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(EEVEE_ViewLayerDa
 
   BLI_assert(!is_hair || (ob && psys && md));
 
-  if (is_hair) {
-    options |= VAR_MAT_HAIR;
-  }
+  SET_FLAG_FROM_TEST(options, is_hair, VAR_MAT_HAIR);
 
   options |= eevee_material_shadow_option(shadow_method);
 
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index de9ed56abf5..4f90155b88c 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -678,12 +678,8 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
 
   gpu_material_ramp_texture_build(mat);
 
-  if (has_surface_output) {
-    mat->domain |= GPU_DOMAIN_SURFACE;
-  }
-  if (has_volume_output) {
-    mat->domain |= GPU_DOMAIN_VOLUME;
-  }
+  SET_FLAG_FROM_TEST(mat->domain, has_surface_output, GPU_DOMAIN_SURFACE);
+  SET_FLAG_FROM_TEST(mat->domain, has_volume_output, GPU_DOMAIN_VOLUME);
 
   if (mat->outlink) {
     /* Prune the unused nodes and extract attributes before compiling so the



More information about the Bf-blender-cvs mailing list