Revision 2301cb2f
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/main/Distorted.java | ||
---|---|---|
81 | 81 |
* Work around bugs in ARM Mali driver by, instead to a single FBO, rendering to a circular queue |
82 | 82 |
* of FBO_QUEUE_SIZE FBOs. (otherwise we sometimes get a 'full pipeline flush' and the end result |
83 | 83 |
* might be missing part of the Objects) |
84 |
* |
|
85 |
* This bug only exists on Mali driver r12. TODO: on other platforms, make this equal to 1. |
|
86 |
* |
|
87 |
* https://community.arm.com/graphics/f/discussions/10285/opengl-es-3-1-on-mali-t880-flashes |
|
84 | 88 |
*/ |
85 |
public static final int FBO_QUEUE_SIZE = 4;
|
|
89 |
public static final int FBO_QUEUE_SIZE = 3;
|
|
86 | 90 |
|
87 | 91 |
private static boolean mInitialized=false; |
88 | 92 |
|
... | ... | |
118 | 122 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
119 | 123 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
120 | 124 |
android.util.Log.e("DISTORTED", "Using OpenGL ES "+configurationInfo.getGlEsVersion()); |
121 |
|
|
125 |
/* |
|
126 |
android.util.Log.e("DISTORTED", "GLSL Version "+GLES31.glGetString(GLES31.GL_SHADING_LANGUAGE_VERSION)); |
|
127 |
android.util.Log.e("DISTORTED", "GL Version " +GLES31.glGetString(GLES31.GL_VERSION)); |
|
128 |
android.util.Log.e("DISTORTED", "GL Vendor " +GLES31.glGetString(GLES31.GL_VENDOR)); |
|
129 |
android.util.Log.e("DISTORTED", "GL Renderer " +GLES31.glGetString(GLES31.GL_RENDERER)); |
|
130 |
*/ |
|
122 | 131 |
GLSL = ( (configurationInfo.reqGlEsVersion>>16)>=3 ? 310 : 100 ); |
123 | 132 |
GLSL_VERSION= (GLSL==100 ? "#version 100\n" : "#version 310 es\n"); |
124 | 133 |
|
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.