Skip to content

Commit

Permalink
Bug 1548339 - WR: Remove the color/alpha feature in cs_scale shader r…
Browse files Browse the repository at this point in the history
…=jrmuizel

this makes the shader simpler at no cost

Differential Revision: https://phabricator.services.mozilla.com/D37114

--HG--
extra : moz-landing-system : lando
  • Loading branch information
kvark committed Jul 5, 2019
1 parent a53a39a commit 6104350
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 45 deletions.
17 changes: 2 additions & 15 deletions gfx/wr/webrender/res/cs_scale.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ void main(void) {
RectWithSize src_rect = src_task.task_rect;
RectWithSize target_rect = scale_task.common_data.task_rect;

#if defined WR_FEATURE_COLOR_TARGET
vec2 texture_size = vec2(textureSize(sPrevPassColor, 0).xy);
#else
vec2 texture_size = vec2(textureSize(sPrevPassAlpha, 0).xy);
#endif

vec2 texture_size = vec2(textureSize(sColor0, 0).xy);
vUv.z = src_task.texture_layer_index;

vUvRect = vec4(src_rect.p0 + vec2(0.5),
Expand All @@ -52,17 +47,9 @@ void main(void) {

#ifdef WR_FRAGMENT_SHADER

#if defined WR_FEATURE_COLOR_TARGET
#define SAMPLE_TYPE vec4
#define SAMPLE_TEXTURE(uv) texture(sPrevPassColor, uv)
#else
#define SAMPLE_TYPE float
#define SAMPLE_TEXTURE(uv) texture(sPrevPassAlpha, uv).r
#endif

void main(void) {
vec2 st = clamp(vUv.xy, vUvRect.xy, vUvRect.zw);
oFragColor = vec4(SAMPLE_TEXTURE(vec3(st, vUv.z)));
oFragColor = texture(sColor0, vec3(st, vUv.z));
}

#endif
23 changes: 9 additions & 14 deletions gfx/wr/webrender/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3358,24 +3358,19 @@ impl Renderer {

let _timer = self.gpu_profile.start_timer(GPU_TAG_SCALE);

match source {
TextureSource::PrevPassColor => {
self.shaders.borrow_mut().cs_scale_rgba8.bind(&mut self.device,
&projection,
&mut self.renderer_errors);
}
TextureSource::PrevPassAlpha => {
self.shaders.borrow_mut().cs_scale_a8.bind(&mut self.device,
&projection,
&mut self.renderer_errors);
}
_ => unreachable!(),
}
self.shaders
.borrow_mut()
.cs_scale
.bind(
&mut self.device,
&projection,
&mut self.renderer_errors,
);

self.draw_instanced_batch(
&scalings,
VertexArrayKind::Scale,
&BatchTextures::no_texture(),
&BatchTextures::color(source),
stats,
);
}
Expand Down
21 changes: 5 additions & 16 deletions gfx/wr/webrender/src/shade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ pub struct Shaders {
pub cs_blur_rgba8: LazilyCompiledShader,
pub cs_border_segment: LazilyCompiledShader,
pub cs_border_solid: LazilyCompiledShader,
pub cs_scale_a8: LazilyCompiledShader,
pub cs_scale_rgba8: LazilyCompiledShader,
pub cs_scale: LazilyCompiledShader,
pub cs_line_decoration: LazilyCompiledShader,
pub cs_gradient: LazilyCompiledShader,

Expand Down Expand Up @@ -688,18 +687,10 @@ impl Shaders {
pls_precache_flags,
)?;

let cs_scale_a8 = LazilyCompiledShader::new(
let cs_scale = LazilyCompiledShader::new(
ShaderKind::Cache(VertexArrayKind::Scale),
"cs_scale",
&["ALPHA_TARGET"],
device,
options.precache_flags,
)?;

let cs_scale_rgba8 = LazilyCompiledShader::new(
ShaderKind::Cache(VertexArrayKind::Scale),
"cs_scale",
&["COLOR_TARGET"],
&[],
device,
options.precache_flags,
)?;
Expand Down Expand Up @@ -854,8 +845,7 @@ impl Shaders {
cs_line_decoration,
cs_gradient,
cs_border_solid,
cs_scale_a8,
cs_scale_rgba8,
cs_scale,
brush_solid,
brush_image,
brush_fast_image,
Expand Down Expand Up @@ -937,8 +927,7 @@ impl Shaders {
}

pub fn deinit(self, device: &mut Device) {
self.cs_scale_a8.deinit(device);
self.cs_scale_rgba8.deinit(device);
self.cs_scale.deinit(device);
self.cs_blur_a8.deinit(device);
self.cs_blur_rgba8.deinit(device);
self.brush_solid.deinit(device);
Expand Down

0 comments on commit 6104350

Please sign in to comment.