Project

General

Profile

« Previous | Next » 

Revision 7cf57d72

Added by Leszek Koltunski over 7 years ago

This version appears to be fully working on Nexus 5X (it transfers back all the vertices and, if there are no vertex effects, the vertices transferred back are identical to the ones passed).

This however crashes with GL_INVALID_OPERATION during glDrawArrays() when run on Nexus 4.

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
310 310
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
311 311
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
312 312

  
313
    //GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]);
313
    GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]);
314 314

  
315
//    GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
315
    GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
316 316
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
317
  //  GLES30.glEndTransformFeedback();
318
  //  GLES30.glFlush();
317

  
318
    int error = GLES30.glGetError();
319

  
320
    if (error != GLES30.GL_NO_ERROR)
321
      {
322
      throw new RuntimeException("glError 0x" + Integer.toHexString(error));
323
      }
324

  
325
    GLES30.glEndTransformFeedback();
326
    GLES30.glFlush();
319 327

  
320 328
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
321
/*
322
int len = mesh.dataLength*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
329

  
330
int len = 3*(mesh.dataLength-2)*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
323 331

  
324 332
Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, len, GLES30.GL_MAP_READ_BIT);
325 333
FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer();
326 334
FloatBuffer bb = mesh.mMeshPositions;
327 335

  
328
String msgB = "BEFORE: ", msgA = "AFTER : ";
336
String msgB = "";
329 337
for(int d=0; d<mesh.dataLength; d++)
330 338
  {
331 339
  msgB+="("+(2*halfW*bb.get(3*d+0))+","+(2*halfH*bb.get(3*d+1))+","+(2*halfZ*bb.get(3*d+2))+")";
332
  msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")";
333 340
  }
334 341
android.util.Log.d( "Feedback", msgB);
342

  
343
String msgA = "";
344
for(int d=0; d<3*(mesh.dataLength-2); d++)
345
  {
346
  if( d==0 || d==1 || ((d-2)%3)==0)
347
     msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")";
348
  }
335 349
android.util.Log.d( "Feedback", msgA);
336 350

  
351
android.util.Log.e( "Feedback",msgA.equalsIgnoreCase(msgB) ? "identical":"not identical");
352

  
353

  
337 354
    /// DEBUG ONLY //////
338 355
    // displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime );
339 356
    /// END DEBUG ///////
340 357

  
341 358
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER);
342
*/
359

  
343 360
    }
344 361

  
345 362
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/MeshObject.java
86 86
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*    TEX_DATA_SIZE*BYTES_PER_FLOAT, mMeshTexture  , GLES30.GL_STATIC_READ);
87 87
       }
88 88

  
89
     if( mPosTBO[0]<0 )
89
     if( mPosTBO[0]<0 ) // Buffer for Transform Feedback. Since we are rendering with GL_TRIANGLE_STRIP, after passing N vertices
90
                        // we will get (N-2) triangles back, each 3 vertices of 12 bytes.
90 91
       {
91 92
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mPosTBO[0]);
92
       GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
93
       GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 3*(dataLength-2)*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
93 94
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
94 95
       }
95 96

  

Also available in: Unified diff