Skip to content

Commit a237f9b

Browse files
author
bors-servo
authored
Auto merge of #591 - glennw:intermittent-hack, r=mrobinson
Add specific shaders for rectangles with CLIP feature. Having the base rectangle shader include clip makes the software mesa implementation (somewhat) slower for reftests. This is enough of a timing difference that it triggers a lot of intermittent test failures in Servo. Instead, include a simple rectangle shader for workloads that don't have a clip mask. The other shaders are typically more expensive and not used as frequently by the reftests, so hopefully this change is enough to work around the Servo intermittent bugs. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/591) <!-- Reviewable:end -->
2 parents 82a0ca4 + 18164e5 commit a237f9b

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

webrender/res/ps_rectangle.fs.glsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ void main(void) {
99
init_transform_fs(vLocalPos, vLocalRect, alpha);
1010
#endif
1111

12+
#ifdef WR_FEATURE_CLIP
1213
alpha = min(alpha, do_clip());
14+
#endif
1315
oFragColor = vColor * vec4(1.0, 1.0, 1.0, alpha);
1416
}

webrender/res/ps_rectangle.vs.glsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ void main(void) {
2121
prim.tile);
2222
#endif
2323

24+
#ifdef WR_FEATURE_CLIP
2425
write_clip(vi.global_clamped_pos, prim.clip_area);
26+
#endif
2527
}

webrender/src/renderer.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl VertexDataTexture {
119119

120120
const TRANSFORM_FEATURE: &'static str = "TRANSFORM";
121121
const SUBPIXEL_AA_FEATURE: &'static str = "SUBPIXEL_AA";
122+
const CLIP_FEATURE: &'static str = "CLIP";
122123

123124
enum ShaderKind {
124125
Primitive,
@@ -346,6 +347,7 @@ pub struct Renderer {
346347
// output, and the cache_image shader blits the results of
347348
// a cache shader (e.g. blur) to the screen.
348349
ps_rectangle: PrimitiveShader,
350+
ps_rectangle_clip: PrimitiveShader,
349351
ps_text_run: PrimitiveShader,
350352
ps_text_run_subpixel: PrimitiveShader,
351353
ps_image: PrimitiveShader,
@@ -503,6 +505,12 @@ impl Renderer {
503505
&mut device,
504506
&[],
505507
options.precache_shaders);
508+
let ps_rectangle_clip = PrimitiveShader::new("ps_rectangle",
509+
max_ubo_vectors,
510+
max_prim_instances,
511+
&mut device,
512+
&[ CLIP_FEATURE ],
513+
options.precache_shaders);
506514
let ps_text_run = PrimitiveShader::new("ps_text_run",
507515
max_ubo_vectors,
508516
max_prim_instances,
@@ -699,6 +707,7 @@ impl Renderer {
699707
cs_text_run: cs_text_run,
700708
cs_blur: cs_blur,
701709
ps_rectangle: ps_rectangle,
710+
ps_rectangle_clip: ps_rectangle_clip,
702711
ps_text_run: ps_text_run,
703712
ps_text_run_subpixel: ps_text_run_subpixel,
704713
ps_image: ps_image,
@@ -1198,7 +1207,7 @@ impl Renderer {
11981207
for batch in &target.alpha_batcher.batches {
11991208
let transform_kind = batch.key.flags.transform_kind();
12001209
let needs_clipping = batch.key.flags.needs_clipping();
1201-
assert!(!needs_clipping || batch.key.blend_mode == BlendMode::Alpha);
1210+
debug_assert!(!needs_clipping || batch.key.blend_mode == BlendMode::Alpha);
12021211

12031212
if batch.key.blend_mode != prev_blend_mode {
12041213
match batch.key.blend_mode {
@@ -1256,7 +1265,11 @@ impl Renderer {
12561265
}
12571266
&PrimitiveBatchData::Rectangles(ref ubo_data) => {
12581267
self.gpu_profile.add_marker(GPU_TAG_PRIM_RECT);
1259-
let (shader, max_prim_items) = self.ps_rectangle.get(&mut self.device, transform_kind);
1268+
let (shader, max_prim_items) = if needs_clipping {
1269+
self.ps_rectangle_clip.get(&mut self.device, transform_kind)
1270+
} else {
1271+
self.ps_rectangle.get(&mut self.device, transform_kind)
1272+
};
12601273
self.draw_ubo_batch(ubo_data,
12611274
shader,
12621275
1,

0 commit comments

Comments
 (0)