From 109faa38089876957c0aae3949434e137056fdc4 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 27 Nov 2019 13:22:50 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- gfx/wr/webrender/res/brush_multi.glsl | 16 ++++++++-------- gfx/wr/webrender/res/prim_shared.glsl | 2 +- gfx/wr/webrender/src/gpu_types.rs | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gfx/wr/webrender/res/brush_multi.glsl b/gfx/wr/webrender/res/brush_multi.glsl index dce79642301b..03ca191cc640 100644 --- a/gfx/wr/webrender/res/brush_multi.glsl +++ b/gfx/wr/webrender/res/brush_multi.glsl @@ -13,14 +13,14 @@ #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); diff --git a/gfx/wr/webrender/res/prim_shared.glsl b/gfx/wr/webrender/res/prim_shared.glsl index 27bd03e6b2cb..2c5fa4fb0434 100644 --- a/gfx/wr/webrender/res/prim_shared.glsl +++ b/gfx/wr/webrender/res/prim_shared.glsl @@ -70,7 +70,7 @@ Instance decode_instance_attributes() { 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; } diff --git a/gfx/wr/webrender/src/gpu_types.rs b/gfx/wr/webrender/src/gpu_types.rs index b12d1f706733..0d00fba2f788 100644 --- a/gfx/wr/webrender/src/gpu_types.rs +++ b/gfx/wr/webrender/src/gpu_types.rs @@ -72,15 +72,15 @@ impl ZBufferIdGenerator { #[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)] @@ -368,7 +368,7 @@ impl GlyphInstance { self.prim_header_index.0 as i32, data0, data1, - resource_address | BrushShaderKind::Text as i32, + resource_address | ((BrushShaderKind::Text as i32) << 24), ], } } @@ -438,7 +438,7 @@ impl From for PrimitiveInstanceData { | ((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), ] } }