Revision 51a3cbab
Added by Leszek Koltunski over 7 years ago
| src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
|---|---|---|
| 183 | 183 |
|
| 184 | 184 |
if( mSurfaceID>=mBufferSize ) |
| 185 | 185 |
{
|
| 186 |
// increase the size of mSSBOBuffer, copy over old values, remap. |
|
| 187 |
// TODO (don't need this if there are never more than mBufferSize=10 Surfaces) |
|
| 186 |
// increase size of the Buffer, copy over old values, remap. |
|
| 187 |
int[] tmp = new int[BUFFERING*mBufferSize]; |
|
| 188 |
for(int i=0;i<BUFFERING*mBufferSize;i++) tmp[i] = mIntBuffer.get(i); |
|
| 189 |
|
|
| 190 |
mBufferSize*= 2; |
|
| 191 |
|
|
| 192 |
GLES31.glBindBufferBase(GLES31.GL_SHADER_STORAGE_BUFFER, 0, 0); |
|
| 193 |
GLES31.glUnmapBuffer(GLES31.GL_SHADER_STORAGE_BUFFER); |
|
| 194 |
GLES31.glBindBuffer(GLES31.GL_SHADER_STORAGE_BUFFER,0); |
|
| 195 |
|
|
| 196 |
GLES31.glBindBuffer(GLES31.GL_SHADER_STORAGE_BUFFER, mSSBO[0]); |
|
| 197 |
GLES31.glBufferData(GLES31.GL_SHADER_STORAGE_BUFFER, BUFFERING*mBufferSize*4 , null, GLES31.GL_DYNAMIC_READ); |
|
| 198 |
ByteBuffer buf = (ByteBuffer) GLES31.glMapBufferRange(GLES31.GL_SHADER_STORAGE_BUFFER, 0, BUFFERING*mBufferSize*4, GLES31.GL_MAP_READ_BIT ); |
|
| 199 |
mIntBuffer = buf.order(ByteOrder.nativeOrder()).asIntBuffer(); |
|
| 200 |
GLES31.glBindBufferBase(GLES31.GL_SHADER_STORAGE_BUFFER,0, mSSBO[0]); |
|
| 201 |
|
|
| 202 |
for(int i=0;i<tmp.length;i++) mIntBuffer.put(i,tmp[i]); |
|
| 188 | 203 |
} |
| 189 | 204 |
|
| 190 | 205 |
createSurface(); |
| src/main/res/raw/main_fragment_shader.glsl | ||
|---|---|---|
| 73 | 73 |
} |
| 74 | 74 |
#endif |
| 75 | 75 |
|
| 76 |
if( color.a < 1.0 ) ssbocount[u_currentIndex]++; |
|
| 76 |
if( color.a < 1.0 && color.a > 0.0 ) ssbocount[u_currentIndex]++;
|
|
| 77 | 77 |
|
| 78 | 78 |
FRAG_COLOR = vec4(color.rgb * (1.0 + 7.0*v_Normal.z) * 0.125, color.a); |
| 79 | 79 |
} |
Also available in: Unified diff
SSBO: handle the fact that we might run out of space in our SSBO if we keep creating new Surfaces.