Project

General

Profile

« Previous | Next » 

Revision b4a9a34f

Added by Leszek Koltunski almost 4 years ago

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

View differences:

src/main/java/org/distorted/main/RubikRenderer.java
19 19

  
20 20
package org.distorted.main;
21 21

  
22
import android.app.ActivityManager;
23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
25 22
import android.opengl.GLES30;
26 23
import android.opengl.GLSurfaceView;
27 24

  
......
48 45
   private final DistortedScreen mScreen;
49 46
   private final Fps mFPS;
50 47
   private boolean mErrorShown;
51
   private static boolean mSupportsGigaminx;
52 48

  
53 49
   private static class Fps
54 50
     {
......
128 124
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
129 125
      {
130 126
      DistortedLibrary.setMax(EffectType.VERTEX,61);    // 60 Minx quaternions + rotate
127
      MeshBase.setMaxEffComponents(242);                // 242 moving parts (Gigaminx)
128

  
131 129
      VertexEffectRotate.enable();
132 130
      VertexEffectQuaternion.enable();
133 131
      BaseEffect.Type.enableEffects();
134 132

  
135
      assignMaxComponents();
136

  
137 133
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
138 134
      }
139 135

  
......
178 174
       }
179 175
     }
180 176

  
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182
// Go around bugs on Qualcomm Adreno driver V@331 (present in Samsung Galaxy J4+ and at least some
183
// versions of other Samsung Galaxy phones).
184
// On this driver, it is not possible to assign more than about 6000 bytes for uniform variables in
185
// the vertex shader. We thus need to limit the size of our uniform arrays. The only way seems to be
186
// to limit the number of Mesh components, but then on this platform we cannot support the largest
187
// object in terms of number of movable parts - the Gigaminx.
188

  
189
   private void assignMaxComponents()
190
     {
191
     Context context = mView.getContext();
192

  
193
     final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
194
     final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
195

  
196
     int glESversion = configurationInfo.reqGlEsVersion;
197
     int major = glESversion >> 16;
198
     int minor = glESversion & 0xff;
199

  
200
     MeshBase.setMaxEffComponents(242);   // the largest object, Gigaminx, has 242 components
201
     mSupportsGigaminx = true;
202

  
203
     if( major==3 && minor==0 )
204
       {
205
       String vendor  = GLES30.glGetString(GLES30.GL_VENDOR);
206
       String version = GLES30.glGetString(GLES30.GL_VERSION);
207

  
208
       if( vendor.contains("Qualcomm") && version.contains("V@331") )
209
         {
210
         // on driver version 331,  do not support Gigaminx.
211
         // Then Cube5 is the largest with 98 components.
212
         MeshBase.setMaxEffComponents(98);
213
         mSupportsGigaminx = false;
214
         }
215
       }
216
     }
217

  
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

  
220
   public static boolean supportsGigaminx()
221
     {
222
     return mSupportsGigaminx;
223
     }
224

  
225 177
///////////////////////////////////////////////////////////////////////////////////////////////////
226 178

  
227 179
   float getFPS()
src/main/java/org/distorted/states/RubikStatePlay.java
282 282
            {
283 283
            if( act.getPreRender().canPlay() && StateList.getCurrentState()== StateList.PLAY )
284 284
              {
285
              if( RubikRenderer.supportsGigaminx() || list!=ObjectList.MEGA || sizes[index]<=3 )
286
                {
287
                mObject = obj;
288
                mSize   = sizes[index];
289
                act.changeObject(list,sizes[index], true);
290
                adjustLevels(act);
291
                mMoves.clear();
292
                }
285
              mObject = obj;
286
              mSize   = sizes[index];
287
              act.changeObject(list,sizes[index], true);
288
              adjustLevels(act);
289
              mMoves.clear();
293 290
              }
294 291

  
295 292
            mObjectPopup.dismiss();

Also available in: Unified diff