Bug 1594128 - Work around Mac GLSL compiler bug. r=kvark
authorNicolas Silva <nsilva@mozilla.com>
Wed, 27 Nov 2019 15:14:58 +0000
changeset 504195 1bcbb2e808a7ff611a33bc336bc3f2a8a514f2f8
parent 504194 576d4b85b28bdfe0f4f8b3f62c148bb517e6dd3f
child 504196 2b00d840a1fd96b7c4963e73eb2304c2b8a8eca0
push id36858
push usercbrindusan@mozilla.com
push dateThu, 28 Nov 2019 16:06:38 +0000
treeherdermozilla-central@6a3ca2b832f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1594128
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1594128 - Work around Mac GLSL compiler bug. r=kvark See https://github.com/servo/webrender/wiki/Driver-issues#bug-1594128---glsl-on-macos-is-confused-by-a-function-that-just-returns-a-constant Differential Revision: https://phabricator.services.mozilla.com/D54691
gfx/wr/webrender/res/brush.glsl
--- a/gfx/wr/webrender/res/brush.glsl
+++ b/gfx/wr/webrender/res/brush.glsl
@@ -110,38 +110,42 @@ void multi_brush_vs(
 #define BRUSH_FLAG_PERSPECTIVE_INTERPOLATION    1
 #define BRUSH_FLAG_SEGMENT_RELATIVE             2
 #define BRUSH_FLAG_SEGMENT_REPEAT_X             4
 #define BRUSH_FLAG_SEGMENT_REPEAT_Y             8
 #define BRUSH_FLAG_TEXEL_RECT                  16
 
 #define INVALID_SEGMENT_INDEX                   0xffff
 
-#ifndef WR_FEATURE_MULTI_BRUSH
-int vecs_per_brush(int brush_kind) {
-    return VECS_PER_SPECIFIC_BRUSH;
-}
-#endif
-
 void main(void) {
     // Load the brush instance from vertex attributes.
     Instance instance = decode_instance_attributes();
     int edge_flags = (instance.flags >> 16) & 0xff;
     int brush_flags = (instance.flags >> 24) & 0xff;
     PrimitiveHeader ph = fetch_prim_header(instance.prim_header_address);
 
     // Fetch the segment of this brush primitive we are drawing.
     vec4 segment_data;
     RectWithSize segment_rect;
     if (instance.segment_index == INVALID_SEGMENT_INDEX) {
         segment_rect = ph.local_rect;
         segment_data = vec4(0.0);
     } else {
+        // This contraption is needed by the Mac GLSL compiler which falls
+        // over (generating garbage values) if:
+        // - we use a variable insead of the ACTUAL_VECS_PER_BRUSH define,
+        // - this compile time condition is done inside of vecs_per_brush.
+        #ifdef WR_FEATURE_MULTI_BRUSH
+        #define ACTUAL_VECS_PER_BRUSH vecs_per_brush(instance.brush_kind)
+        #else
+        #define ACTUAL_VECS_PER_BRUSH VECS_PER_SPECIFIC_BRUSH
+        #endif
+
         int segment_address = ph.specific_prim_address +
-                              vecs_per_brush(instance.brush_kind) +
+                              ACTUAL_VECS_PER_BRUSH +
                               instance.segment_index * VECS_PER_SEGMENT;
 
         vec4[2] segment_info = fetch_from_gpu_cache_2(segment_address);
         segment_rect = RectWithSize(segment_info[0].xy, segment_info[0].zw);
         segment_rect.p0 += ph.local_rect.p0;
         segment_data = segment_info[1];
     }