diff options
Diffstat (limited to 'gfx/wr/webrender/res')
-rw-r--r-- | gfx/wr/webrender/res/brush.glsl | 2 | ||||
-rw-r--r-- | gfx/wr/webrender/res/brush_linear_gradient.glsl | 4 | ||||
-rw-r--r-- | gfx/wr/webrender/res/cs_border_segment.glsl | 8 | ||||
-rw-r--r-- | gfx/wr/webrender/res/cs_clip_image.glsl | 117 | ||||
-rw-r--r-- | gfx/wr/webrender/res/cs_linear_gradient.glsl | 4 | ||||
-rw-r--r-- | gfx/wr/webrender/res/cs_radial_gradient.glsl | 4 | ||||
-rw-r--r-- | gfx/wr/webrender/res/gpu_buffer.glsl | 36 | ||||
-rw-r--r-- | gfx/wr/webrender/res/gradient.glsl | 2 | ||||
-rw-r--r-- | gfx/wr/webrender/res/prim_shared.glsl | 6 | ||||
-rw-r--r-- | gfx/wr/webrender/res/ps_quad.glsl | 81 | ||||
-rw-r--r-- | gfx/wr/webrender/res/ps_quad_mask.glsl | 6 | ||||
-rw-r--r-- | gfx/wr/webrender/res/ps_quad_textured.glsl | 2 | ||||
-rw-r--r-- | gfx/wr/webrender/res/ps_text_run.glsl | 2 | ||||
-rw-r--r-- | gfx/wr/webrender/res/render_task.glsl | 25 |
14 files changed, 118 insertions, 181 deletions
diff --git a/gfx/wr/webrender/res/brush.glsl b/gfx/wr/webrender/res/brush.glsl index 8d0d52ce82..67c9255831 100644 --- a/gfx/wr/webrender/res/brush.glsl +++ b/gfx/wr/webrender/res/brush.glsl @@ -214,7 +214,7 @@ void main(void) { Instance instance = decode_instance_attributes(); PrimitiveHeader ph = fetch_prim_header(instance.prim_header_address); Transform transform = fetch_transform(ph.transform_id); - PictureTask task = fetch_picture_task(instance.picture_task_address); + PictureTask task = fetch_picture_task(ph.picture_task_address); ClipArea clip_area = fetch_clip_area(instance.clip_address); WR_VERTEX_SHADER_MAIN_FUNCTION(instance, ph, transform, task, clip_area); diff --git a/gfx/wr/webrender/res/brush_linear_gradient.glsl b/gfx/wr/webrender/res/brush_linear_gradient.glsl index ceb1b14e5b..235be4b24b 100644 --- a/gfx/wr/webrender/res/brush_linear_gradient.glsl +++ b/gfx/wr/webrender/res/brush_linear_gradient.glsl @@ -82,12 +82,12 @@ Fragment brush_fs() { #ifdef SWGL_DRAW_SPAN void swgl_drawSpanRGBA8() { - int address = swgl_validateGradient(sGpuBuffer, get_gpu_buffer_uv(v_gradient_address.x), int(GRADIENT_ENTRIES + 2.0)); + int address = swgl_validateGradient(sGpuBufferF, get_gpu_buffer_uv(v_gradient_address.x), int(GRADIENT_ENTRIES + 2.0)); if (address < 0) { return; } - swgl_commitLinearGradientRGBA8(sGpuBuffer, address, GRADIENT_ENTRIES, true, v_gradient_repeat.x != 0.0, + swgl_commitLinearGradientRGBA8(sGpuBufferF, address, GRADIENT_ENTRIES, true, v_gradient_repeat.x != 0.0, v_pos, v_scale_dir, v_start_offset.x); } #endif diff --git a/gfx/wr/webrender/res/cs_border_segment.glsl b/gfx/wr/webrender/res/cs_border_segment.glsl index e684bfa6df..7deb62f6ef 100644 --- a/gfx/wr/webrender/res/cs_border_segment.glsl +++ b/gfx/wr/webrender/res/cs_border_segment.glsl @@ -13,7 +13,7 @@ flat varying mediump vec4 vColor11; // A point + tangent defining the line where the edge // transition occurs. Used for corners only. -flat varying mediump vec4 vColorLine; +flat varying highp vec4 vColorLine; // x: segment, y: clip mode // We cast these to/from floats rather than using an ivec due to a driver bug @@ -31,13 +31,13 @@ flat varying highp vec4 vClipCenter_Sign; // An outer and inner elliptical radii for border // corner clipping. -flat varying mediump vec4 vClipRadii; +flat varying highp vec4 vClipRadii; // Reference point for determine edge clip lines. -flat varying mediump vec4 vEdgeReference; +flat varying highp vec4 vEdgeReference; // Stores widths/2 and widths/3 to save doing this in FS. -flat varying mediump vec4 vPartialWidths; +flat varying highp vec4 vPartialWidths; // Clipping parameters for dot or dash. flat varying mediump vec4 vClipParams1; diff --git a/gfx/wr/webrender/res/cs_clip_image.glsl b/gfx/wr/webrender/res/cs_clip_image.glsl deleted file mode 100644 index 24ba1dab8e..0000000000 --- a/gfx/wr/webrender/res/cs_clip_image.glsl +++ /dev/null @@ -1,117 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include shared,clip_shared - -varying highp vec2 vLocalPos; -varying highp vec2 vClipMaskImageUv; - -flat varying highp vec4 vClipMaskUvInnerRect; - -#ifdef WR_VERTEX_SHADER - -PER_INSTANCE in vec4 aClipTileRect; -PER_INSTANCE in ivec2 aClipDataResourceAddress; -PER_INSTANCE in vec4 aClipLocalRect; - -struct ClipMaskInstanceImage { - ClipMaskInstanceCommon base; - RectWithEndpoint tile_rect; - ivec2 resource_address; - RectWithEndpoint local_rect; -}; - -ClipMaskInstanceImage fetch_clip_item() { - ClipMaskInstanceImage cmi; - - cmi.base = fetch_clip_item_common(); - - cmi.tile_rect = RectWithEndpoint(aClipTileRect.xy, aClipTileRect.zw); - cmi.resource_address = aClipDataResourceAddress; - cmi.local_rect = RectWithEndpoint(aClipLocalRect.xy, aClipLocalRect.zw); - - return cmi; -} - -struct ClipImageVertexInfo { - vec2 local_pos; - vec4 world_pos; -}; - -// This differs from write_clip_tile_vertex in that we forward transform the -// primitive's local-space tile rect into the target space. We use scissoring -// to ensure that the primitive does not draw outside the target bounds. -ClipImageVertexInfo write_clip_image_vertex(RectWithEndpoint tile_rect, - RectWithEndpoint local_clip_rect, - Transform prim_transform, - Transform clip_transform, - RectWithEndpoint sub_rect, - vec2 task_origin, - vec2 screen_origin, - float device_pixel_scale) { - vec2 local_pos = rect_clamp(local_clip_rect, mix(tile_rect.p0, tile_rect.p1, aPosition.xy)); - vec4 world_pos = prim_transform.m * vec4(local_pos, 0.0, 1.0); - vec4 final_pos = vec4( - world_pos.xy * device_pixel_scale + (task_origin - screen_origin) * world_pos.w, - 0.0, - world_pos.w - ); - gl_Position = uTransform * final_pos; - - init_transform_vs( - clip_transform.is_axis_aligned - ? vec4(vec2(-1.0e16), vec2(1.0e16)) - : vec4(local_clip_rect.p0, local_clip_rect.p1)); - - ClipImageVertexInfo vi = ClipImageVertexInfo(local_pos, world_pos); - return vi; -} - -void main(void) { - ClipMaskInstanceImage cmi = fetch_clip_item(); - Transform clip_transform = fetch_transform(cmi.base.clip_transform_id); - Transform prim_transform = fetch_transform(cmi.base.prim_transform_id); - ImageSource res = fetch_image_source_direct(cmi.resource_address); - - ClipImageVertexInfo vi = write_clip_image_vertex( - cmi.tile_rect, - cmi.local_rect, - prim_transform, - clip_transform, - cmi.base.sub_rect, - cmi.base.task_origin, - cmi.base.screen_origin, - cmi.base.device_pixel_scale - ); - vLocalPos = vi.local_pos; - vec2 uv = (vi.local_pos - cmi.tile_rect.p0) / rect_size(cmi.tile_rect); - - vec2 texture_size = vec2(TEX_SIZE(sColor0)); - vec4 uv_rect = vec4(res.uv_rect.p0, res.uv_rect.p1); - vClipMaskImageUv = mix(uv_rect.xy, uv_rect.zw, uv) / texture_size; - - // applying a half-texel offset to the UV boundaries to prevent linear samples from the outside - vClipMaskUvInnerRect = (uv_rect + vec4(0.5, 0.5, -0.5, -0.5)) / texture_size.xyxy; -} -#endif - -#ifdef WR_FRAGMENT_SHADER -void main(void) { - float alpha = init_transform_rough_fs(vLocalPos); - vec2 source_uv = clamp(vClipMaskImageUv, vClipMaskUvInnerRect.xy, vClipMaskUvInnerRect.zw); - float clip_alpha = texture(sColor0, source_uv).r; //careful: texture has type A8 - oFragColor = vec4(mix(1.0, clip_alpha, alpha), 0.0, 0.0, 1.0); -} - -#ifdef SWGL_DRAW_SPAN -void swgl_drawSpanR8() { - if (has_valid_transform_bounds()) { - return; - } - - swgl_commitTextureLinearR8(sColor0, vClipMaskImageUv, vClipMaskUvInnerRect); -} -#endif - -#endif diff --git a/gfx/wr/webrender/res/cs_linear_gradient.glsl b/gfx/wr/webrender/res/cs_linear_gradient.glsl index b1aff899a6..1afee5818b 100644 --- a/gfx/wr/webrender/res/cs_linear_gradient.glsl +++ b/gfx/wr/webrender/res/cs_linear_gradient.glsl @@ -54,12 +54,12 @@ void main(void) { #ifdef SWGL_DRAW_SPAN void swgl_drawSpanRGBA8() { - int address = swgl_validateGradient(sGpuBuffer, get_gpu_buffer_uv(v_gradient_address.x), int(GRADIENT_ENTRIES + 2.0)); + int address = swgl_validateGradient(sGpuBufferF, get_gpu_buffer_uv(v_gradient_address.x), int(GRADIENT_ENTRIES + 2.0)); if (address < 0) { return; } - swgl_commitLinearGradientRGBA8(sGpuBuffer, address, GRADIENT_ENTRIES, false, v_gradient_repeat.x != 0.0, + swgl_commitLinearGradientRGBA8(sGpuBufferF, address, GRADIENT_ENTRIES, false, v_gradient_repeat.x != 0.0, v_pos, v_scale_dir, v_start_offset.x); } #endif diff --git a/gfx/wr/webrender/res/cs_radial_gradient.glsl b/gfx/wr/webrender/res/cs_radial_gradient.glsl index 16ffe06376..10919ac628 100644 --- a/gfx/wr/webrender/res/cs_radial_gradient.glsl +++ b/gfx/wr/webrender/res/cs_radial_gradient.glsl @@ -58,12 +58,12 @@ void main(void) { #ifdef SWGL_DRAW_SPAN void swgl_drawSpanRGBA8() { - int address = swgl_validateGradient(sGpuBuffer, get_gpu_buffer_uv(v_gradient_address.x), + int address = swgl_validateGradient(sGpuBufferF, get_gpu_buffer_uv(v_gradient_address.x), int(GRADIENT_ENTRIES + 2.0)); if (address < 0) { return; } - swgl_commitRadialGradientRGBA8(sGpuBuffer, address, GRADIENT_ENTRIES, v_gradient_repeat.x != 0.0, + swgl_commitRadialGradientRGBA8(sGpuBufferF, address, GRADIENT_ENTRIES, v_gradient_repeat.x != 0.0, v_pos, v_start_radius.x); } #endif diff --git a/gfx/wr/webrender/res/gpu_buffer.glsl b/gfx/wr/webrender/res/gpu_buffer.glsl index 25f4622db2..4923a28ef9 100644 --- a/gfx/wr/webrender/res/gpu_buffer.glsl +++ b/gfx/wr/webrender/res/gpu_buffer.glsl @@ -2,41 +2,47 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -uniform HIGHP_SAMPLER_FLOAT sampler2D sGpuBuffer; +uniform HIGHP_SAMPLER_FLOAT sampler2D sGpuBufferF; +uniform HIGHP_SAMPLER_FLOAT isampler2D sGpuBufferI; ivec2 get_gpu_buffer_uv(HIGHP_FS_ADDRESS int address) { return ivec2(uint(address) % WR_MAX_VERTEX_TEXTURE_WIDTH, uint(address) / WR_MAX_VERTEX_TEXTURE_WIDTH); } -vec4 fetch_from_gpu_buffer_1(HIGHP_FS_ADDRESS int address) { +vec4 fetch_from_gpu_buffer_1f(HIGHP_FS_ADDRESS int address) { ivec2 uv = get_gpu_buffer_uv(address); - return texelFetch(sGpuBuffer, uv, 0); + return texelFetch(sGpuBufferF, uv, 0); } -vec4[2] fetch_from_gpu_buffer_2(HIGHP_FS_ADDRESS int address) { +vec4[2] fetch_from_gpu_buffer_2f(HIGHP_FS_ADDRESS int address) { ivec2 uv = get_gpu_buffer_uv(address); return vec4[2]( - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(0, 0)), - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(1, 0)) + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(0, 0)), + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(1, 0)) ); } -vec4[3] fetch_from_gpu_buffer_3(HIGHP_FS_ADDRESS int address) { +vec4[3] fetch_from_gpu_buffer_3f(HIGHP_FS_ADDRESS int address) { ivec2 uv = get_gpu_buffer_uv(address); return vec4[3]( - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(0, 0)), - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(1, 0)), - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(2, 0)) + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(0, 0)), + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(1, 0)), + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(2, 0)) ); } -vec4[4] fetch_from_gpu_buffer_4(HIGHP_FS_ADDRESS int address) { +vec4[4] fetch_from_gpu_buffer_4f(HIGHP_FS_ADDRESS int address) { ivec2 uv = get_gpu_buffer_uv(address); return vec4[4]( - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(0, 0)), - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(1, 0)), - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(2, 0)), - TEXEL_FETCH(sGpuBuffer, uv, 0, ivec2(3, 0)) + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(0, 0)), + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(1, 0)), + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(2, 0)), + TEXEL_FETCH(sGpuBufferF, uv, 0, ivec2(3, 0)) ); } + +ivec4 fetch_from_gpu_buffer_1i(HIGHP_FS_ADDRESS int address) { + ivec2 uv = get_gpu_buffer_uv(address); + return texelFetch(sGpuBufferI, uv, 0); +} diff --git a/gfx/wr/webrender/res/gradient.glsl b/gfx/wr/webrender/res/gradient.glsl index 87c011fefc..6ed2e69871 100644 --- a/gfx/wr/webrender/res/gradient.glsl +++ b/gfx/wr/webrender/res/gradient.glsl @@ -54,7 +54,7 @@ vec4 sample_gradient(float offset) { float entry_fract = x - entry_index; // Fetch the start and end color. There is a [start, end] color per entry. - vec4 texels[2] = fetch_from_gpu_buffer_2(v_gradient_address.x + 2 * int(entry_index)); + vec4 texels[2] = fetch_from_gpu_buffer_2f(v_gradient_address.x + 2 * int(entry_index)); // Finally interpolate and apply dithering return dither(texels[0] + texels[1] * entry_fract); diff --git a/gfx/wr/webrender/res/prim_shared.glsl b/gfx/wr/webrender/res/prim_shared.glsl index 1a599bf980..9762658776 100644 --- a/gfx/wr/webrender/res/prim_shared.glsl +++ b/gfx/wr/webrender/res/prim_shared.glsl @@ -44,7 +44,6 @@ PER_INSTANCE in ivec4 aData; struct Instance { int prim_header_address; - int picture_task_address; int clip_address; int segment_index; int flags; @@ -56,8 +55,7 @@ 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.clip_address = aData.y; instance.segment_index = aData.z & 0xffff; instance.flags = aData.z >> 16; instance.resource_address = aData.w & 0xffffff; @@ -72,6 +70,7 @@ struct PrimitiveHeader { float z; int specific_prim_address; int transform_id; + int picture_task_address; ivec4 user_data; }; @@ -90,6 +89,7 @@ PrimitiveHeader fetch_prim_header(int index) { ph.z = float(data0.x); ph.specific_prim_address = data0.y; ph.transform_id = data0.z; + ph.picture_task_address = data0.w; ph.user_data = data1; return ph; diff --git a/gfx/wr/webrender/res/ps_quad.glsl b/gfx/wr/webrender/res/ps_quad.glsl index ed6b35c3b8..94c80a93f7 100644 --- a/gfx/wr/webrender/res/ps_quad.glsl +++ b/gfx/wr/webrender/res/ps_quad.glsl @@ -2,12 +2,40 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/// The common infrastructure for ps_quad_* shaders. +/// +/// # Memory layout +/// +/// The diagram below shows the the various pieces of data fectched in the vertex shader: +/// +///```ascii +/// (int gpu buffer) +/// +---------------+ (sGpuCache) +/// (instance-step vertex attr) | Int header | +-----------+ +/// +-----------------------------+ | | | Transform | +/// | Quad instance (uvec4) | +--> | transform id +--> +-----------+ +/// | | | | z id | +/// | x: int prim address +---+ +---------------+ (float gpu buffer) +/// | y: float prim address +--------------------------> +-----------+--------------+-+-+ +/// | z: quad flags | (sGpuCache) | Quad Prim | Quad Segment | | | +/// | edge flags | +--------------------+ | | | | | +/// | part index | | Picture task | | bounds | rect | | | +/// | segment index | | | | clip | uv rect | | | +/// | w: picture task address +--> | task rect | | color | | | | +/// +-----------------------------+ | device pixel scale | +-----------+--------------+-+-+ +/// | content origin | +/// +--------------------+ +///``` + #define WR_FEATURE_TEXTURE_2D #include shared,rect,transform,render_task,gpu_buffer flat varying mediump vec4 v_color; flat varying mediump vec4 v_uv_sample_bounds; +// x: (in ps_quad_textured) has edge flags +// y: has uv rect +// z: (in ps_quad_textured) sample as mask flat varying lowp ivec4 v_flags; varying highp vec2 v_uv; @@ -61,7 +89,7 @@ struct QuadPrimitive { QuadSegment fetch_segment(int base, int index) { QuadSegment seg; - vec4 texels[2] = fetch_from_gpu_buffer_2(base + 3 + index * 2); + vec4 texels[2] = fetch_from_gpu_buffer_2f(base + 3 + index * 2); seg.rect = RectWithEndpoint(texels[0].xy, texels[0].zw); seg.uv_rect = texels[1]; @@ -72,7 +100,7 @@ QuadSegment fetch_segment(int base, int index) { QuadPrimitive fetch_primitive(int index) { QuadPrimitive prim; - vec4 texels[3] = fetch_from_gpu_buffer_3(index); + vec4 texels[3] = fetch_from_gpu_buffer_3f(index); prim.bounds = RectWithEndpoint(texels[0].xy, texels[0].zw); prim.clip = RectWithEndpoint(texels[1].xy, texels[1].zw); @@ -81,37 +109,51 @@ QuadPrimitive fetch_primitive(int index) { return prim; } +struct QuadHeader { + int transform_id; + int z_id; +}; + +QuadHeader fetch_header(int address) { + ivec4 header = fetch_from_gpu_buffer_1i(address); + + QuadHeader qh = QuadHeader( + header.x, + header.y + ); + + return qh; +} + struct QuadInstance { // x - int prim_address; + int prim_address_i; // y - int quad_flags; - int edge_flags; - int picture_task_address; + int prim_address_f; // z + int quad_flags; + int edge_flags; int part_index; - int z_id; + int segment_index; // w - int segment_index; - int transform_id; + int picture_task_address; }; QuadInstance decode_instance() { QuadInstance qi = QuadInstance( aData.x, - (aData.y >> 24) & 0xff, - (aData.y >> 16) & 0xff, - aData.y & 0xffff, + aData.y, (aData.z >> 24) & 0xff, - aData.z & 0xffffff, + (aData.z >> 16) & 0xff, + (aData.z >> 8) & 0xff, + (aData.z >> 0) & 0xff, - (aData.w >> 24) & 0xff, - aData.w & 0xffffff + aData.w ); return qi; @@ -165,17 +207,18 @@ float edge_aa_offset(int edge, int flags) { PrimitiveInfo ps_quad_main(void) { QuadInstance qi = decode_instance(); - Transform transform = fetch_transform(qi.transform_id); + QuadHeader qh = fetch_header(qi.prim_address_i); + Transform transform = fetch_transform(qh.transform_id); PictureTask task = fetch_picture_task(qi.picture_task_address); - QuadPrimitive prim = fetch_primitive(qi.prim_address); - float z = float(qi.z_id); + QuadPrimitive prim = fetch_primitive(qi.prim_address_f); + float z = float(qh.z_id); QuadSegment seg; if (qi.segment_index == INVALID_SEGMENT_INDEX) { seg.rect = prim.bounds; seg.uv_rect = vec4(0.0); } else { - seg = fetch_segment(qi.prim_address, qi.segment_index); + seg = fetch_segment(qi.prim_address_f, qi.segment_index); } // The local space rect that we will draw, which is effectively: diff --git a/gfx/wr/webrender/res/ps_quad_mask.glsl b/gfx/wr/webrender/res/ps_quad_mask.glsl index 4b28109726..6b72714efb 100644 --- a/gfx/wr/webrender/res/ps_quad_mask.glsl +++ b/gfx/wr/webrender/res/ps_quad_mask.glsl @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/// This shader applies a (rounded) rectangle mask to the content of the framebuffer. + #include ps_quad,ellipse varying highp vec4 vClipLocalPos; @@ -45,12 +47,12 @@ Clip fetch_clip(int index) { clip.space = aClipData.z; #ifdef WR_FEATURE_FAST_PATH - vec4 texels[3] = fetch_from_gpu_buffer_3(index); + vec4 texels[3] = fetch_from_gpu_buffer_3f(index); clip.rect = RectWithEndpoint(texels[0].xy, texels[0].zw); clip.radii = texels[1]; clip.mode = texels[2].x; #else - vec4 texels[4] = fetch_from_gpu_buffer_4(index); + vec4 texels[4] = fetch_from_gpu_buffer_4f(index); clip.rect = RectWithEndpoint(texels[0].xy, texels[0].zw); clip.radii_top = texels[1]; clip.radii_bottom = texels[2]; diff --git a/gfx/wr/webrender/res/ps_quad_textured.glsl b/gfx/wr/webrender/res/ps_quad_textured.glsl index 48579eb4fe..2382623cdb 100644 --- a/gfx/wr/webrender/res/ps_quad_textured.glsl +++ b/gfx/wr/webrender/res/ps_quad_textured.glsl @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/// This shader renders solid colors or simple images in a color or alpha target. + #include ps_quad #ifndef SWGL_ANTIALIAS diff --git a/gfx/wr/webrender/res/ps_text_run.glsl b/gfx/wr/webrender/res/ps_text_run.glsl index aabc1e9d8a..9faac99620 100644 --- a/gfx/wr/webrender/res/ps_text_run.glsl +++ b/gfx/wr/webrender/res/ps_text_run.glsl @@ -100,7 +100,7 @@ void main() { PrimitiveHeader ph = fetch_prim_header(instance.prim_header_address); Transform transform = fetch_transform(ph.transform_id); ClipArea clip_area = fetch_clip_area(instance.clip_address); - PictureTask task = fetch_picture_task(instance.picture_task_address); + PictureTask task = fetch_picture_task(ph.picture_task_address); int glyph_index = instance.segment_index; int subpx_dir = (instance.flags >> 8) & 0xff; diff --git a/gfx/wr/webrender/res/render_task.glsl b/gfx/wr/webrender/res/render_task.glsl index cd9aea402c..e5d0c298cd 100644 --- a/gfx/wr/webrender/res/render_task.glsl +++ b/gfx/wr/webrender/res/render_task.glsl @@ -73,7 +73,7 @@ PictureTask fetch_picture_task(int address) { return task; } -#define CLIP_TASK_EMPTY 0x7FFF +#define CLIP_TASK_EMPTY 0x7FFFFFFF struct ClipArea { RectWithEndpoint task_rect; @@ -82,21 +82,22 @@ struct ClipArea { }; ClipArea fetch_clip_area(int index) { - ClipArea area; - + RenderTaskData task_data; if (index >= CLIP_TASK_EMPTY) { - area.task_rect = RectWithEndpoint(vec2(0.0), vec2(0.0)); - area.device_pixel_scale = 0.0; - area.screen_origin = vec2(0.0); + // We deliberately create a dummy RenderTaskData here then convert to a + // ClipArea after this if-else statement, rather than initialize the + // ClipArea in separate branches, to avoid a miscompile in some Adreno + // drivers. See bug 1884791. Unfortunately the specific details of the bug + // are unknown, so please take extra care not to regress this when + // refactoring. + task_data = RenderTaskData(RectWithEndpoint(vec2(0.0), vec2(0.0)), + vec4(0.0)); } else { - RenderTaskData task_data = fetch_render_task_data(index); - - area.task_rect = task_data.task_rect; - area.device_pixel_scale = task_data.user_data.x; - area.screen_origin = task_data.user_data.yz; + task_data = fetch_render_task_data(index); } - return area; + return ClipArea(task_data.task_rect, task_data.user_data.x, + task_data.user_data.yz); } #endif //WR_VERTEX_SHADER |