зеркало из https://github.com/mozilla/gecko-dev.git
97 строки
3.7 KiB
GLSL
97 строки
3.7 KiB
GLSL
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* 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/. */
|
|
|
|
#ifdef WR_FEATURE_TEXTURE_EXTERNAL
|
|
// Please check https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external_essl3.txt
|
|
// for this extension.
|
|
#extension GL_OES_EGL_image_external_essl3 : require
|
|
#endif
|
|
|
|
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
|
|
#extension GL_ARB_explicit_attrib_location : require
|
|
#endif
|
|
|
|
#include base
|
|
|
|
#if defined(WR_FEATURE_TEXTURE_EXTERNAL) || defined(WR_FEATURE_TEXTURE_RECT) || defined(WR_FEATURE_TEXTURE_2D)
|
|
#define TEX_SAMPLE(sampler, tex_coord) texture(sampler, tex_coord.xy)
|
|
#else
|
|
#define TEX_SAMPLE(sampler, tex_coord) texture(sampler, tex_coord)
|
|
#endif
|
|
|
|
//======================================================================================
|
|
// Vertex shader attributes and uniforms
|
|
//======================================================================================
|
|
#ifdef WR_VERTEX_SHADER
|
|
// A generic uniform that shaders can optionally use to configure
|
|
// an operation mode for this batch.
|
|
uniform int uMode;
|
|
|
|
// Uniform inputs
|
|
uniform mat4 uTransform; // Orthographic projection
|
|
uniform float uDevicePixelRatio;
|
|
|
|
// Attribute inputs
|
|
in vec3 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(uint(vpi) * (uint(i) % uint(WR_MAX_VERTEX_TEXTURE_WIDTH/vpi))), int(uint(i) / uint(WR_MAX_VERTEX_TEXTURE_WIDTH/vpi)))
|
|
#endif
|
|
|
|
//======================================================================================
|
|
// Fragment shader attributes and uniforms
|
|
//======================================================================================
|
|
#ifdef WR_FRAGMENT_SHADER
|
|
// Uniform inputs
|
|
|
|
// Fragment shader outputs
|
|
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
|
|
layout(location = 0, index = 0) out vec4 oFragColor;
|
|
layout(location = 0, index = 1) out vec4 oFragBlend;
|
|
#else
|
|
out vec4 oFragColor;
|
|
#endif
|
|
#endif
|
|
|
|
//======================================================================================
|
|
// Shared shader uniforms
|
|
//======================================================================================
|
|
#ifdef WR_FEATURE_TEXTURE_2D
|
|
uniform sampler2D sColor0;
|
|
uniform sampler2D sColor1;
|
|
uniform sampler2D sColor2;
|
|
#elif defined WR_FEATURE_TEXTURE_RECT
|
|
uniform sampler2DRect sColor0;
|
|
uniform sampler2DRect sColor1;
|
|
uniform sampler2DRect sColor2;
|
|
#elif defined WR_FEATURE_TEXTURE_EXTERNAL
|
|
uniform samplerExternalOES sColor0;
|
|
uniform samplerExternalOES sColor1;
|
|
uniform samplerExternalOES sColor2;
|
|
#else
|
|
uniform sampler2DArray sColor0;
|
|
uniform sampler2DArray sColor1;
|
|
uniform sampler2DArray sColor2;
|
|
#endif
|
|
|
|
#ifdef WR_FEATURE_DITHERING
|
|
uniform sampler2D sDither;
|
|
#endif
|
|
|
|
//======================================================================================
|
|
// Interpolator definitions
|
|
//======================================================================================
|
|
|
|
//======================================================================================
|
|
// VS only types and UBOs
|
|
//======================================================================================
|
|
|
|
//======================================================================================
|
|
// VS only functions
|
|
//======================================================================================
|