Backed out changeset 697243e0434b (bug 1640960) as requested by kvark. CLOSED TREE

This commit is contained in:
Butkovits Atila 2020-07-16 17:31:20 +03:00
parent 682f8a9a04
commit e5880f1a26
26 changed files with 127 additions and 103 deletions

View File

@ -3547,14 +3547,6 @@ pub fn ast_to_hir(state: &mut State, tu: &syntax::TranslationUnit) -> Translatio
"gl_Position",
SymDecl::Global(StorageClass::Out, None, Type::new(Vec4), RunClass::Vector),
);
state.declare(
"gl_VertexID",
SymDecl::Global(StorageClass::In, None, Type::new(Int), RunClass::Vector),
);
state.declare(
"gl_InstanceID",
SymDecl::Global(StorageClass::In, None, Type::new(Int), RunClass::Scalar),
);
TranslationUnit(tu.0.map(state, translate_external_declaration))
}

View File

@ -44,8 +44,6 @@
using namespace glsl;
constexpr I32 VertexShaderImpl::gl_VertexID;
struct IntRect {
int x0;
int y0;

View File

@ -46,8 +46,6 @@ struct VertexShaderImpl {
LoadAttribsFunc load_attribs_func = nullptr;
RunPrimitiveFunc run_primitive_func = nullptr;
static constexpr I32 gl_VertexID = { 0, 1, 3, 2 };
int gl_InstanceID;
vec4 gl_Position;
void set_uniform_1i(int index, int value) {
@ -66,7 +64,6 @@ struct VertexShaderImpl {
ALWAYS_INLINE void load_attribs(VertexAttrib* attribs, uint32_t start,
int instance, int count) {
gl_InstanceID = instance;
(*load_attribs_func)(this, attribs, start, instance, count);
}

View File

@ -174,7 +174,7 @@ void brush_shader_main_vs(
if (transform.is_axis_aligned) {
// Select the corner of the local rect that we are processing.
vec2 local_pos = segment_rect.p0 + segment_rect.size * quad_position();
vec2 local_pos = segment_rect.p0 + segment_rect.size * aPosition.xy;
vi = write_vertex(
local_pos,

View File

@ -64,8 +64,7 @@ ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
vec2 task_origin,
vec2 screen_origin,
float device_pixel_scale) {
vec2 quad_pos = quad_position();
vec2 device_pos = screen_origin + sub_rect.p0 + quad_pos * sub_rect.size;
vec2 device_pos = screen_origin + sub_rect.p0 + aPosition.xy * sub_rect.size;
vec2 world_pos = device_pos / device_pixel_scale;
vec4 pos = prim_transform.m * vec4(world_pos, 0.0, 1.0);
@ -82,7 +81,7 @@ ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
// We can therefore simplify this when the clip construction is rewritten
// to only affect the areas touched by a clip.
vec4 vertex_pos = vec4(
task_origin + sub_rect.p0 + quad_pos * sub_rect.size,
task_origin + sub_rect.p0 + aPosition.xy * sub_rect.size,
0.0,
1.0
);

View File

@ -45,7 +45,7 @@ PER_INSTANCE in vec4 aUvRect0;
void main(void) {
// Get world position
vec2 world_pos = aDeviceRect.xy + quad_position() * aDeviceRect.zw;
vec2 world_pos = aDeviceRect.xy + aPosition.xy * aDeviceRect.zw;
// Clip the position to the world space clip rect
vec2 clipped_world_pos = clamp(world_pos, aDeviceClipRect.xy, aDeviceClipRect.xy + aDeviceClipRect.zw);

View File

@ -77,12 +77,11 @@ void main(void) {
src_rect.p0 + blur_task.blur_region - vec2(0.5));
vUvRect /= texture_size.xyxy;
vec2 quad_pos = quad_position();
vec2 pos = target_rect.p0 + target_rect.size * quad_pos;
vec2 pos = target_rect.p0 + target_rect.size * aPosition.xy;
vec2 uv0 = src_rect.p0 / texture_size;
vec2 uv1 = (src_rect.p0 + src_rect.size) / texture_size;
vUv.xy = mix(uv0, uv1, quad_pos);
vUv.xy = mix(uv0, uv1, aPosition.xy);
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}

View File

@ -195,8 +195,6 @@ void main(void) {
break;
}
vec2 quad_pos = quad_position();
vConfig = ivec4(
segment,
style0 | (style1 << 8),
@ -204,7 +202,7 @@ void main(void) {
clip_mode
);
vPartialWidths = vec4(aWidths / 3.0, aWidths / 2.0);
vPos = aRect.zw * quad_pos;
vPos = aRect.zw * aPosition.xy;
vec4[2] color0 = get_colors_for_side(aColor0, style0);
vColor00 = color0[0];
@ -229,7 +227,7 @@ void main(void) {
if (radius > 0.5)
radius += 2.0;
vPos = vClipParams1.xy + radius * (2.0 * quad_pos - 1.0);
vPos = vClipParams1.xy + radius * (2.0 * aPosition.xy - 1.0);
vPos = clamp(vPos, vec2(0.0), aRect.zw);
} else if (clip_mode == CLIP_DASH_CORNER) {
vec2 center = (aClipParams1.xy + aClipParams2.xy) * 0.5;

View File

@ -103,7 +103,7 @@ void main(void) {
}
vMixColors = mix_colors;
vPos = aRect.zw * quad_position();
vPos = aRect.zw * aPosition.xy;
vColor0 = aColor0;
vColor1 = aColor1;

View File

@ -23,8 +23,7 @@ PER_INSTANCE in vec4 aColor3;
PER_INSTANCE in vec2 aStartStop;
void main(void) {
vec2 quad_pos = quad_position();
vPos = mix(aStartStop.x, aStartStop.y, mix(quad_pos.x, quad_pos.y, aAxisSelect));
vPos = mix(aStartStop.x, aStartStop.y, mix(aPosition.x, aPosition.y, aAxisSelect));
vStops = aStops;
vColor0 = aColor0;
@ -32,7 +31,7 @@ void main(void) {
vColor2 = aColor2;
vColor3 = aColor3;
gl_Position = uTransform * vec4(aTaskRect.xy + aTaskRect.zw * quad_pos, 0.0, 1.0);
gl_Position = uTransform * vec4(aTaskRect.xy + aTaskRect.zw * aPosition.xy, 0.0, 1.0);
}
#endif

View File

@ -82,10 +82,9 @@ void main(void) {
vParams = vec4(0.0);
}
vec2 quad_pos = quad_position();
vLocalPos = mix(quad_pos.xy, quad_pos.yx, aAxisSelect) * size;
vLocalPos = mix(aPosition.xy, aPosition.yx, aAxisSelect) * size;
gl_Position = uTransform * vec4(aTaskRect.xy + aTaskRect.zw * quad_pos, 0.0, 1.0);
gl_Position = uTransform * vec4(aTaskRect.xy + aTaskRect.zw * aPosition.xy, 0.0, 1.0);
}
#endif

View File

@ -22,9 +22,8 @@ void main(void) {
vUvRect = vec4(src_rect.p0 + vec2(0.5),
src_rect.p0 + src_rect.size - vec2(0.5)) / texture_size.xyxy;
vec2 quad_pos = quad_position();
vec2 pos = aScaleTargetRect.xy + aScaleTargetRect.zw * quad_pos;
vUv.xy = (src_rect.p0 + src_rect.size * quad_pos) / texture_size;
vec2 pos = aScaleTargetRect.xy + aScaleTargetRect.zw * aPosition.xy;
vUv.xy = (src_rect.p0 + src_rect.size * aPosition.xy) / texture_size;
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}

View File

@ -78,7 +78,7 @@ vec3 compute_uv(RenderTaskCommonData task, vec2 texture_size) {
vec2 uv0 = task_rect.p0 / texture_size;
vec2 uv1 = floor(task_rect.p0 + task_rect.size) / texture_size;
uv.xy = mix(uv0, uv1, quad_position());
uv.xy = mix(uv0, uv1, aPosition.xy);
return uv;
}
@ -87,7 +87,7 @@ void main(void) {
FilterTask filter_task = fetch_filter_task(aFilterRenderTaskAddress);
RectWithSize target_rect = filter_task.common_data.task_rect;
vec2 pos = target_rect.p0 + target_rect.size * quad_position();
vec2 pos = target_rect.p0 + target_rect.size * aPosition.xy;
RenderTaskCommonData input_1_task;
if (aFilterInputCount > 0) {

View File

@ -2,7 +2,7 @@
* 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,debug_shared
#include shared,shared_other
varying vec4 vColor;

View File

@ -2,7 +2,7 @@
* 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,debug_shared
#include shared,shared_other
varying vec2 vColorTexCoord;
varying vec4 vColor;

View File

@ -14,7 +14,7 @@
PER_INSTANCE in vec4 aRect;
void main(void) {
vec2 pos = aRect.xy + quad_position() * aRect.zw;
vec2 pos = aRect.xy + aPosition.xy * aRect.zw;
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}
#endif

View File

@ -14,7 +14,7 @@
PER_INSTANCE in vec4 aRect;
void main(void) {
vec2 pos = aRect.xy + quad_position() * aRect.zw;
vec2 pos = aRect.xy + aPosition.xy * aRect.zw;
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}
#endif

View File

@ -44,6 +44,9 @@ varying vec4 vClipMaskUv;
uniform HIGHP_SAMPLER_FLOAT sampler2D sPrimitiveHeadersF;
uniform HIGHP_SAMPLER_FLOAT isampler2D sPrimitiveHeadersI;
// Instanced attributes
PER_INSTANCE in ivec4 aData;
#define VECS_PER_PRIM_HEADER_F 2U
#define VECS_PER_PRIM_HEADER_I 2U
@ -58,27 +61,20 @@ struct Instance
int brush_kind;
};
Instance decode_instance_attributes_impl(ivec4 data) {
Instance decode_instance_attributes() {
Instance instance;
instance.prim_header_address = data.x;
instance.picture_task_address = data.y >> 16;
instance.clip_address = data.y & 0xffff;
instance.segment_index = data.z & 0xffff;
instance.flags = data.z >> 16;
instance.resource_address = data.w & 0xffffff;
instance.brush_kind = data.w >> 24;
instance.prim_header_address = aData.x;
instance.picture_task_address = aData.y >> 16;
instance.clip_address = aData.y & 0xffff;
instance.segment_index = aData.z & 0xffff;
instance.flags = aData.z >> 16;
instance.resource_address = aData.w & 0xffffff;
instance.brush_kind = aData.w >> 24;
return instance;
}
// Instanced attributes
PER_INSTANCE in ivec4 aData;
Instance decode_instance_attributes() {
return decode_instance_attributes_impl(aData);
}
struct PrimitiveHeader {
RectWithSize local_rect;
RectWithSize local_clip_rect;
@ -193,7 +189,7 @@ VertexInfo write_transform_vertex(RectWithSize local_segment_rect,
local_segment_rect.size += extrude_distance.xy + extrude_distance.zw;
// Select the corner of the local rect that we are processing.
vec2 local_pos = local_segment_rect.p0 + local_segment_rect.size * quad_position();
vec2 local_pos = local_segment_rect.p0 + local_segment_rect.size * aPosition.xy;
// Convert the world positions to device pixel space.
vec2 task_offset = task.common_data.task_rect.p0 - task.content_origin;

View File

@ -11,7 +11,7 @@ PER_INSTANCE in vec4 aRect;
PER_INSTANCE in vec4 aColor;
void main(void) {
vec2 pos = aRect.xy + quad_position() * aRect.zw;
vec2 pos = aRect.xy + aPosition.xy * aRect.zw;
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
gl_Position.z = gl_Position.w; // force depth clear to 1.0
vColor = aColor;

View File

@ -68,10 +68,9 @@ void main(void) {
vec2 dest_origin = dest_task.common_data.task_rect.p0 -
dest_task.content_origin;
vec2 quad_pos = quad_position();
vec2 local_pos = bilerp(geometry.local[0], geometry.local[1],
geometry.local[3], geometry.local[2],
quad_pos.y, quad_pos.x);
aPosition.y, aPosition.x);
vec4 world_pos = transform.m * vec4(local_pos, 0.0, 1.0);
vec4 final_pos = vec4(

View File

@ -152,8 +152,6 @@ void text_shader_main_vs(
vec2 snap_bias = get_snap_bias(subpx_dir);
vec2 quad_pos = quad_position();
// Glyph space refers to the pixel space used by glyph rasterization during frame
// building. If a non-identity transform was used, WR_FEATURE_GLYPH_TRANSFORM will
// be set. Otherwise, regardless of whether the raster space is LOCAL or SCREEN,
@ -186,13 +184,13 @@ void text_shader_main_vs(
RectWithSize local_rect = transform_rect(glyph_rect, glyph_transform_inv);
// Select the corner of the glyph's local space rect that we are processing.
vec2 local_pos = local_rect.p0 + local_rect.size * quad_pos;
vec2 local_pos = local_rect.p0 + local_rect.size * aPosition.xy;
// If the glyph's local rect would fit inside the local clip rect, then select a corner from
// the device space glyph rect to reduce overdraw of clipped pixels in the fragment shader.
// Otherwise, fall back to clamping the glyph's local rect to the local clip rect.
if (rect_inside_rect(local_rect, ph.local_clip_rect)) {
local_pos = glyph_transform_inv * (glyph_rect.p0 + glyph_rect.size * quad_pos);
local_pos = glyph_transform_inv * (glyph_rect.p0 + glyph_rect.size * aPosition.xy);
}
#else
float raster_scale = float(ph.user_data.x) / 65535.0;
@ -228,7 +226,7 @@ void text_shader_main_vs(
glyph_scale_inv * (res.uv_rect.zw - res.uv_rect.xy));
// Select the corner of the glyph rect that we are processing.
vec2 local_pos = glyph_rect.p0 + glyph_rect.size * quad_pos;
vec2 local_pos = glyph_rect.p0 + glyph_rect.size * aPosition.xy;
#endif
VertexInfo vi = write_vertex(

View File

@ -49,16 +49,15 @@
// Uniform inputs
uniform mat4 uTransform; // Orthographic projection
// Attribute inputs
in vec2 aPosition;
// get_fetch_uv is a macro to work around a macOS Intel driver parsing bug.
// TODO: convert back to a function once the driver issues are resolved, if ever.
// https://github.com/servo/webrender/pull/623
// https://github.com/servo/servo/issues/13953
// Do the division with unsigned ints because that's more efficient with D3D
#define get_fetch_uv(i, vpi) ivec2(int(vpi * (uint(i) % (WR_MAX_VERTEX_TEXTURE_WIDTH/vpi))), int(uint(i) / (WR_MAX_VERTEX_TEXTURE_WIDTH/vpi)))
vec2 quad_position() {
return vec2(ivec2(gl_VertexID & 1, (gl_VertexID>>1) & 1));
}
#endif
//======================================================================================

View File

@ -6,8 +6,6 @@
// Vertex shader attributes and uniforms
//======================================================================================
#ifdef WR_VERTEX_SHADER
// Attribute inputs
in vec2 aPosition;
#endif
//======================================================================================

View File

@ -300,19 +300,14 @@ impl VertexDescriptor {
}
}
fn bind(&self, gl: &dyn gl::Gl, vertex_buf: VBOId, instance_buf: VBOId) {
if !self.vertex_attributes.is_empty() {
Self::bind_attributes(
self.vertex_attributes,
0,
0, gl, vertex_buf);
}
fn bind(&self, gl: &dyn gl::Gl, main: VBOId, instance: VBOId) {
Self::bind_attributes(self.vertex_attributes, 0, 0, gl, main);
if !self.instance_attributes.is_empty() {
Self::bind_attributes(
self.instance_attributes,
self.vertex_attributes.len(),
1, gl, instance_buf,
1, gl, instance,
);
}
}
@ -3329,7 +3324,7 @@ impl Device {
);
}
pub fn draw_triangles_u16(&mut self, first_index: i32, index_count: i32) {
pub fn draw_triangles_u16(&mut self, first_vertex: i32, index_count: i32) {
debug_assert!(self.inside_frame);
#[cfg(debug_assertions)]
debug_assert!(self.shader_is_ready);
@ -3338,11 +3333,11 @@ impl Device {
gl::TRIANGLES,
index_count,
gl::UNSIGNED_SHORT,
first_index as u32 * 2,
first_vertex as u32 * 2,
);
}
pub fn draw_triangles_u32(&mut self, first_index: i32, index_count: i32) {
pub fn draw_triangles_u32(&mut self, first_vertex: i32, index_count: i32) {
debug_assert!(self.inside_frame);
#[cfg(debug_assertions)]
debug_assert!(self.shader_is_ready);
@ -3351,7 +3346,7 @@ impl Device {
gl::TRIANGLES,
index_count,
gl::UNSIGNED_INT,
first_index as u32 * 4,
first_vertex as u32 * 4,
);
}

View File

@ -408,7 +408,13 @@ pub(crate) mod desc {
use crate::device::{VertexAttribute, VertexAttributeKind, VertexDescriptor};
pub const PRIM_INSTANCES: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aData",
@ -419,7 +425,13 @@ pub(crate) mod desc {
};
pub const BLUR: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aBlurRenderTaskAddress",
@ -440,7 +452,13 @@ pub(crate) mod desc {
};
pub const LINE: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aTaskRect",
@ -471,7 +489,13 @@ pub(crate) mod desc {
};
pub const GRADIENT: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aTaskRect",
@ -521,7 +545,13 @@ pub(crate) mod desc {
};
pub const BORDER: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aTaskOrigin",
@ -572,7 +602,13 @@ pub(crate) mod desc {
};
pub const SCALE: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aScaleTargetRect",
@ -593,7 +629,13 @@ pub(crate) mod desc {
};
pub const CLIP: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aTransformIds",
@ -650,7 +692,13 @@ pub(crate) mod desc {
};
pub const RESOLVE: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aRect",
@ -661,7 +709,13 @@ pub(crate) mod desc {
};
pub const SVG_FILTER: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aFilterRenderTaskAddress",
@ -786,7 +840,13 @@ pub(crate) mod desc {
};
pub const COMPOSITE: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aDeviceRect",
@ -832,7 +892,13 @@ pub(crate) mod desc {
};
pub const CLEAR: VertexDescriptor = VertexDescriptor {
vertex_attributes: &[],
vertex_attributes: &[
VertexAttribute {
name: "aPosition",
count: 2,
kind: VertexAttributeKind::F32,
},
],
instance_attributes: &[
VertexAttribute {
name: "aRect",
@ -2314,13 +2380,14 @@ impl Renderer {
let x1 = 1.0;
let y1 = 1.0;
let quad_indices: [u16; 6] = [0, 1, 2, 2, 1, 3];
let quad_vertices = [
PackedVertex { pos: [x0, y0] },
PackedVertex { pos: [x1, y0] },
PackedVertex { pos: [x0, y1] },
PackedVertex { pos: [x1, y1] },
];
let quad_indices: [u16; 6] = [0, 1, 2, 2, 1, 3];
let prim_vao = device.create_vao(&desc::PRIM_INSTANCES);
device.bind_vao(&prim_vao);
device.update_vao_indices(&prim_vao, &quad_indices, VertexUsageHint::Static);

View File

@ -383,14 +383,6 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
OperatingSystem::OSX, DeviceFamily::All, nsIGfxInfo::FEATURE_GL_SWIZZLE,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, "FEATURE_FAILURE_MAC_GPU_SWITCHING_NO_SWIZZLE");
// When we draw without per-vertex attributes, Intel GPUs screw up scissored clears.
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1652763
// We are blocking it on all devices in order to support GPU switching.
IMPLEMENT_MAC_DRIVER_BLOCKLIST(OperatingSystem::OSX, DeviceFamily::All,
nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
"FEATURE_FAILURE_MAC_INTEL_NO_SCISSORED_CLEARS");
#ifdef NIGHTLY_BUILD
IMPLEMENT_MAC_DRIVER_BLOCKLIST(
OperatingSystem::OSX, DeviceFamily::IntelRolloutWebRender, nsIGfxInfo::FEATURE_WEBRENDER,