commit eff6e3d33dd76e12ba4600447d2cd0fcfb922ce5
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sun Mar 14 10:04:48 2021 +0100

    Properly solve the issue with Qualcomm driver V@331 having buggy UBO size.

diff --git a/src/main/java/org/distorted/library/main/DistortedLibrary.java b/src/main/java/org/distorted/library/main/DistortedLibrary.java
index 5892931..ae9e00d 100644
--- a/src/main/java/org/distorted/library/main/DistortedLibrary.java
+++ b/src/main/java/org/distorted/library/main/DistortedLibrary.java
@@ -116,6 +116,7 @@ public class DistortedLibrary
   private static int mGLSL;
   private static String mGLSL_VERSION;
   private static boolean mOITCompilationAttempted, mNeedsTransformFeedback;
+  private static boolean mBuggyUBOs;
 
   private static int mMaxTextureSize         = Integer.MAX_VALUE;
   private static int mMaxNumberOfVerUniforms = Integer.MAX_VALUE;
@@ -248,6 +249,7 @@ public class DistortedLibrary
 
     mainVertHeader += "#define MAX_COMPON " + MeshBase.getMaxEffComponents() + "\n";
     if( MeshBase.getUseCenters() ) mainVertHeader += "#define COMP_CENTERS\n";
+    if( mBuggyUBOs )               mainVertHeader += "#define BUGGY_UBOS\n";
 
     String enabledEffectV= VertexEffect.getGLSL();
     String enabledEffectF= FragmentEffect.getGLSL();
@@ -347,6 +349,7 @@ public class DistortedLibrary
 
     fullVertHeader += "#define MAX_COMPON " + MeshBase.getMaxEffComponents() + "\n";
     if( MeshBase.getUseCenters() ) fullVertHeader += "#define COMP_CENTERS\n";
+    if( mBuggyUBOs )               fullVertHeader += "#define BUGGY_UBOS\n";
 
     String enabledEffectV= VertexEffect.getAllGLSL();
     String enabledEffectF= "{}";
@@ -387,6 +390,7 @@ public class DistortedLibrary
 
     mainVertHeader += "#define MAX_COMPON " + MeshBase.getMaxEffComponents() + "\n";
     if( MeshBase.getUseCenters() ) mainVertHeader += "#define COMP_CENTERS\n";
+    if( mBuggyUBOs )               mainVertHeader += "#define BUGGY_UBOS\n";
 
     String enabledEffectV= VertexEffect.getGLSL();
     String enabledEffectF= FragmentEffect.getGLSL();
@@ -935,6 +939,7 @@ public class DistortedLibrary
       if( version.contains("V@331.0") )
         {
         Log.e("DISTORTED", "You are running this on an Adreno 3xx driver version 331.\nStrange shit might happen.");
+        mBuggyUBOs = true;
         }
       }
     }
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index ffb08ed..514efbf 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -65,10 +65,17 @@ layout (std140) uniform vUniformFloats
                                       // second vec4: first float - cache, next 3: Center, the third -  the Region.
   };
 
+#ifdef BUGGY_UBOS
+layout (packed) uniform componentAssociation
+  {
+  ivec2 vComAssoc[MAX_COMPON];        // component 'AND' and 'EQU' Associations
+  };
+#else
 layout (std140) uniform componentAssociation
   {
   ivec4 vComAssoc[MAX_COMPON];        // component 'AND' and 'EQU' Associations
   };
+#endif
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 // HELPER FUNCTIONS
