1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.library.effectqueue;
|
21
|
|
22
|
import android.opengl.GLES30;
|
23
|
|
24
|
import org.distorted.library.effect.Effect;
|
25
|
import org.distorted.library.main.InternalBuffer;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
|
29
|
class UniformBlockProperties
|
30
|
{
|
31
|
private static final int NUM_BYTES = 4*100;
|
32
|
|
33
|
private final InternalBuffer mUBO;
|
34
|
private final int[] mProperties;
|
35
|
private final int mNumIntUniforms;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
UniformBlockProperties(int numUniforms)
|
40
|
{
|
41
|
mProperties= new int[NUM_BYTES/4];
|
42
|
mNumIntUniforms = numUniforms;
|
43
|
mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ);
|
44
|
}
|
45
|
|
46
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47
|
|
48
|
UniformBlockProperties(UniformBlockProperties original)
|
49
|
{
|
50
|
int size = original.mProperties.length;
|
51
|
mProperties= new int[size];
|
52
|
System.arraycopy(original.mProperties, 0, mProperties, 0, size);
|
53
|
mNumIntUniforms = original.mNumIntUniforms;
|
54
|
|
55
|
mUBO = new InternalBuffer(GLES30.GL_UNIFORM_BUFFER, GLES30.GL_STATIC_READ);
|
56
|
}
|
57
|
|
58
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
|
60
|
int getIndex()
|
61
|
{
|
62
|
return mUBO.createImmediatelyInt( NUM_BYTES, mProperties);
|
63
|
}
|
64
|
|
65
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66
|
|
67
|
void remove(int pos, int numEffects)
|
68
|
{
|
69
|
System.arraycopy(mProperties, mNumIntUniforms*(pos+1), mProperties, mNumIntUniforms*pos, mNumIntUniforms*(numEffects-pos) );
|
70
|
mUBO.invalidate();
|
71
|
}
|
72
|
|
73
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74
|
|
75
|
void makeHole(int pos, int numEffects)
|
76
|
{
|
77
|
System.arraycopy(mProperties, mNumIntUniforms*pos, mProperties, mNumIntUniforms*(pos+1), mNumIntUniforms*(numEffects-pos) );
|
78
|
mUBO.invalidate();
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
void addOrdinal(int pos, int ordinal)
|
84
|
{
|
85
|
mProperties[mNumIntUniforms*pos] = ordinal;
|
86
|
mUBO.invalidate();
|
87
|
}
|
88
|
|
89
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90
|
|
91
|
void addAssociations(int pos, Effect effect)
|
92
|
{
|
93
|
effect.writeAssociations(mProperties, mNumIntUniforms*pos+1, mNumIntUniforms*pos+3);
|
94
|
mUBO.invalidate();
|
95
|
}
|
96
|
|
97
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98
|
|
99
|
void markForDeletion()
|
100
|
{
|
101
|
mUBO.markForDeletion();
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
|
106
|
void print(int num)
|
107
|
{
|
108
|
StringBuilder builder = new StringBuilder();
|
109
|
|
110
|
builder.append(mUBO.getID());
|
111
|
builder.append(':');
|
112
|
|
113
|
for(int i=0; i<6; i++)
|
114
|
{
|
115
|
builder.append(' ');
|
116
|
builder.append(mProperties[4*i ]);
|
117
|
builder.append(' ');
|
118
|
builder.append(mProperties[4*i+1]);
|
119
|
builder.append(' ');
|
120
|
builder.append(mProperties[4*i+2]);
|
121
|
builder.append(',');
|
122
|
}
|
123
|
|
124
|
builder.append(' ');
|
125
|
builder.append('(');
|
126
|
builder.append(num);
|
127
|
builder.append(')');
|
128
|
|
129
|
String res = builder.toString();
|
130
|
|
131
|
android.util.Log.e("ubp", res);
|
132
|
}
|
133
|
}
|