Bug 1594128 - Don't rely on high bits to store the brush_kind varying. r=gw
authorNicolas Silva <nsilva@mozilla.com>
Tue, 26 Nov 2019 15:32:21 +0000
changeset 503861 a8ee6dbf146b0d1ef4d3348539d1ad439f18a26c
parent 503860 beeeb1889588204a7865327c4e2bf7710b17a938
child 503862 39f51911efa8fc0969cd32fd0c4f2ef5d1651ae5
push id36849
push userdvarga@mozilla.com
push dateTue, 26 Nov 2019 21:27:08 +0000
treeherdermozilla-central@bcbb45f7d4f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
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 - Don't rely on high bits to store the brush_kind varying. r=gw In GLES the default precision for ints is only 16 bits in the fragment shader. Differential Revision: https://phabricator.services.mozilla.com/D54000
gfx/wr/webrender/res/brush_multi.glsl
gfx/wr/webrender/res/prim_shared.glsl
gfx/wr/webrender/src/gpu_types.rs
--- a/gfx/wr/webrender/res/brush_multi.glsl
+++ b/gfx/wr/webrender/res/brush_multi.glsl
@@ -8,24 +8,24 @@
 // provide opportunities for aggressive batching when the number of draw
 // calls so high that reducing the number of draw calls is worth the
 // cost of this "├╝ber-shader".
 
 
 #define WR_FEATURE_MULTI_BRUSH
 
 // These constants must match the BrushShaderKind enum in gpu_types.rs.
-#define BRUSH_KIND_SOLID            0x1000000
-#define BRUSH_KIND_IMAGE            0x2000000
-#define BRUSH_KIND_TEXT             0x3000000
-#define BRUSH_KIND_LINEAR_GRADIENT  0x4000000
-#define BRUSH_KIND_RADIAL_GRADIENT  0x5000000
-#define BRUSH_KIND_BLEND            0x6000000
-#define BRUSH_KIND_MIX_BLEND        0x7000000
-#define BRUSH_KIND_YV               0x8000000
+#define BRUSH_KIND_SOLID            1
+#define BRUSH_KIND_IMAGE            2
+#define BRUSH_KIND_TEXT             3
+#define BRUSH_KIND_LINEAR_GRADIENT  4
+#define BRUSH_KIND_RADIAL_GRADIENT  5
+#define BRUSH_KIND_BLEND            6
+#define BRUSH_KIND_MIX_BLEND        7
+#define BRUSH_KIND_YV               8
 
 int vecs_per_brush(int brush_kind);
 
 #include shared,prim_shared,brush
 
 #ifdef WR_FEATURE_IMAGE_BRUSH
 #include brush_image
 #endif
--- a/gfx/wr/webrender/res/prim_shared.glsl
+++ b/gfx/wr/webrender/res/prim_shared.glsl
@@ -65,17 +65,17 @@ Instance decode_instance_attributes() {
     Instance instance;
 
     instance.prim_header_address = aData.x;
     instance.picture_task_address = aData.y >> 16;
     instance.clip_address = aData.y & 0xffff;
     instance.segment_index = aData.z & 0xffff;
     instance.flags = aData.z & 0xffff0000;
     instance.resource_address = aData.w & 0xffffff;
-    instance.brush_kind = aData.w & 0xff000000;
+    instance.brush_kind = aData.w >> 24;
 
     return instance;
 }
 
 struct PrimitiveHeader {
     RectWithSize local_rect;
     RectWithSize local_clip_rect;
     float z;
--- a/gfx/wr/webrender/src/gpu_types.rs
+++ b/gfx/wr/webrender/src/gpu_types.rs
@@ -67,25 +67,25 @@ impl ZBufferIdGenerator {
 ///
 /// Not all brush kinds need to be present in this enum, only those we want to support in the generic
 /// brush shader.
 /// Do not use the 24 lowest bits. This will be packed with other information in the vertex attributes.
 /// The constants must match the corresponding defines in brush_multi.glsl.
 #[repr(i32)]
 #[derive(Copy, Clone, Debug, PartialEq)]
 pub enum BrushShaderKind {
-    None = 0,
-    Solid           = 0x1000000,
-    Image           = 0x2000000,
-    Text            = 0x3000000,
-    LinearGradient  = 0x4000000,
-    RadialGradient  = 0x5000000,
-    Blend           = 0x6000000,
-    MixBlend        = 0x7000000,
-    Yuv             = 0x8000000,
+    None            = 0,
+    Solid           = 1,
+    Image           = 2,
+    Text            = 3,
+    LinearGradient  = 4,
+    RadialGradient  = 5,
+    Blend           = 6,
+    MixBlend        = 7,
+    Yuv             = 8,
 }
 
 #[derive(Debug, Copy, Clone)]
 #[cfg_attr(feature = "capture", derive(Serialize))]
 #[cfg_attr(feature = "replay", derive(Deserialize))]
 #[repr(C)]
 pub enum RasterizationSpace {
     Local = 0,
@@ -363,17 +363,17 @@ impl GlyphInstance {
     //           header since they are constant, and some can be
     //           compressed to a smaller size.
     pub fn build(&self, data0: i32, data1: i32, resource_address: i32) -> PrimitiveInstanceData {
         PrimitiveInstanceData {
             data: [
                 self.prim_header_index.0 as i32,
                 data0,
                 data1,
-                resource_address | BrushShaderKind::Text as i32,
+                resource_address | ((BrushShaderKind::Text as i32) << 24),
             ],
         }
     }
 }
 
 pub struct SplitCompositeInstance {
     pub prim_header_index: PrimitiveHeaderIndex,
     pub polygons_address: GpuCacheAddress,
@@ -433,17 +433,17 @@ impl From<BrushInstance> for PrimitiveIn
             data: [
                 instance.prim_header_index.0,
                 ((instance.render_task_address.0 as i32) << 16)
                 | instance.clip_task_address.0 as i32,
                 instance.segment_index
                 | ((instance.edge_flags.bits() as i32) << 16)
                 | ((instance.brush_flags.bits() as i32) << 24),
                 instance.resource_address
-                | instance.brush_kind as i32,
+                | ((instance.brush_kind as i32) << 24),
             ]
         }
     }
 }
 
 // Represents the information about a transform palette
 // entry that is passed to shaders. It includes an index
 // into the transform palette, and a set of flags. The