Revision 6672d895
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/main/Distorted.java | ||
---|---|---|
82 | 82 |
* Work around bugs in ARM Mali driver by, instead to a single FBO, rendering to a circular queue |
83 | 83 |
* of FBO_QUEUE_SIZE FBOs. (otherwise we sometimes get a 'full pipeline flush' and the end result |
84 | 84 |
* might be missing part of the Objects) |
85 |
* |
|
86 |
* This bug only exists on Mali driver r12. TODO: on other platforms, make this equal to 1. |
|
87 |
* |
|
88 |
* https://community.arm.com/graphics/f/discussions/10285/opengl-es-3-1-on-mali-t880-flashes |
|
85 | 89 |
*/ |
86 |
public static final int FBO_QUEUE_SIZE = 4;
|
|
90 |
public static final int FBO_QUEUE_SIZE = 3;
|
|
87 | 91 |
|
88 | 92 |
private static boolean mInitialized=false; |
89 | 93 |
|
... | ... | |
125 | 129 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
126 | 130 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
127 | 131 |
android.util.Log.e("DISTORTED", "Using OpenGL ES "+configurationInfo.getGlEsVersion()); |
128 |
|
|
132 |
/* |
|
133 |
android.util.Log.e("DISTORTED", "GLSL Version "+GLES31.glGetString(GLES31.GL_SHADING_LANGUAGE_VERSION)); |
|
134 |
android.util.Log.e("DISTORTED", "GL Version " +GLES31.glGetString(GLES31.GL_VERSION)); |
|
135 |
android.util.Log.e("DISTORTED", "GL Vendor " +GLES31.glGetString(GLES31.GL_VENDOR)); |
|
136 |
android.util.Log.e("DISTORTED", "GL Renderer " +GLES31.glGetString(GLES31.GL_RENDERER)); |
|
137 |
*/ |
|
129 | 138 |
GLSL = ( (configurationInfo.reqGlEsVersion>>16)>=3 ? 310 : 100 ); |
130 | 139 |
GLSL_VERSION= (GLSL==100 ? "#version 100\n" : "#version 310 es\n"); |
131 | 140 |
|
src/main/java/org/distorted/library/main/DistortedScreen.java | ||
---|---|---|
55 | 55 |
private static MatrixEffectMove mMoveEffect = new MatrixEffectMove( new Static3D(5,5,0) ); |
56 | 56 |
///// END DEBUGGING ////////////////////////// |
57 | 57 |
|
58 |
private int mCurrFBO; |
|
58 |
private int mCurrFBO, mLastFBO;
|
|
59 | 59 |
|
60 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 61 |
// PUBLIC API |
... | ... | |
70 | 70 |
super(Distorted.FBO_QUEUE_SIZE,1,BOTH_DEPTH_STENCIL, TYPE_SYST, 1,1); |
71 | 71 |
mShowFPS = false; |
72 | 72 |
mCurrFBO = 0; |
73 |
mLastFBO = 1; |
|
73 | 74 |
} |
74 | 75 |
|
75 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
83 | 84 |
*/ |
84 | 85 |
public int render(long time) |
85 | 86 |
{ |
87 |
if( ++mCurrFBO>=Distorted.FBO_QUEUE_SIZE ) mCurrFBO=0; |
|
88 |
if( ++mLastFBO>=Distorted.FBO_QUEUE_SIZE ) mLastFBO=0; |
|
89 |
|
|
86 | 90 |
if( mShowFPS ) |
87 | 91 |
{ |
88 | 92 |
if( lastTime==0 ) lastTime = time; |
... | ... | |
106 | 110 |
int numrender = super.render(time,mCurrFBO); |
107 | 111 |
|
108 | 112 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0); |
109 |
setAsInput(mCurrFBO,0); |
|
113 |
|
|
114 |
// workaround for the Mali issues: blit the framebuffer we have computed Distorted.FBO_QUEUE_SIZE |
|
115 |
// frames ago. Looks like FBO_QUEUE_SIZE=2 solves the issue already but I decided to play it safe and |
|
116 |
// make it equal to 3. |
|
117 |
// This of course introduces a delay and uses more memory, but it does not appear to have any effect |
|
118 |
// on speed. Maybe a slight positive effect if any! |
|
119 |
setAsInput(mLastFBO,0); |
|
120 |
|
|
110 | 121 |
GLES31.glColorMask(true,true,true,true); |
111 | 122 |
GLES31.glDepthMask(false); |
112 | 123 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST); |
... | ... | |
120 | 131 |
fpsEffects.drawPriv(fpsW / 2.0f, fpsH / 2.0f, fpsMesh, this, time, 0); |
121 | 132 |
} |
122 | 133 |
|
123 |
mCurrFBO++; |
|
124 |
if( mCurrFBO>=Distorted.FBO_QUEUE_SIZE ) mCurrFBO=0; |
|
125 |
|
|
126 | 134 |
return numrender+1; |
127 | 135 |
} |
128 | 136 |
|
Also available in: Unified diff
I am pretty sure this time the flashing issues on Mali T880 r12 driver are finally fixed.
The fix: a queue of FBOs render to, just like before, but this time in DistortedScreen we blit not the current FBO, but the one computed several frames ago.
This of course introduces a delay and uses more memory, but it appears to work and does not seem to have any effects on speed.