Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. From 5984831966cf28ce7dd2693f0564e74105834609 Mon Sep 17 00:00:00 2001
  2. From: Robert Bragg <robert@linux.intel.com>
  3. Date: Mon, 1 Nov 2010 20:33:20 +0000
  4. Subject: [PATCH] pipeline: Avoid costly checking of lighting properties
  5.  
  6. During _cogl_pipeline_needs_blending_enabled we were always checking the
  7. current lighting properties (ambient,diffuse,specular,emission) which
  8. had a notable impact during micro-benchmarks that exercise journal
  9. throughput of simple colored rectangles. This #if 0's the offending code
  10. considering that Cogl doesn't actually support lighting currently and
  11. when it actually does then we will be able to optimize this by avoiding
  12. the checks when lighting is disabled.
  13. ---
  14. clutter/cogl/cogl/cogl-pipeline.c | 42 +++++++++++++++++++++---------------
  15. 1 files changed, 24 insertions(+), 18 deletions(-)
  16.  
  17. diff --git a/clutter/cogl/cogl/cogl-pipeline.c b/clutter/cogl/cogl/cogl-pipeline.c
  18. index bde53f1..ce2c143 100644
  19. --- a/clutter/cogl/cogl/cogl-pipeline.c
  20. +++ b/clutter/cogl/cogl/cogl-pipeline.c
  21. @@ -864,9 +864,6 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
  22. if (changes & COGL_PIPELINE_STATE_LAYERS)
  23. changes = COGL_PIPELINE_STATE_AFFECTS_BLENDING;
  24.  
  25. - /* XXX: we don't currently handle specific changes in an optimal way*/
  26. - changes = COGL_PIPELINE_STATE_AFFECTS_BLENDING;
  27. -
  28. if ((override_color && cogl_color_get_alpha_byte (override_color) != 0xff))
  29. return TRUE;
  30.  
  31. @@ -878,13 +875,13 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
  32. return TRUE;
  33. }
  34.  
  35. - /* We can't make any assumptions about the alpha channel if the user
  36. - * is using an unknown fragment shader.
  37. - *
  38. - * TODO: check that it isn't just a vertex shader!
  39. - */
  40. if (changes & COGL_PIPELINE_STATE_USER_SHADER)
  41. {
  42. + /* We can't make any assumptions about the alpha channel if the user
  43. + * is using an unknown fragment shader.
  44. + *
  45. + * TODO: check that it isn't just a vertex shader!
  46. + */
  47. if (_cogl_pipeline_get_user_program (pipeline) != COGL_INVALID_HANDLE)
  48. return TRUE;
  49. }
  50. @@ -893,8 +890,13 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
  51. */
  52. if (changes & COGL_PIPELINE_STATE_LIGHTING)
  53. {
  54. + /* XXX: This stuff is showing up in sysprof reports which is
  55. + * silly because lighting isn't currently actually supported
  56. + * by Cogl except for these token properties. When we actually
  57. + * expose lighting support we can avoid these checks when
  58. + * lighting is disabled. */
  59. +#if 0
  60. CoglColor tmp;
  61. -
  62. cogl_pipeline_get_ambient (pipeline, &tmp);
  63. if (cogl_color_get_alpha_byte (&tmp) != 0xff)
  64. return TRUE;
  65. @@ -907,6 +909,7 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
  66. cogl_pipeline_get_emission (pipeline, &tmp);
  67. if (cogl_color_get_alpha_byte (&tmp) != 0xff)
  68. return TRUE;
  69. +#endif
  70. }
  71.  
  72. if (changes & COGL_PIPELINE_STATE_LAYERS)
  73. @@ -921,15 +924,18 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
  74. if (has_alpha)
  75. return TRUE;
  76. }
  77. -
  78. - /* So far we have only checked the property that has been changed so
  79. - * we now need to check all the other properties too. */
  80. - other_state = COGL_PIPELINE_STATE_AFFECTS_BLENDING & ~changes;
  81. - if (other_state &&
  82. - _cogl_pipeline_needs_blending_enabled (pipeline,
  83. - other_state,
  84. - NULL))
  85. - return TRUE;
  86. + else
  87. + {
  88. + /* In this case we have so far only checked the property that
  89. + * has been changed so we now need to check all the other
  90. + * properties too. */
  91. + other_state = COGL_PIPELINE_STATE_AFFECTS_BLENDING & ~changes;
  92. + if (other_state &&
  93. + _cogl_pipeline_needs_blending_enabled (pipeline,
  94. + other_state,
  95. + NULL))
  96. + return TRUE;
  97. + }
  98.  
  99. return FALSE;
  100. }
  101. --
  102. 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement