summaryrefslogtreecommitdiff
path: root/drivers/gles2/shaders/canvas.glsl
diff options
context:
space:
mode:
authorMarcin Zawiejski <dragmz@gmail.com>2018-08-20 02:10:14 +0200
committerMarcin Zawiejski <dragmz@gmail.com>2018-08-20 02:10:14 +0200
commitbd5ff205b2c1f6ebeeab94bb8dc02a2ff725f628 (patch)
tree44782f77c728e95027100cf64fe041e398a562de /drivers/gles2/shaders/canvas.glsl
parentfaa49c182978b3fe74e7aad65fb761c2881f009c (diff)
Revert "Batch GLES2 draw calls"
This reverts commit f55039b194bbbd8d797b667d67e5677fb429d356. The GLES2 batching seems to require more testing and tweaking in order to actually make the performance better on Android devices. It's been proved with #21184 that the current implementation has it's drawbacks therefore I suggest reverting the commit for now.
Diffstat (limited to 'drivers/gles2/shaders/canvas.glsl')
-rw-r--r--drivers/gles2/shaders/canvas.glsl33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl
index a63c7675d8..29d81bb2c4 100644
--- a/drivers/gles2/shaders/canvas.glsl
+++ b/drivers/gles2/shaders/canvas.glsl
@@ -20,6 +20,13 @@ varying vec4 color_interp;
uniform highp vec2 color_texpixel_size;
+#ifdef USE_TEXTURE_RECT
+
+uniform vec4 dst_rect;
+uniform vec4 src_rect;
+
+#endif
+
uniform highp float time;
VERTEX_SHADER_GLOBALS
@@ -37,9 +44,35 @@ void main() {
vec4 color = color_attrib;
+#ifdef USE_TEXTURE_RECT
+
+ if (dst_rect.z < 0.0) { // Transpose is encoded as negative dst_rect.z
+ uv_interp = src_rect.xy + abs(src_rect.zw) * vertex.yx;
+ } else {
+ uv_interp = src_rect.xy + abs(src_rect.zw) * vertex;
+ }
+
+ vec4 outvec = vec4(0.0, 0.0, 0.0, 1.0);
+
+ // This is what is done in the GLES 3 bindings and should
+ // take care of flipped rects.
+ //
+ // But it doesn't.
+ // I don't know why, will need to investigate further.
+
+ outvec.xy = dst_rect.xy + abs(dst_rect.zw) * select(vertex, vec2(1.0, 1.0) - vertex, lessThan(src_rect.zw, vec2(0.0, 0.0)));
+
+ // outvec.xy = dst_rect.xy + abs(dst_rect.zw) * vertex;
+#else
vec4 outvec = vec4(vertex.xy, 0.0, 1.0);
+#ifdef USE_UV_ATTRIBUTE
uv_interp = uv_attrib;
+#else
+ uv_interp = vertex.xy;
+#endif
+
+#endif
{
vec2 src_vtx=outvec.xy;