Bug 1612941 - WR shader changes to support SWGL instance attribs. r=jrmuizel,gw

Add annotations to vertex shaders so that SWGL can detect when a vertex attribute
is generated by per-instance data rather than per-vertex data.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Lee Salzman 2020-03-11 12:05:16 +00:00
Родитель 1d46e2d87f
Коммит ac1f8c5496
18 изменённых файлов: 85 добавлений и 77 удалений

Просмотреть файл

@ -36,6 +36,14 @@
#endif
#ifdef WR_VERTEX_SHADER
#ifdef SWGL
// Annotate a vertex attribute as being flat per each drawn primitive instance.
// SWGL can use this information to avoid redundantly loading the attribute in all SIMD lanes.
#define PER_INSTANCE flat
#else
#define PER_INSTANCE
#endif
#define varying out
#endif

Просмотреть файл

@ -6,13 +6,13 @@
#ifdef WR_VERTEX_SHADER
in ivec2 aTransformIds;
in ivec4 aClipDataResourceAddress;
in vec2 aClipLocalPos;
in vec4 aClipTileRect;
in vec4 aClipDeviceArea;
in vec4 aClipOrigins;
in float aDevicePixelScale;
PER_INSTANCE in ivec2 aTransformIds;
PER_INSTANCE in ivec4 aClipDataResourceAddress;
PER_INSTANCE in vec2 aClipLocalPos;
PER_INSTANCE in vec4 aClipTileRect;
PER_INSTANCE in vec4 aClipDeviceArea;
PER_INSTANCE in vec4 aClipOrigins;
PER_INSTANCE in float aDevicePixelScale;
struct ClipMaskInstance {
int clip_transform_id;

Просмотреть файл

@ -23,16 +23,16 @@ varying vec2 vUv;
#endif
#ifdef WR_VERTEX_SHADER
in vec4 aDeviceRect;
in vec4 aDeviceClipRect;
in vec4 aColor;
in vec4 aParams;
in vec3 aTextureLayers;
PER_INSTANCE in vec4 aDeviceRect;
PER_INSTANCE in vec4 aDeviceClipRect;
PER_INSTANCE in vec4 aColor;
PER_INSTANCE in vec4 aParams;
PER_INSTANCE in vec3 aTextureLayers;
#ifdef WR_FEATURE_YUV
in vec4 aUvRect0;
in vec4 aUvRect1;
in vec4 aUvRect2;
PER_INSTANCE in vec4 aUvRect0;
PER_INSTANCE in vec4 aUvRect1;
PER_INSTANCE in vec4 aUvRect2;
#endif
void main(void) {

Просмотреть файл

@ -18,9 +18,9 @@ flat varying int vSupport;
#define DIR_HORIZONTAL 0
#define DIR_VERTICAL 1
in int aBlurRenderTaskAddress;
in int aBlurSourceTaskAddress;
in int aBlurDirection;
PER_INSTANCE in int aBlurRenderTaskAddress;
PER_INSTANCE in int aBlurSourceTaskAddress;
PER_INSTANCE in int aBlurDirection;
struct BlurTask {
RenderTaskCommonData common_data;

Просмотреть файл

@ -72,15 +72,15 @@ varying vec2 vPos;
#ifdef WR_VERTEX_SHADER
in vec2 aTaskOrigin;
in vec4 aRect;
in vec4 aColor0;
in vec4 aColor1;
in int aFlags;
in vec2 aWidths;
in vec2 aRadii;
in vec4 aClipParams1;
in vec4 aClipParams2;
PER_INSTANCE in vec2 aTaskOrigin;
PER_INSTANCE in vec4 aRect;
PER_INSTANCE in vec4 aColor0;
PER_INSTANCE in vec4 aColor1;
PER_INSTANCE in int aFlags;
PER_INSTANCE in vec2 aWidths;
PER_INSTANCE in vec2 aRadii;
PER_INSTANCE in vec4 aClipParams1;
PER_INSTANCE in vec4 aClipParams2;
vec2 get_outer_corner_scale(int segment) {
vec2 p;

Просмотреть файл

@ -45,15 +45,15 @@ varying vec2 vPos;
#ifdef WR_VERTEX_SHADER
in vec2 aTaskOrigin;
in vec4 aRect;
in vec4 aColor0;
in vec4 aColor1;
in int aFlags;
in vec2 aWidths;
in vec2 aRadii;
in vec4 aClipParams1;
in vec4 aClipParams2;
PER_INSTANCE in vec2 aTaskOrigin;
PER_INSTANCE in vec4 aRect;
PER_INSTANCE in vec4 aColor0;
PER_INSTANCE in vec4 aColor1;
PER_INSTANCE in int aFlags;
PER_INSTANCE in vec2 aWidths;
PER_INSTANCE in vec2 aRadii;
PER_INSTANCE in vec4 aClipParams1;
PER_INSTANCE in vec4 aClipParams2;
vec2 get_outer_corner_scale(int segment) {
vec2 p;

Просмотреть файл

@ -13,14 +13,14 @@ flat varying vec4 vColor3;
#ifdef WR_VERTEX_SHADER
in vec4 aTaskRect;
in float aAxisSelect;
in vec4 aStops;
in vec4 aColor0;
in vec4 aColor1;
in vec4 aColor2;
in vec4 aColor3;
in vec2 aStartStop;
PER_INSTANCE in vec4 aTaskRect;
PER_INSTANCE in float aAxisSelect;
PER_INSTANCE in vec4 aStops;
PER_INSTANCE in vec4 aColor0;
PER_INSTANCE in vec4 aColor1;
PER_INSTANCE in vec4 aColor2;
PER_INSTANCE in vec4 aColor3;
PER_INSTANCE in vec2 aStartStop;
void main(void) {
vPos = mix(aStartStop.x, aStartStop.y, mix(aPosition.x, aPosition.y, aAxisSelect));

Просмотреть файл

@ -21,22 +21,22 @@ flat varying vec4 vParams;
#ifdef WR_VERTEX_SHADER
// The size of the mask tile we're rendering, in pixels.
in vec4 aTaskRect;
PER_INSTANCE in vec4 aTaskRect;
// The size of the mask tile. aLocalSize.x is always horizontal and .y vertical,
// regardless of the line's orientation. The size is chosen by
// prim_store::get_line_decoration_sizes.
in vec2 aLocalSize;
PER_INSTANCE in vec2 aLocalSize;
// A LINE_STYLE_* value, indicating what sort of line to draw.
in int aStyle;
PER_INSTANCE in int aStyle;
// 0.0 for a horizontal line, 1.0 for a vertical line.
in float aAxisSelect;
PER_INSTANCE in float aAxisSelect;
// The thickness of the wavy line itself, not the amplitude of the waves (i.e.,
// the thickness of the final decorated line).
in float aWavyLineThickness;
PER_INSTANCE in float aWavyLineThickness;
void main(void) {
vec2 size = mix(aLocalSize, aLocalSize.yx, aAxisSelect);

Просмотреть файл

@ -9,9 +9,9 @@ flat varying vec4 vUvRect;
#ifdef WR_VERTEX_SHADER
in vec4 aScaleTargetRect;
in ivec4 aScaleSourceRect;
in int aScaleSourceLayer;
PER_INSTANCE in vec4 aScaleTargetRect;
PER_INSTANCE in ivec4 aScaleSourceRect;
PER_INSTANCE in int aScaleSourceLayer;
void main(void) {
RectWithSize src_rect = RectWithSize(vec2(aScaleSourceRect.xy), vec2(aScaleSourceRect.zw));

Просмотреть файл

@ -39,13 +39,13 @@ flat varying int vFuncs[4];
#ifdef WR_VERTEX_SHADER
in int aFilterRenderTaskAddress;
in int aFilterInput1TaskAddress;
in int aFilterInput2TaskAddress;
in int aFilterKind;
in int aFilterInputCount;
in int aFilterGenericInt;
in ivec2 aFilterExtraDataAddress;
PER_INSTANCE in int aFilterRenderTaskAddress;
PER_INSTANCE in int aFilterInput1TaskAddress;
PER_INSTANCE in int aFilterInput2TaskAddress;
PER_INSTANCE in int aFilterKind;
PER_INSTANCE in int aFilterInputCount;
PER_INSTANCE in int aFilterGenericInt;
PER_INSTANCE in ivec2 aFilterExtraDataAddress;
struct FilterTask {
RenderTaskCommonData common_data;

Просмотреть файл

@ -11,7 +11,7 @@ in vec4 aColor;
void main(void) {
vColor = vec4(aColor.rgb * aColor.a, aColor.a);
vec4 pos = vec4(aPosition, 1.0);
vec4 pos = vec4(aPosition, 0.0, 1.0);
pos.xy = floor(pos.xy + 0.5);
gl_Position = uTransform * pos;
}

Просмотреть файл

@ -14,7 +14,7 @@ in vec2 aColorTexCoord;
void main(void) {
vColor = aColor;
vColorTexCoord = aColorTexCoord;
vec4 pos = vec4(aPosition, 1.0);
vec4 pos = vec4(aPosition, 0.0, 1.0);
pos.xy = floor(pos.xy + 0.5);
gl_Position = uTransform * pos;
}

Просмотреть файл

@ -6,10 +6,10 @@
#ifdef WR_VERTEX_SHADER
in ivec4 aTargetRect;
in ivec2 aStencilOrigin;
in int aSubpixel;
in int aPad;
PER_INSTANCE in ivec4 aTargetRect;
PER_INSTANCE in ivec2 aStencilOrigin;
PER_INSTANCE in int aSubpixel;
PER_INSTANCE in int aPad;
out vec2 vStencilUV;
flat out int vSubpixel;

Просмотреть файл

@ -6,14 +6,14 @@
#ifdef WR_VERTEX_SHADER
in vec2 aFromPosition;
in vec2 aCtrlPosition;
in vec2 aToPosition;
in vec2 aFromNormal;
in vec2 aCtrlNormal;
in vec2 aToNormal;
in int aPathID;
in int aPad;
PER_INSTANCE in vec2 aFromPosition;
PER_INSTANCE in vec2 aCtrlPosition;
PER_INSTANCE in vec2 aToPosition;
PER_INSTANCE in vec2 aFromNormal;
PER_INSTANCE in vec2 aCtrlNormal;
PER_INSTANCE in vec2 aToNormal;
PER_INSTANCE in int aPathID;
PER_INSTANCE in int aPad;
out vec2 vFrom;
out vec2 vCtrl;

Просмотреть файл

@ -11,7 +11,7 @@
#include shared
#ifdef WR_VERTEX_SHADER
in vec4 aRect;
PER_INSTANCE in vec4 aRect;
void main(void) {
vec2 pos = aRect.xy + aPosition.xy * aRect.zw;

Просмотреть файл

@ -11,7 +11,7 @@
#include shared
#ifdef WR_VERTEX_SHADER
in vec4 aRect;
PER_INSTANCE in vec4 aRect;
void main(void) {
vec2 pos = aRect.xy + aPosition.xy * aRect.zw;

Просмотреть файл

@ -45,7 +45,7 @@ uniform HIGHP_SAMPLER_FLOAT sampler2D sPrimitiveHeadersF;
uniform HIGHP_SAMPLER_FLOAT isampler2D sPrimitiveHeadersI;
// Instanced attributes
in ivec4 aData;
PER_INSTANCE in ivec4 aData;
#define VECS_PER_PRIM_HEADER_F 2U
#define VECS_PER_PRIM_HEADER_I 2U

Просмотреть файл

@ -50,7 +50,7 @@
uniform mat4 uTransform; // Orthographic projection
// Attribute inputs
in vec3 aPosition;
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.