Project

General

Profile

« Previous | Next » 

Revision 1f19fba8

Added by Leszek Koltunski almost 6 years ago

Port the Mali flash fix to the OIT branch.

View differences:

src/main/java/org/distorted/library/main/Distorted.java
28 28
import org.distorted.library.effect.FragmentEffect;
29 29
import org.distorted.library.effect.PostprocessEffect;
30 30
import org.distorted.library.effect.VertexEffect;
31
import org.distorted.library.program.*;
32 31

  
33 32
///////////////////////////////////////////////////////////////////////////////////////////////////
34 33
/**
......
87 86
   *
88 87
   * https://community.arm.com/graphics/f/discussions/10285/opengl-es-3-1-on-mali-t880-flashes
89 88
   */
90
  public static final int FBO_QUEUE_SIZE = 3;
89
  public static final int FBO_QUEUE_SIZE = 4;
91 90

  
92 91
  private static boolean mInitialized=false;
93 92

  
......
117 116
 * Needs to be called from a thread holding the OpenGL context.
118 117
 *   
119 118
 * @param context Context of the App using the library - used to open up Resources and read Shader code.
120
 * @throws FragmentCompilationException Fragment Shader failed to compile
121
 * @throws VertexCompilationException   Vertex Shader failed to compile
122
 * @throws VertexUniformsException      Too many uniforms in the Vertex Shader
123
 * @throws FragmentUniformsException    Too many uniforms in the Fragment Shader
124
 * @throws LinkingException             Shader failed to link
125 119
 */
126 120
  public static void onCreate(final Context context)
127
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
128 121
    {
129 122
    final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
130 123
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
src/main/java/org/distorted/library/main/DistortedOutputSurface.java
299 299
///////////////////////////////////////////////////////////////////////////////////////////////////
300 300
// two phases: 1. collapse the SSBO 2. blend the ssbo's color
301 301

  
302
  private int oitRender(long currTime)
302
  private int oitRender(long currTime, int fbo)
303 303
    {
304 304
    float corrW = getWidthCorrection();
305 305
    float corrH = getHeightCorrection();
......
307 307
    // Do the Collapse Pass only if we do have a Depth attachment.
308 308
    // Otherwise there's no point (in fact we then would create a feedback loop!)
309 309

  
310
    if( mDepthStencilH[0] != 0 )
310
    if( mDepthStencilH[fbo] != 0 )
311 311
      {
312 312
      GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
313 313
      GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
314
      GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mDepthStencilH[0]);
314
      GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mDepthStencilH[fbo]);
315 315
      DistortedRenderState.switchOffColorDepthStencil();
316 316
      DistortedEffects.oitCollapse(this, corrW, corrH);
317 317
      GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
318 318
      }
319 319

  
320
    setAsOutput(currTime);
320
    setAsOutputFBO(currTime,fbo);
321 321
    DistortedRenderState.switchColorDepthOnStencilOff();
322 322
    DistortedEffects.oitRender(this, corrW, corrH);
323 323
    DistortedRenderState.restoreColorDepthStencil();
......
341 341
    GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT|GLES31.GL_DEPTH_BUFFER_BIT|GLES31.GL_STENCIL_BUFFER_BIT);
342 342
    GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[2*fbo  ], 0);
343 343
    GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
344

  
345
    for(int i=buffer.mNumColors-2; i>=0; i--)
346
      {
347
      GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[i], 0);
348
      GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
349
      }
350 344
    }
351 345

  
352 346
///////////////////////////////////////////////////////////////////////////////////////////////////
......
430 424
          numRenders += currQueue.postprocess(mBuffer,fbo);
431 425
          numRenders += oitBuild(time,mBuffer[quality],fbo);
432 426
          GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT|GLES31.GL_ATOMIC_COUNTER_BARRIER_BIT);
433
          numRenders += oitRender(time);  // merge the OIT linked list
427
          numRenders += oitRender(time,fbo);  // merge the OIT linked list
434 428
          clearBuffer(mBuffer[quality],fbo);
435 429
          }
436 430
        } // end else (postprocessed child)
......
473 467

  
474 468
///////////////////////////////////////////////////////////////////////////////////////////////////
475 469

  
476
  private void setAsOutputFBO(long time, int fbo)
470
  public void setAsOutputFBO(long time, int fbo)
477 471
    {
478 472
    if( fbo>=0 && fbo<mNumFBOs )
479 473
      {
......
609 603
 * <p>
610 604
 * This version does not attempt to clear anything.
611 605
 */
612

  
613 606
  public void setAsOutput()
614 607
    {
615 608
    GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);

Also available in: Unified diff