Revision 42661133
Added by Leszek Koltunski about 3 years ago
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; |
|
22 | 25 |
import android.opengl.GLES30; |
23 | 26 |
import android.opengl.GLSurfaceView; |
24 | 27 |
|
... | ... | |
28 | 31 |
import org.distorted.library.effect.VertexEffectRotate; |
29 | 32 |
import org.distorted.library.main.DistortedLibrary; |
30 | 33 |
import org.distorted.library.main.DistortedScreen; |
34 |
import org.distorted.library.mesh.MeshBase; |
|
31 | 35 |
|
32 | 36 |
import javax.microedition.khronos.egl.EGLConfig; |
33 | 37 |
import javax.microedition.khronos.opengles.GL10; |
... | ... | |
44 | 48 |
private final DistortedScreen mScreen; |
45 | 49 |
private final Fps mFPS; |
46 | 50 |
private boolean mErrorShown; |
51 |
private static boolean mSupportsGigaminx; |
|
47 | 52 |
|
48 | 53 |
private static class Fps |
49 | 54 |
{ |
50 | 55 |
private static final int NUM_FRAMES = 100; |
51 | 56 |
|
52 | 57 |
private long lastTime=0; |
53 |
private long[] durations; |
|
58 |
private final long[] durations;
|
|
54 | 59 |
private int currDuration; |
55 | 60 |
private float currFPS; |
56 | 61 |
|
... | ... | |
127 | 132 |
VertexEffectQuaternion.enable(); |
128 | 133 |
BaseEffect.Type.enableEffects(); |
129 | 134 |
|
135 |
assignMaxComponents(); |
|
136 |
|
|
130 | 137 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1); |
131 | 138 |
} |
132 | 139 |
|
... | ... | |
171 | 178 |
} |
172 | 179 |
} |
173 | 180 |
|
181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
182 |
|
|
183 |
private void assignMaxComponents() |
|
184 |
{ |
|
185 |
Context context = mView.getContext(); |
|
186 |
|
|
187 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
188 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
189 |
|
|
190 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
191 |
int major = glESversion >> 16; |
|
192 |
int minor = glESversion & 0xff; |
|
193 |
|
|
194 |
MeshBase.setMaxEffComponents(242); // the largest object, Gigaminx, has 242 components |
|
195 |
mSupportsGigaminx = true; |
|
196 |
|
|
197 |
if( major==3 && minor==0 ) |
|
198 |
{ |
|
199 |
String vendor = GLES30.glGetString(GLES30.GL_VENDOR); |
|
200 |
String version = GLES30.glGetString(GLES30.GL_VERSION); |
|
201 |
String renderer= GLES30.glGetString(GLES30.GL_RENDERER); |
|
202 |
|
|
203 |
if( vendor.contains("Qualcomm")) |
|
204 |
{ |
|
205 |
if( (renderer.contains("Adreno") && renderer.contains("30")) || version.contains("V@331") ) |
|
206 |
{ |
|
207 |
// on Adreno 30x or driver version 331, do not support Gigaminx. |
|
208 |
// Then Cube5 is the largest with 98 components. |
|
209 |
MeshBase.setMaxEffComponents(98); |
|
210 |
mSupportsGigaminx = false; |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
217 |
|
|
218 |
public static boolean supportsGigaminx() |
|
219 |
{ |
|
220 |
return mSupportsGigaminx; |
|
221 |
} |
|
222 |
|
|
174 | 223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
175 | 224 |
|
176 | 225 |
float getFPS() |
Also available in: Unified diff
Another attempt at fixing tthings on early Qualcomm OpenGL ES 3.0 drivers.
The previous version does not work on Adreno 405 driver V@100, present for example in a Asus ZenPad 8.
Revert the packed 'ivec2' UBO in the vertex shader back to a 'std140' ivec4. This comes at a price if bumping into the bug on Qualcomm driver version 331 on Adreno 308 - i.e. Samsung Galaxy J4+ again.
On this platform, switch off Gigaminx and then set MAX_COMPONENTS to 98.