Project

General

Profile

« Previous | Next » 

Revision 6ce08079

Added by Leszek Koltunski over 7 years ago

This commit (and reading the OpenGL ES 3.0 spec) pretty conclusively proves that, sadly, Nexus 4's Transform Feedback implementation is incomplete (doesn't work with GL_TRIANGLES primitiveMode)

View differences:

src/main/java/org/distorted/examples/TableOfContents.java
85 85
   final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
86 86
      
87 87
   int i = 0;
88
   
88

  
89
   {
90
      final Map<String, Object> item = new HashMap<>();
91
      item.put(ITEM_IMAGE, R.drawable.icon_example_feedback);
92
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_feedback));
93
      item.put(ITEM_SUBTITLE, getText(R.string.example_feedback_subtitle));
94
      data.add(item);
95
      activityMapping.put(i++, FeedbackActivity.class);
96
   }
97

  
89 98
   {
90 99
      final Map<String, Object> item = new HashMap<>();
91 100
      item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa);
......
347 356
      activityMapping.put(i++, MultiblurActivity.class);
348 357
   }
349 358

  
350
   {
351
      final Map<String, Object> item = new HashMap<>();
352
      item.put(ITEM_IMAGE, R.drawable.icon_example_feedback);
353
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_feedback));
354
      item.put(ITEM_SUBTITLE, getText(R.string.example_feedback_subtitle));
355
      data.add(item);
356
      activityMapping.put(i++, FeedbackActivity.class);
357
   }
358

  
359 359
   final SimpleAdapter dataAdapter = new SimpleAdapter(this, data, R.layout.toc_item, new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE}, new int[] {R.id.Image, R.id.Title, R.id.SubTitle});
360 360
   setListAdapter(dataAdapter);  
361 361
      
src/main/java/org/distorted/examples/feedback/FeedbackRenderer.java
42 42
    private final int BYTESFLOAT = 4;
43 43
    private final int POSITION   = 3;
44 44

  
45
    private final boolean USEPOINTS=false;
45
    private final boolean USEPOINTS=true;
46 46

  
47 47
    private GLSurfaceView mView;
48 48
    private DistortedProgram mFeedbackProgram;
......
62 62
      {
63 63
      mFeedbackProgram.useProgram();
64 64

  
65
      int numVertices = (USEPOINTS ? mVertices : 3*(mVertices-2));
66

  
67 65
      GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mVBO[0]);
68
      GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[0], USEPOINTS ? 1:POSITION, GLES30.GL_FLOAT, false, 0, 0);
66
      GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[0], POSITION, GLES30.GL_FLOAT, false, 0, 0);
69 67
      GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mTBO[0]);
70 68

  
71 69
      GLES30.glEnable(GLES30.GL_RASTERIZER_DISCARD);
72 70
      GLES30.glBeginTransformFeedback( USEPOINTS ? GLES30.GL_POINTS : GLES30.GL_TRIANGLES);
73
      GLES30.glDrawArrays( USEPOINTS ? GLES30.GL_POINTS : GLES30.GL_TRIANGLE_STRIP, 0, USEPOINTS ? mVertices*POSITION : mVertices);
71
      GLES30.glDrawArrays( USEPOINTS ? GLES30.GL_POINTS : GLES30.GL_TRIANGLE_STRIP, 0, mVertices);
72

  
73
      int error = GLES30.glGetError();
74

  
75
      if( error != GLES30.GL_NO_ERROR )
76
        {
77
        throw new RuntimeException("DrawArrays: glError 0x" + Integer.toHexString(error));
78
        }
79

  
74 80
      GLES30.glEndTransformFeedback();
75 81
      GLES30.glDisable(GLES30.GL_RASTERIZER_DISCARD);
76 82
      GLES30.glFlush();
77 83

  
84
      int numVertices = 3*(mVertices);
85

  
78 86
      Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, numVertices*POSITION*BYTESFLOAT, GLES30.GL_MAP_READ_BIT);
79 87
      FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer();
80 88
      String msg = "";
......
115 123
      String header= "#version 300 es\n";
116 124
      String[] feedback = { "outValue" };
117 125

  
118
      if(USEPOINTS)
119
        {
120
        header += "#define USEPOINTS 1\n";
121
        }
122
      else
123
        {
124
        header += "#define USEPOINTS 0\n";
125
        }
126

  
127 126
      try
128 127
        {
129 128
        mFeedbackProgram = new DistortedProgram(vertStream,fragStream, header, header, glsl, feedback );
......
141 140
      mVBO = new int[1];
142 141
      GLES30.glGenBuffers(1, mVBO, 0);
143 142
      GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mVBO[0]);
144
      GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, mVertices*POSITION*BYTESFLOAT, data, GLES30.GL_STATIC_READ);
143
      GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, mVertices*POSITION*BYTESFLOAT, data, GLES30.GL_STATIC_DRAW);
145 144
      GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
146 145

  
147
      int numVertices = (USEPOINTS ? mVertices : 3*(mVertices-2));
148

  
149 146
      mTBO = new int[1];
150 147
      GLES30.glGenBuffers(1, mTBO, 0);
151 148
      GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mTBO[0]);
152
      GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, numVertices*POSITION*BYTESFLOAT, null, GLES30.GL_STATIC_READ);
149
      GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 3*(mVertices)*POSITION*BYTESFLOAT, null, GLES30.GL_STATIC_READ);
153 150
      GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
154 151
      }
155 152
}

Also available in: Unified diff