Revision 2faad666
Added by Leszek Koltunski about 6 years ago
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
115 | 115 |
private int mSurfaceID; |
116 | 116 |
private int mLastIndex; |
117 | 117 |
private int[] mLastValue = new int[FRAME_DELAY]; |
118 |
private int mLastDiff = -1; |
|
119 |
|
|
120 |
private static final int RUNNING_AVERAGE = 10; |
|
121 |
private int[] mRunningAvg = new int[RUNNING_AVERAGE]; |
|
122 |
private int mAvgIndex; |
|
123 |
private int mAvgSum; |
|
118 | 124 |
// end section |
119 | 125 |
//////////////////////////////////////////////////////////////////////////////// |
120 | 126 |
|
... | ... | |
218 | 224 |
|
219 | 225 |
void recreate() |
220 | 226 |
{ |
227 |
mSSBO[0] = -1; |
|
228 |
mLastDiff = -1; |
|
229 |
|
|
221 | 230 |
for(int i = 0; i< FRAME_DELAY; i++) mLastValue[i] = 0; |
222 |
mSSBO[0]= -1; |
|
223 | 231 |
mSurfaceCounter.releaseAll(); |
232 |
|
|
224 | 233 |
recreateSurface(); |
225 | 234 |
} |
226 | 235 |
|
... | ... | |
516 | 525 |
GLES31.glClear(mClear); |
517 | 526 |
DistortedRenderState.colorDepthStencilRestore(); |
518 | 527 |
|
519 |
if( ++mLastIndex >= FRAME_DELAY ) mLastIndex=0; |
|
520 |
|
|
521 |
int index = (mLastIndex==0 ? FRAME_DELAY-1 : mLastIndex-1); |
|
522 |
int value = mIntBuffer.get(FRAME_DELAY *mSurfaceID+index); |
|
523 |
|
|
524 |
if( value!=mLastValue[index] ) |
|
528 |
if( mSSBO[0]>=0 ) |
|
525 | 529 |
{ |
526 | 530 |
// yes, this DOES keep on working when 'value' overflows into negative territory. |
527 |
android.util.Log.d("surface", "surface id: "+mSurfaceID+" last frame: "+(value-mLastValue[index]) ); |
|
528 |
mLastValue[index] = value; |
|
531 |
int value = mIntBuffer.get(FRAME_DELAY*mSurfaceID+mLastIndex); |
|
532 |
|
|
533 |
if( value-mLastValue[mLastIndex]!=mLastDiff ) |
|
534 |
{ |
|
535 |
android.util.Log.d("surface", "id " + mSurfaceID + |
|
536 |
(mType == TYPE_USER ? " USER" : (mType == TYPE_SYST ? " SYST" : " TREE")) + |
|
537 |
" (" + mWidth + "x" + mHeight + ") last frame: " + (value - mLastValue[mLastIndex]) |
|
538 |
+ " avg: " + (mAvgSum/RUNNING_AVERAGE) |
|
539 |
); |
|
540 |
} |
|
541 |
|
|
542 |
mLastDiff = value-mLastValue[mLastIndex]; |
|
543 |
mLastValue[mLastIndex] = value; |
|
544 |
|
|
545 |
mAvgSum += (mLastDiff-mRunningAvg[mAvgIndex]); |
|
546 |
mRunningAvg[mAvgIndex] = mLastDiff; |
|
547 |
if( ++mAvgIndex>=RUNNING_AVERAGE ) mAvgIndex =0; |
|
529 | 548 |
} |
549 |
|
|
550 |
if( ++mLastIndex >= FRAME_DELAY ) mLastIndex=0; |
|
530 | 551 |
} |
531 | 552 |
} |
532 | 553 |
|
Also available in: Unified diff
SSBO: now we have a more-or-less correct running average of the count of transparent fragments over the last few frames.