Project

General

Profile

« Previous | Next » 

Revision 2b7d2abb

Added by Leszek Koltunski over 3 years ago

Remove UBO from the fragment shader and come back to the default of only 5 concurrent fragment effects. All because UBOs in fragment shader crash on Adreno 510 and Adreno 506.

View differences:

src/main/java/org/distorted/library/uniformblock/UniformBlockIntUniforms.java
32 32
 */
33 33
public class UniformBlockIntUniforms
34 34
  {
35
  private final InternalBuffer mUBO;
35
  private InternalBuffer mUBO;
36 36
  private final int[] mArray;
37 37
  private final int mNumUniforms, mSize;
38
  private final boolean mReallyUseUBO;
38 39

  
39 40
///////////////////////////////////////////////////////////////////////////////////////////////////
40 41

  
41
  public UniformBlockIntUniforms(int numUniforms, int size)
42
  public UniformBlockIntUniforms(int numUniforms, int size, boolean reallyUse)
42 43
    {
43 44
    mNumUniforms = numUniforms;
44 45
    mSize        = size;
45 46
    mArray= new int[mNumUniforms*mSize];
46
    mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ);
47
    mReallyUseUBO= reallyUse;
48

  
49
    if( mReallyUseUBO )
50
      {
51
      mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ);
52
      }
47 53
    }
48 54

  
49 55
///////////////////////////////////////////////////////////////////////////////////////////////////
......
53 59
    mNumUniforms = original.mNumUniforms;
54 60
    mSize        = original.mSize;
55 61
    mArray= new int[mNumUniforms*mSize];
62
    mReallyUseUBO= original.mReallyUseUBO;
63

  
56 64
    System.arraycopy(original.mArray, 0, mArray, 0, mSize);
57
    mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ);
65

  
66
    if( mReallyUseUBO )
67
      {
68
      mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ);
69
      }
58 70
    }
59 71

  
60 72
///////////////////////////////////////////////////////////////////////////////////////////////////
......
69 81
  public void remove(int pos, int numEffects)
70 82
    {
71 83
    System.arraycopy(mArray, mNumUniforms*(pos+1), mArray, mNumUniforms*pos, mNumUniforms*(numEffects-pos) );
72
    mUBO.invalidate();
84

  
85
    if( mReallyUseUBO )
86
      {
87
      mUBO.invalidate();
88
      }
73 89
    }
74 90

  
75 91
///////////////////////////////////////////////////////////////////////////////////////////////////
......
77 93
  public void makeHole(int pos, int numEffects)
78 94
    {
79 95
    System.arraycopy(mArray, mNumUniforms*pos, mArray, mNumUniforms*(pos+1), mNumUniforms*(numEffects-pos) );
80
    mUBO.invalidate();
96

  
97
    if( mReallyUseUBO )
98
      {
99
      mUBO.invalidate();
100
      }
81 101
    }
82 102

  
83 103
///////////////////////////////////////////////////////////////////////////////////////////////////
......
85 105
  public void addOrdinal(int pos, int ordinal)
86 106
    {
87 107
    mArray[mNumUniforms*pos] = ordinal;
88
    mUBO.invalidate();
108

  
109
    if( mReallyUseUBO )
110
      {
111
      mUBO.invalidate();
112
      }
89 113
    }
90 114

  
91 115
///////////////////////////////////////////////////////////////////////////////////////////////////
......
93 117
  public void addAssociations(int pos, Effect effect)
94 118
    {
95 119
    effect.writeAssociations(mArray, mNumUniforms*pos+1, mNumUniforms*pos+3);
96
    mUBO.invalidate();
120

  
121
    if( mReallyUseUBO )
122
      {
123
      mUBO.invalidate();
124
      }
97 125
    }
98 126

  
99 127
///////////////////////////////////////////////////////////////////////////////////////////////////
100 128

  
101 129
  public void markForDeletion()
102 130
    {
103
    mUBO.markForDeletion();
131
    if( mReallyUseUBO )
132
      {
133
      mUBO.markForDeletion();
134
      }
135
    }
136

  
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

  
139
  public int[] getBackingArray()
140
    {
141
    return mArray;
104 142
    }
105 143

  
106 144
///////////////////////////////////////////////////////////////////////////////////////////////////
......
109 147
    {
110 148
    StringBuilder builder = new StringBuilder();
111 149

  
112
    builder.append(mUBO.getID());
150
    builder.append( mReallyUseUBO ? mUBO.getID() : "NOT USED");
113 151
    builder.append(':');
114 152

  
115 153
    for(int i=0; i<6; i++)

Also available in: Unified diff