summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wgpu-hal/src/gles/shaders
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/wgpu-hal/src/gles/shaders
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/wgpu-hal/src/gles/shaders')
-rw-r--r--third_party/rust/wgpu-hal/src/gles/shaders/clear.frag9
-rw-r--r--third_party/rust/wgpu-hal/src/gles/shaders/clear.vert11
-rw-r--r--third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.frag16
-rw-r--r--third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.vert18
4 files changed, 54 insertions, 0 deletions
diff --git a/third_party/rust/wgpu-hal/src/gles/shaders/clear.frag b/third_party/rust/wgpu-hal/src/gles/shaders/clear.frag
new file mode 100644
index 0000000000..7766c12d9f
--- /dev/null
+++ b/third_party/rust/wgpu-hal/src/gles/shaders/clear.frag
@@ -0,0 +1,9 @@
+#version 300 es
+precision lowp float;
+uniform vec4 color;
+//Hack: Some WebGL implementations don't find "color" otherwise.
+uniform vec4 color_workaround;
+out vec4 frag;
+void main() {
+ frag = color + color_workaround;
+}
diff --git a/third_party/rust/wgpu-hal/src/gles/shaders/clear.vert b/third_party/rust/wgpu-hal/src/gles/shaders/clear.vert
new file mode 100644
index 0000000000..ac655e7f31
--- /dev/null
+++ b/third_party/rust/wgpu-hal/src/gles/shaders/clear.vert
@@ -0,0 +1,11 @@
+#version 300 es
+precision lowp float;
+// A triangle that fills the whole screen
+const vec2[3] TRIANGLE_POS = vec2[](
+ vec2( 0.0, -3.0),
+ vec2(-3.0, 1.0),
+ vec2( 3.0, 1.0)
+);
+void main() {
+ gl_Position = vec4(TRIANGLE_POS[gl_VertexID], 0.0, 1.0);
+} \ No newline at end of file
diff --git a/third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.frag b/third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.frag
new file mode 100644
index 0000000000..853f82a6ae
--- /dev/null
+++ b/third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.frag
@@ -0,0 +1,16 @@
+#version 300 es
+precision mediump float;
+in vec2 uv;
+uniform sampler2D present_texture;
+out vec4 frag;
+vec4 linear_to_srgb(vec4 linear) {
+ vec3 color_linear = linear.rgb;
+ vec3 selector = ceil(color_linear - 0.0031308); // 0 if under value, 1 if over
+ vec3 under = 12.92 * color_linear;
+ vec3 over = 1.055 * pow(color_linear, vec3(0.41666)) - 0.055;
+ vec3 result = mix(under, over, selector);
+ return vec4(result, linear.a);
+}
+void main() {
+ frag = linear_to_srgb(texture(present_texture, uv));
+} \ No newline at end of file
diff --git a/third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.vert b/third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.vert
new file mode 100644
index 0000000000..922f2a1848
--- /dev/null
+++ b/third_party/rust/wgpu-hal/src/gles/shaders/srgb_present.vert
@@ -0,0 +1,18 @@
+#version 300 es
+precision mediump float;
+// A triangle that fills the whole screen
+const vec2[3] TRIANGLE_POS = vec2[](
+ vec2( 0.0, -3.0),
+ vec2(-3.0, 1.0),
+ vec2( 3.0, 1.0)
+);
+const vec2[3] TRIANGLE_UV = vec2[](
+ vec2( 0.5, 1.),
+ vec2( -1.0, -1.0),
+ vec2( 2.0, -1.0)
+);
+out vec2 uv;
+void main() {
+ uv = TRIANGLE_UV[gl_VertexID];
+ gl_Position = vec4(TRIANGLE_POS[gl_VertexID], 0.0, 1.0);
+} \ No newline at end of file