Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch the UBO data to be untyped. #385

Merged
merged 1 commit into from Sep 1, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Switch the UBO data to be untyped.

This is an interim workaround for how slow shader compilation is on
Linux when using AoS style declarations. We need this change in order
to enable CI testing of WR, otherwise the test pass is too slow.

It brings the shader compile time on Linux down from around 1.8s to
around 0.2 seconds.
  • Loading branch information
gw3583 committed Sep 1, 2016
commit 24c15626fcf6072cd4a756b61567fa0c1a0ede6d

Large diffs are not rendered by default.

@@ -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;
@@ -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);
@@ -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),
@@ -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;
@@ -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;
@@ -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;
@@ -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),
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -3,41 +3,24 @@
* 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

vec2 texture_size = textureSize(sDiffuse, 0);
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);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.