aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-09-01 04:28:46 -0500
committerGitHub <noreply@github.com>2016-09-01 04:28:46 -0500
commitc3ef836c09f0453a795a1c76f1daa4ed4fc05a2f (patch)
tree19e4e09f9cc77288301d0d020cbb23c818fe5c86
parent57b372ba3bfc8c1c99c541be8d68fac93deb41ca (diff)
parent31d055dced8c5211e01cf2987f1f376cc3521339 (diff)
downloadservo-c3ef836c09f0453a795a1c76f1daa4ed4fc05a2f.tar.gz
servo-c3ef836c09f0453a795a1c76f1daa4ed4fc05a2f.zip
Auto merge of #13146 - glennw:update-wr-soa, r=nox
Update WR + shaders (switch to untyped UBO for CI). This makes WR startup time significantly faster on Linux, by working around a slow path in the shader compiler. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13146) <!-- Reviewable:end -->
-rw-r--r--components/servo/Cargo.lock4
-rw-r--r--ports/cef/Cargo.lock4
-rw-r--r--resources/shaders/prim_shared.glsl347
-rw-r--r--resources/shaders/ps_angle_gradient.glsl2
-rw-r--r--resources/shaders/ps_angle_gradient.vs.glsl14
-rw-r--r--resources/shaders/ps_blend.vs.glsl12
-rw-r--r--resources/shaders/ps_border.fs.glsl29
-rw-r--r--resources/shaders/ps_border.vs.glsl15
-rw-r--r--resources/shaders/ps_box_shadow.vs.glsl14
-rw-r--r--resources/shaders/ps_clear.vs.glsl13
-rw-r--r--resources/shaders/ps_composite.vs.glsl13
-rw-r--r--resources/shaders/ps_gradient.vs.glsl14
-rw-r--r--resources/shaders/ps_image.vs.glsl12
-rw-r--r--resources/shaders/ps_image_clip.vs.glsl13
-rw-r--r--resources/shaders/ps_rectangle.vs.glsl11
-rw-r--r--resources/shaders/ps_rectangle_clip.vs.glsl12
-rw-r--r--resources/shaders/ps_text.vs.glsl12
-rw-r--r--resources/shaders/ps_text_run.vs.glsl29
18 files changed, 374 insertions, 196 deletions
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 1c96d6f4469..7686aeb2102 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -2585,7 +2585,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.5.1"
-source = "git+https://github.com/servo/webrender#b3611d501b13281299a073540058547feeb7e4e3"
+source = "git+https://github.com/servo/webrender#a235d5bd9d3d5174e5b71542277358a9534e7f44"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2610,7 +2610,7 @@ dependencies = [
[[package]]
name = "webrender_traits"
version = "0.5.1"
-source = "git+https://github.com/servo/webrender#b3611d501b13281299a073540058547feeb7e4e3"
+source = "git+https://github.com/servo/webrender#a235d5bd9d3d5174e5b71542277358a9534e7f44"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 21f902244ed..61a0c37c836 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -2445,7 +2445,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.5.1"
-source = "git+https://github.com/servo/webrender#b3611d501b13281299a073540058547feeb7e4e3"
+source = "git+https://github.com/servo/webrender#a235d5bd9d3d5174e5b71542277358a9534e7f44"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2470,7 +2470,7 @@ dependencies = [
[[package]]
name = "webrender_traits"
version = "0.5.1"
-source = "git+https://github.com/servo/webrender#b3611d501b13281299a073540058547feeb7e4e3"
+source = "git+https://github.com/servo/webrender#a235d5bd9d3d5174e5b71542277358a9534e7f44"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/resources/shaders/prim_shared.glsl b/resources/shaders/prim_shared.glsl
index f0f6619e1cc..21d6c41e382 100644
--- a/resources/shaders/prim_shared.glsl
+++ b/resources/shaders/prim_shared.glsl
@@ -27,6 +27,8 @@
#define BORDER_STYLE_INSET uint(8)
#define BORDER_STYLE_OUTSET uint(9)
+#define MAX_STOPS_PER_ANGLE_GRADIENT 8
+
#ifdef WR_VERTEX_SHADER
struct Layer {
mat4 transform;
@@ -35,30 +37,89 @@ struct Layer {
vec4 screen_vertices[4];
};
+layout(std140) uniform Data {
+ vec4 data[WR_MAX_UBO_VECTORS];
+};
+
+layout(std140) uniform Tiles {
+ vec4 tiles[WR_MAX_UBO_VECTORS];
+};
+
layout(std140) uniform Layers {
- Layer layers[WR_MAX_PRIM_LAYERS];
+ vec4 layers[WR_MAX_UBO_VECTORS];
};
+Layer fetch_layer(int index) {
+ Layer layer;
+
+ int offset = index * 13;
+
+ layer.transform[0] = layers[offset + 0];
+ layer.transform[1] = layers[offset + 1];
+ layer.transform[2] = layers[offset + 2];
+ layer.transform[3] = layers[offset + 3];
+
+ layer.inv_transform[0] = layers[offset + 4];
+ layer.inv_transform[1] = layers[offset + 5];
+ layer.inv_transform[2] = layers[offset + 6];
+ layer.inv_transform[3] = layers[offset + 7];
+
+ layer.local_clip_rect = layers[offset + 8];
+
+ layer.screen_vertices[0] = layers[offset + 9];
+ layer.screen_vertices[1] = layers[offset + 10];
+ layer.screen_vertices[2] = layers[offset + 11];
+ layer.screen_vertices[3] = layers[offset + 12];
+
+ return layer;
+}
+
struct Tile {
vec4 actual_rect;
vec4 target_rect;
};
-layout(std140) uniform Tiles {
- Tile tiles[WR_MAX_PRIM_TILES];
-};
+Tile fetch_tile(int index) {
+ Tile tile;
+
+ int offset = index * 2;
+
+ tile.actual_rect = tiles[offset + 0];
+ tile.target_rect = tiles[offset + 1];
+
+ return tile;
+}
struct PrimitiveInfo {
- uvec4 layer_tile;
+ vec4 layer_tile;
vec4 local_clip_rect;
vec4 local_rect;
};
+PrimitiveInfo unpack_prim_info(int offset) {
+ PrimitiveInfo info;
+
+ info.layer_tile = data[offset + 0];
+ info.local_clip_rect = data[offset + 1];
+ info.local_rect = data[offset + 2];
+
+ return info;
+}
+
struct ClipCorner {
vec4 rect;
vec4 outer_inner_radius;
};
+ClipCorner unpack_clip_corner(int offset) {
+ ClipCorner corner;
+
+ corner.rect = data[offset + 0];
+ corner.outer_inner_radius = data[offset + 1];
+
+ return corner;
+}
+
struct Clip {
vec4 rect;
ClipCorner top_left;
@@ -67,6 +128,18 @@ struct Clip {
ClipCorner bottom_right;
};
+Clip unpack_clip(int offset) {
+ Clip clip;
+
+ clip.rect = data[offset + 0];
+ clip.top_left = unpack_clip_corner(offset + 1);
+ clip.top_right = unpack_clip_corner(offset + 3);
+ clip.bottom_left = unpack_clip_corner(offset + 5);
+ clip.bottom_right = unpack_clip_corner(offset + 7);
+
+ return clip;
+}
+
bool ray_plane(vec3 normal, vec3 point, vec3 ray_origin, vec3 ray_dir, out float t)
{
float denom = dot(normal, ray_dir);
@@ -91,8 +164,7 @@ vec4 untransform(vec2 ref, vec3 n, vec3 a, mat4 inv_transform) {
return r;
}
-vec3 get_layer_pos(vec2 pos, uint layer_index) {
- Layer layer = layers[layer_index];
+vec3 get_layer_pos(vec2 pos, Layer layer) {
vec3 a = layer.screen_vertices[0].xyz / layer.screen_vertices[0].w;
vec3 b = layer.screen_vertices[3].xyz / layer.screen_vertices[3].w;
vec3 c = layer.screen_vertices[2].xyz / layer.screen_vertices[2].w;
@@ -113,8 +185,8 @@ struct VertexInfo {
};
VertexInfo write_vertex(PrimitiveInfo info) {
- Layer layer = layers[info.layer_tile.x];
- Tile tile = tiles[info.layer_tile.y];
+ Layer layer = fetch_layer(int(info.layer_tile.x));
+ Tile tile = fetch_tile(int(info.layer_tile.y));
vec2 p0 = floor(0.5 + info.local_rect.xy * uDevicePixelRatio) / uDevicePixelRatio;
vec2 p1 = floor(0.5 + (info.local_rect.xy + info.local_rect.zw) * uDevicePixelRatio) / uDevicePixelRatio;
@@ -155,8 +227,8 @@ struct TransformVertexInfo {
};
TransformVertexInfo write_transform_vertex(PrimitiveInfo info) {
- Layer layer = layers[info.layer_tile.x];
- Tile tile = tiles[info.layer_tile.y];
+ Layer layer = fetch_layer(int(info.layer_tile.x));
+ Tile tile = fetch_tile(int(info.layer_tile.y));
vec2 lp0 = info.local_rect.xy;
vec2 lp1 = info.local_rect.xy + info.local_rect.zw;
@@ -200,7 +272,7 @@ TransformVertexInfo write_transform_vertex(PrimitiveInfo info) {
max_pos_clamped,
aPosition.xy);
- vec3 layer_pos = get_layer_pos(clamped_pos / uDevicePixelRatio, info.layer_tile.x);
+ vec3 layer_pos = get_layer_pos(clamped_pos / uDevicePixelRatio, layer);
vec2 final_pos = clamped_pos + vec2(tile.target_rect.xy) - vec2(tile.actual_rect.xy);
@@ -208,6 +280,257 @@ TransformVertexInfo write_transform_vertex(PrimitiveInfo info) {
return TransformVertexInfo(layer_pos, clipped_local_rect);
}
+
+struct Rectangle {
+ PrimitiveInfo info;
+ vec4 color;
+};
+
+Rectangle fetch_rectangle(int index) {
+ Rectangle rect;
+
+ int offset = index * 4;
+
+ rect.info = unpack_prim_info(offset);
+ rect.color = data[offset + 3];
+
+ return rect;
+}
+
+struct RectangleClip {
+ PrimitiveInfo info;
+ vec4 color;
+ Clip clip;
+};
+
+RectangleClip fetch_rectangle_clip(int index) {
+ RectangleClip rect;
+
+ int offset = index * 13;
+
+ rect.info = unpack_prim_info(offset);
+ rect.color = data[offset + 3];
+ rect.clip = unpack_clip(offset + 4);
+
+ return rect;
+}
+
+struct Glyph {
+ PrimitiveInfo info;
+ vec4 color;
+ vec4 uv_rect;
+};
+
+Glyph fetch_glyph(int index) {
+ Glyph glyph;
+
+ int offset = index * 5;
+
+ glyph.info = unpack_prim_info(offset);
+ glyph.color = data[offset + 3];
+ glyph.uv_rect = data[offset + 4];
+
+ return glyph;
+}
+
+struct TextRunGlyph {
+ vec4 local_rect;
+ vec4 uv_rect;
+};
+
+struct TextRun {
+ PrimitiveInfo info;
+ vec4 color;
+ TextRunGlyph glyphs[WR_GLYPHS_PER_TEXT_RUN];
+};
+
+PrimitiveInfo fetch_text_run_glyph(int index, out vec4 color, out vec4 uv_rect) {
+ int offset = 20 * (index / WR_GLYPHS_PER_TEXT_RUN);
+ int glyph_index = index % WR_GLYPHS_PER_TEXT_RUN;
+ int glyph_offset = offset + 4 + 2 * glyph_index;
+
+ PrimitiveInfo info;
+ info.layer_tile = data[offset + 0];
+ info.local_clip_rect = data[offset + 1];
+ info.local_rect = data[glyph_offset + 0];
+
+ color = data[offset + 3];
+ uv_rect = data[glyph_offset + 1];
+
+ return info;
+}
+
+struct Image {
+ PrimitiveInfo info;
+ vec4 st_rect; // Location of the image texture in the texture atlas.
+ vec4 stretch_size_uvkind; // Size of the actual image.
+};
+
+Image fetch_image(int index) {
+ Image image;
+
+ int offset = index * 5;
+
+ image.info = unpack_prim_info(offset);
+ image.st_rect = data[offset + 3];
+ image.stretch_size_uvkind = data[offset + 4];
+
+ return image;
+}
+
+struct ImageClip {
+ PrimitiveInfo info;
+ vec4 st_rect; // Location of the image texture in the texture atlas.
+ vec4 stretch_size_uvkind; // Size of the actual image.
+ Clip clip;
+};
+
+ImageClip fetch_image_clip(int index) {
+ ImageClip image;
+
+ int offset = index * 14;
+
+ image.info = unpack_prim_info(offset);
+ image.st_rect = data[offset + 3];
+ image.stretch_size_uvkind = data[offset + 4];
+ image.clip = unpack_clip(offset + 5);
+
+ return image;
+}
+
+struct Border {
+ PrimitiveInfo info;
+ vec4 verticalColor;
+ vec4 horizontalColor;
+ vec4 radii;
+ vec4 border_style_trbl;
+ vec4 part;
+};
+
+Border fetch_border(int index) {
+ Border border;
+
+ int offset = index * 8;
+
+ border.info = unpack_prim_info(offset);
+ border.verticalColor = data[offset + 3];
+ border.horizontalColor = data[offset + 4];
+ border.radii = data[offset + 5];
+ border.border_style_trbl = data[offset + 6];
+ border.part = data[offset + 7];
+
+ return border;
+}
+
+struct BoxShadow {
+ PrimitiveInfo info;
+ vec4 color;
+ vec4 border_radii_blur_radius_inverted;
+ vec4 bs_rect;
+ vec4 src_rect;
+};
+
+BoxShadow fetch_boxshadow(int index) {
+ BoxShadow bs;
+
+ int offset = index * 7;
+
+ bs.info = unpack_prim_info(offset);
+ bs.color = data[offset + 3];
+ bs.border_radii_blur_radius_inverted = data[offset + 4];
+ bs.bs_rect = data[offset + 5];
+ bs.src_rect = data[offset + 6];
+
+ return bs;
+}
+
+struct AlignedGradient {
+ PrimitiveInfo info;
+ vec4 color0;
+ vec4 color1;
+ vec4 dir;
+ Clip clip;
+};
+
+AlignedGradient fetch_aligned_gradient(int index) {
+ AlignedGradient gradient;
+
+ int offset = index * 15;
+
+ gradient.info = unpack_prim_info(offset);
+ gradient.color0 = data[offset + 3];
+ gradient.color1 = data[offset + 4];
+ gradient.dir = data[offset + 5];
+ gradient.clip = unpack_clip(offset + 6);
+
+ return gradient;
+}
+
+struct AngleGradient {
+ PrimitiveInfo info;
+ vec4 start_end_point;
+ vec4 stop_count;
+ vec4 colors[MAX_STOPS_PER_ANGLE_GRADIENT];
+ vec4 offsets[MAX_STOPS_PER_ANGLE_GRADIENT/4];
+};
+
+AngleGradient fetch_angle_gradient(int index) {
+ AngleGradient gradient;
+
+ int offset = index * 15;
+
+ gradient.info = unpack_prim_info(offset);
+ gradient.start_end_point = data[offset + 3];
+ gradient.stop_count = data[offset + 4];
+
+ for (int i=0 ; i < MAX_STOPS_PER_ANGLE_GRADIENT ; ++i) {
+ gradient.colors[i] = data[offset + 5 + i];
+ }
+
+ for (int i=0 ; i < MAX_STOPS_PER_ANGLE_GRADIENT/4 ; ++i) {
+ gradient.offsets[i] = data[offset + 5 + MAX_STOPS_PER_ANGLE_GRADIENT + i];
+ }
+
+ return gradient;
+}
+
+struct Blend {
+ vec4 target_rect;
+ vec4 src_rect;
+ vec4 opacity;
+};
+
+Blend fetch_blend(int index) {
+ Blend blend;
+
+ int offset = index * 3;
+
+ blend.target_rect = data[offset + 0];
+ blend.src_rect = data[offset + 1];
+ blend.opacity = data[offset + 2];
+
+ return blend;
+}
+
+struct Composite {
+ vec4 src0;
+ vec4 src1;
+ vec4 target_rect;
+ vec4 info_amount;
+};
+
+Composite fetch_composite(int index) {
+ Composite composite;
+
+ int offset = index * 4;
+
+ composite.src0 = data[offset + 0];
+ composite.src1 = data[offset + 1];
+ composite.target_rect = data[offset + 2];
+ composite.info_amount = data[offset + 3];
+
+ return composite;
+}
#endif
#ifdef WR_FRAGMENT_SHADER
diff --git a/resources/shaders/ps_angle_gradient.glsl b/resources/shaders/ps_angle_gradient.glsl
index fae2211af50..0ef30941186 100644
--- a/resources/shaders/ps_angle_gradient.glsl
+++ b/resources/shaders/ps_angle_gradient.glsl
@@ -2,8 +2,6 @@
* 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/. */
-#define MAX_STOPS_PER_ANGLE_GRADIENT 8
-
flat varying int vStopCount;
flat varying float vAngle;
flat varying vec2 vStartPoint;
diff --git a/resources/shaders/ps_angle_gradient.vs.glsl b/resources/shaders/ps_angle_gradient.vs.glsl
index 1b5c9a82d30..716997d95ee 100644
--- a/resources/shaders/ps_angle_gradient.vs.glsl
+++ b/resources/shaders/ps_angle_gradient.vs.glsl
@@ -3,20 +3,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/. */
-struct AngleGradient {
- PrimitiveInfo info;
- vec4 start_end_point;
- vec4 stop_count;
- vec4 colors[MAX_STOPS_PER_ANGLE_GRADIENT];
- vec4 offsets[MAX_STOPS_PER_ANGLE_GRADIENT/4];
-};
-
-layout(std140) uniform Items {
- AngleGradient gradients[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- AngleGradient gradient = gradients[gl_InstanceID];
+ AngleGradient gradient = fetch_angle_gradient(gl_InstanceID);
VertexInfo vi = write_vertex(gradient.info);
vStopCount = int(gradient.stop_count.x);
diff --git a/resources/shaders/ps_blend.vs.glsl b/resources/shaders/ps_blend.vs.glsl
index 1da420b2493..851c9b8962b 100644
--- a/resources/shaders/ps_blend.vs.glsl
+++ b/resources/shaders/ps_blend.vs.glsl
@@ -3,18 +3,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/. */
-struct Blend {
- vec4 target_rect;
- vec4 src_rect;
- vec4 opacity;
-};
-
-layout(std140) uniform Items {
- Blend blends[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Blend blend = blends[gl_InstanceID];
+ Blend blend = fetch_blend(gl_InstanceID);
vec2 local_pos = mix(vec2(blend.target_rect.xy),
vec2(blend.target_rect.xy + blend.target_rect.zw),
diff --git a/resources/shaders/ps_border.fs.glsl b/resources/shaders/ps_border.fs.glsl
index 545415e3050..17f19b58159 100644
--- a/resources/shaders/ps_border.fs.glsl
+++ b/resources/shaders/ps_border.fs.glsl
@@ -62,15 +62,6 @@ vec4 drawCircle(vec2 aPixel, vec2 aDesiredPos, float aRadius, vec3 aColor) {
return vec4(aColor, pixelInCircle);
}
-// Draw a rectangle at aRect fill it with aColor. Only works on non-rotated
-// rects.
-vec4 drawRect(vec2 aPixel, vec4 aRect, vec3 aColor) {
- // GLSL origin is bottom left, positive Y is up
- bool inRect = (aRect.x <= aPixel.x) && (aPixel.x <= aRect.x + aRect.z) &&
- (aPixel.y >= aRect.y) && (aPixel.y <= aRect.y + aRect.w);
- return vec4(aColor, float(inRect));
-}
-
vec4 draw_dotted_edge() {
// Everything here should be in device pixels.
// We want the dot to be roughly the size of the whole border spacing
@@ -134,11 +125,21 @@ void draw_dotted_border(void) {
#endif
-vec4 draw_dashed_edge(float position, float border_width) {
+vec4 draw_dashed_edge(float position, float border_width, float pixels_per_fragment) {
// TODO: Investigate exactly what FF does.
float size = border_width * 3;
- float segment = floor(position / size) + 2;
- return mix(vec4(0, 0, 0, 0), vHorizontalColor, mod(segment, 2));
+ float segment = floor(position / size);
+
+ float alpha = alpha_for_solid_border(position,
+ segment * size,
+ (segment + 1) * size,
+ pixels_per_fragment);
+
+ if (mod(segment + 2, 2) == 0) {
+ return vHorizontalColor * vec4(1, 1, 1, 1 - alpha);
+ } else {
+ return vHorizontalColor * vec4(1, 1, 1, alpha);
+ }
}
void draw_dashed_border(vec2 local_pos, float distance_from_mix_line) {
@@ -165,13 +166,13 @@ void draw_dashed_border(vec2 local_pos, float distance_from_mix_line) {
case PST_BOTTOM:
case PST_TOP:
{
- oFragColor = draw_dashed_edge(vLocalPos.x - vPieceRect.x, vPieceRect.w);
+ oFragColor = draw_dashed_edge(vLocalPos.x - vPieceRect.x, vPieceRect.w, pixels_per_fragment);
break;
}
case PST_LEFT:
case PST_RIGHT:
{
- oFragColor = draw_dashed_edge(vLocalPos.y - vPieceRect.y, vPieceRect.z);
+ oFragColor = draw_dashed_edge(vLocalPos.y - vPieceRect.y, vPieceRect.z, pixels_per_fragment);
break;
}
}
diff --git a/resources/shaders/ps_border.vs.glsl b/resources/shaders/ps_border.vs.glsl
index 6ad3cdb6473..168f65bc967 100644
--- a/resources/shaders/ps_border.vs.glsl
+++ b/resources/shaders/ps_border.vs.glsl
@@ -3,19 +3,6 @@
* 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/. */
-struct Border {
- PrimitiveInfo info;
- vec4 verticalColor;
- vec4 horizontalColor;
- vec4 radii;
- vec4 border_style_trbl;
- vec4 part;
-};
-
-layout(std140) uniform Items {
- Border borders[WR_MAX_PRIM_ITEMS];
-};
-
float get_border_style(Border a_border, uint a_edge) {
switch (a_edge) {
case PST_TOP:
@@ -34,7 +21,7 @@ float get_border_style(Border a_border, uint a_edge) {
}
void main(void) {
- Border border = borders[gl_InstanceID];
+ Border border = fetch_border(gl_InstanceID);
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(border.info);
vLocalPos = vi.local_pos;
diff --git a/resources/shaders/ps_box_shadow.vs.glsl b/resources/shaders/ps_box_shadow.vs.glsl
index 9662502e14d..e501548f87a 100644
--- a/resources/shaders/ps_box_shadow.vs.glsl
+++ b/resources/shaders/ps_box_shadow.vs.glsl
@@ -3,20 +3,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/. */
-struct BoxShadow {
- PrimitiveInfo info;
- vec4 color;
- vec4 border_radii_blur_radius_inverted;
- vec4 bs_rect;
- vec4 src_rect;
-};
-
-layout(std140) uniform Items {
- BoxShadow boxshadows[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- BoxShadow bs = boxshadows[gl_InstanceID];
+ BoxShadow bs = fetch_boxshadow(gl_InstanceID);
VertexInfo vi = write_vertex(bs.info);
vPos = vi.local_clamped_pos;
diff --git a/resources/shaders/ps_clear.vs.glsl b/resources/shaders/ps_clear.vs.glsl
index 5d3012fe46c..37c941b092b 100644
--- a/resources/shaders/ps_clear.vs.glsl
+++ b/resources/shaders/ps_clear.vs.glsl
@@ -4,19 +4,12 @@
* 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/. */
-struct ClearTile {
- uvec4 rect;
+layout(std140) uniform Data {
+ uvec4 data[WR_MAX_UBO_VECTORS];
};
-layout(std140) uniform Tiles {
- ClearTile tiles[WR_MAX_CLEAR_TILES];
-};
-
-
void main() {
- ClearTile tile = tiles[gl_InstanceID];
-
- vec4 rect = vec4(tile.rect);
+ vec4 rect = vec4(data[gl_InstanceID]);
vec4 pos = vec4(mix(rect.xy, rect.xy + rect.zw, aPosition.xy), 0, 1);
gl_Position = uTransform * pos;
diff --git a/resources/shaders/ps_composite.vs.glsl b/resources/shaders/ps_composite.vs.glsl
index e3ab343859d..125bd37186b 100644
--- a/resources/shaders/ps_composite.vs.glsl
+++ b/resources/shaders/ps_composite.vs.glsl
@@ -3,19 +3,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/. */
-struct Composite {
- vec4 src0;
- vec4 src1;
- vec4 target_rect;
- vec4 info_amount;
-};
-
-layout(std140) uniform Items {
- Composite composites[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Composite composite = composites[gl_InstanceID];
+ Composite composite = fetch_composite(gl_InstanceID);
vec2 local_pos = mix(vec2(composite.target_rect.xy),
vec2(composite.target_rect.xy + composite.target_rect.zw),
diff --git a/resources/shaders/ps_gradient.vs.glsl b/resources/shaders/ps_gradient.vs.glsl
index 0e34678f5e3..6697e3a08c1 100644
--- a/resources/shaders/ps_gradient.vs.glsl
+++ b/resources/shaders/ps_gradient.vs.glsl
@@ -6,20 +6,8 @@
#define DIR_HORIZONTAL uint(0)
#define DIR_VERTICAL uint(1)
-struct Gradient {
- PrimitiveInfo info;
- vec4 color0;
- vec4 color1;
- vec4 dir;
- Clip clip;
-};
-
-layout(std140) uniform Items {
- Gradient gradients[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Gradient gradient = gradients[gl_InstanceID];
+ AlignedGradient gradient = fetch_aligned_gradient(gl_InstanceID);
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(gradient.info);
diff --git a/resources/shaders/ps_image.vs.glsl b/resources/shaders/ps_image.vs.glsl
index 16d46a13b66..d4a9ed243ca 100644
--- a/resources/shaders/ps_image.vs.glsl
+++ b/resources/shaders/ps_image.vs.glsl
@@ -3,18 +3,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/. */
-struct Image {
- PrimitiveInfo info;
- vec4 st_rect; // Location of the image texture in the texture atlas.
- vec4 stretch_size_uvkind; // Size of the actual image.
-};
-
-layout(std140) uniform Items {
- Image images[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Image image = images[gl_InstanceID];
+ Image image = fetch_image(gl_InstanceID);
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(image.info);
diff --git a/resources/shaders/ps_image_clip.vs.glsl b/resources/shaders/ps_image_clip.vs.glsl
index dea9dc2cf5d..ec093e4e64f 100644
--- a/resources/shaders/ps_image_clip.vs.glsl
+++ b/resources/shaders/ps_image_clip.vs.glsl
@@ -3,19 +3,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/. */
-struct Image {
- PrimitiveInfo info;
- vec4 st_rect; // Location of the image texture in the texture atlas.
- vec4 stretch_size_uvkind; // Size of the actual image.
- Clip clip;
-};
-
-layout(std140) uniform Items {
- Image images[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Image image = images[gl_InstanceID];
+ ImageClip image = fetch_image_clip(gl_InstanceID);
VertexInfo vi = write_vertex(image.info);
vClipRect = vec4(image.clip.rect.xy, image.clip.rect.xy + image.clip.rect.zw);
diff --git a/resources/shaders/ps_rectangle.vs.glsl b/resources/shaders/ps_rectangle.vs.glsl
index 046923875b4..ba5ccbb69d5 100644
--- a/resources/shaders/ps_rectangle.vs.glsl
+++ b/resources/shaders/ps_rectangle.vs.glsl
@@ -3,17 +3,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/. */
-struct Rectangle {
- PrimitiveInfo info;
- vec4 color;
-};
-
-layout(std140) uniform Items {
- Rectangle rects[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Rectangle rect = rects[gl_InstanceID];
+ Rectangle rect = fetch_rectangle(gl_InstanceID);
vColor = rect.color;
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(rect.info);
diff --git a/resources/shaders/ps_rectangle_clip.vs.glsl b/resources/shaders/ps_rectangle_clip.vs.glsl
index da39ff9fd6f..e804c0cad4e 100644
--- a/resources/shaders/ps_rectangle_clip.vs.glsl
+++ b/resources/shaders/ps_rectangle_clip.vs.glsl
@@ -3,18 +3,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/. */
-struct Rectangle {
- PrimitiveInfo info;
- vec4 color;
- Clip clip;
-};
-
-layout(std140) uniform Items {
- Rectangle rects[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Rectangle rect = rects[gl_InstanceID];
+ RectangleClip rect = fetch_rectangle_clip(gl_InstanceID);
VertexInfo vi = write_vertex(rect.info);
vClipRect = vec4(rect.clip.rect.xy, rect.clip.rect.xy + rect.clip.rect.zw);
diff --git a/resources/shaders/ps_text.vs.glsl b/resources/shaders/ps_text.vs.glsl
index fc457aedc88..a8d97ced9ef 100644
--- a/resources/shaders/ps_text.vs.glsl
+++ b/resources/shaders/ps_text.vs.glsl
@@ -3,18 +3,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/. */
-struct Glyph {
- PrimitiveInfo info;
- vec4 color;
- vec4 uv_rect;
-};
-
-layout(std140) uniform Items {
- Glyph glyphs[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- Glyph glyph = glyphs[gl_InstanceID];
+ Glyph glyph = fetch_glyph(gl_InstanceID);
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(glyph.info);
diff --git a/resources/shaders/ps_text_run.vs.glsl b/resources/shaders/ps_text_run.vs.glsl
index 055ab6bd991..0310b3972b0 100644
--- a/resources/shaders/ps_text_run.vs.glsl
+++ b/resources/shaders/ps_text_run.vs.glsl
@@ -3,34 +3,17 @@
* 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/. */
-struct TextRunGlyph {
- vec4 local_rect;
- vec4 uv_rect;
-};
-
-struct TextRun {
- PrimitiveInfo info;
- TextRunGlyph glyphs[WR_GLYPHS_PER_TEXT_RUN];
- vec4 color;
-};
-
-layout(std140) uniform Items {
- TextRun text_runs[WR_MAX_PRIM_ITEMS];
-};
-
void main(void) {
- TextRun text_run = text_runs[gl_InstanceID / WR_GLYPHS_PER_TEXT_RUN];
- TextRunGlyph glyph = text_run.glyphs[gl_InstanceID % WR_GLYPHS_PER_TEXT_RUN];
- text_run.info.local_rect = glyph.local_rect;
- vec4 uv_rect = glyph.uv_rect;
+ vec4 color, uv_rect;
+ PrimitiveInfo info = fetch_text_run_glyph(gl_InstanceID, color, uv_rect);
#ifdef WR_FEATURE_TRANSFORM
- TransformVertexInfo vi = write_transform_vertex(text_run.info);
+ TransformVertexInfo vi = write_transform_vertex(info);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
- vec2 f = (vi.local_pos.xy - text_run.info.local_rect.xy) / text_run.info.local_rect.zw;
+ vec2 f = (vi.local_pos.xy - info.local_rect.xy) / info.local_rect.zw;
#else
- VertexInfo vi = write_vertex(text_run.info);
+ VertexInfo vi = write_vertex(info);
vec2 f = (vi.local_clamped_pos - vi.local_rect.p0) / (vi.local_rect.p1 - vi.local_rect.p0);
#endif
@@ -38,6 +21,6 @@ void main(void) {
vec2 st0 = uv_rect.xy / texture_size;
vec2 st1 = uv_rect.zw / texture_size;
- vColor = text_run.color;
+ vColor = color;
vUv = mix(st0, st1, f);
}