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/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