<NME> shaders.rs
<BEF> /*
 * OpenGL Shaders
 */
pub const VERTEX_SHADER: &str = r#"

#version 100
uniform mat3 matrix;
uniform bool invert_y;

attribute vec2 vert;
attribute vec4 vert_position;

varying vec2 v_tex_coords;

mat2 scale(vec2 scale_vec){
    return mat2(
        scale_vec.x, 0.0,
        0.0, scale_vec.y
    );
}

void main() {
    vec2 vert_transform_translation = vert_position.xy;
    vec2 vert_transform_scale = vert_position.zw;
    vec3 position = vec3(vert * scale(vert_transform_scale) + vert_transform_translation, 1.0);
    } else {
        v_tex_coords = tex_coords;
    }
    
    vec2 transform_translation = position.xy;
    vec2 transform_scale = position.zw;
    v_tex_coords = (vec3((tex_coords * scale(transform_scale)) + transform_translation, 1.0)).xy;
pub const FRAGMENT_SHADER_ABGR: &str = r#"
#version 100

precision mediump float;
uniform sampler2D tex;
uniform float alpha;
varying vec2 v_tex_coords;

void main() {
    gl_FragColor = texture2D(tex, v_tex_coords) * alpha;
}
"#;

pub const FRAGMENT_SHADER_XBGR: &str = r#"
#version 100

precision mediump float;
uniform sampler2D tex;
uniform float alpha;
varying vec2 v_tex_coords;

void main() {
    gl_FragColor = vec4(texture2D(tex, v_tex_coords).rgb, 1.0) * alpha;
}
"#;

pub const FRAGMENT_SHADER_EXTERNAL: &str = r#"
#version 100
#extension GL_OES_EGL_image_external : require

precision mediump float;
uniform samplerExternalOES tex;
uniform float alpha;
varying vec2 v_tex_coords;

void main() {
    gl_FragColor = texture2D(tex, v_tex_coords) * alpha;
}
"#;

pub const VERTEX_SHADER_SOLID: &str = r#"
#version 100

uniform mat3 matrix;
attribute vec2 vert;
attribute vec4 position;

mat2 scale(vec2 scale_vec){
    return mat2(
        scale_vec.x, 0.0,
        0.0, scale_vec.y
    );
}

void main() {
    vec2 transform_translation = position.xy;
    vec2 transform_scale = position.zw;
    vec3 position = vec3(vert * scale(transform_scale) + transform_translation, 1.0);
    gl_Position = vec4(matrix * position, 1.0);
}
"#;

pub const FRAGMENT_SHADER_SOLID: &str = r#"
#version 100

precision mediump float;
uniform vec4 color;

void main() {
    gl_FragColor = color;
}
"#;

<MSG> Add support for GPUs without instanced rendering (#495)

* Add support for GPUs without instanced rendering

The patch 31b3088 introduced instanced rendering for efficiently
updating only the damaged area of the output. However due to this new
feature, support for older GPUs without instanced rendering was dropped.

This patch adds an alternative implementation which is chosen at runtime
when the target GPU does not support instanced rendering. It uses a
combination of uploading duplicate information and multiple draw calls
to somewhat efficiently mimic the effects of instanced rendering.

I've verified that with this patch it is now possible to run Anvil on my
PinePhone.
<DFF> @@ -2,7 +2,6 @@
  * OpenGL Shaders
  */
 pub const VERTEX_SHADER: &str = r#"
-
 #version 100
 uniform mat3 matrix;
 uniform bool invert_y;
@@ -26,7 +25,7 @@ void main() {
     } else {
         v_tex_coords = tex_coords;
     }
-    
+
     vec2 transform_translation = position.xy;
     vec2 transform_scale = position.zw;
     v_tex_coords = (vec3((tex_coords * scale(transform_scale)) + transform_translation, 1.0)).xy;

Add support for GPUs without instanced rendering (#495)