Skip to content

Commit ae8083f

Browse files
committed
Merge branch 'anuke' into be
2 parents b57b84b + 071fdff commit ae8083f

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

extensions/profiling/src/arc/profiling/GL20Interceptor.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package arc.profiling;
22

3-
import arc.graphics.GL20;
3+
import arc.*;
4+
import arc.graphics.*;
5+
import arc.util.*;
46

57
import java.nio.*;
68

@@ -10,16 +12,21 @@
1012
*/
1113
public class GL20Interceptor extends GLInterceptor implements GL20{
1214
protected final GL20 gl20;
15+
protected volatile @Nullable Thread mainThread;
1316

1417
protected GL20Interceptor(GLProfiler glProfiler, GL20 gl20){
1518
super(glProfiler);
1619
this.gl20 = gl20;
20+
Core.app.post(() -> mainThread = Thread.currentThread());
1721
}
1822

1923
private void check(){
24+
if(mainThread != null && Thread.currentThread() != mainThread){
25+
glProfiler.getListener().onError("GL call on wrong thread: " + Thread.currentThread());
26+
}
2027
int error = gl20.glGetError();
2128
while(error != GL20.GL_NO_ERROR){
22-
glProfiler.getListener().onError(error);
29+
glProfiler.getListener().onError(resolveErrorNumber(error));
2330
error = gl20.glGetError();
2431
}
2532
}

extensions/profiling/src/arc/profiling/GL30Interceptor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package arc.profiling;
22

3+
import arc.*;
34
import arc.graphics.GL20;
45
import arc.graphics.GL30;
6+
import arc.util.*;
57

68
import java.nio.Buffer;
79
import java.nio.FloatBuffer;
@@ -13,18 +15,22 @@
1315
* @author Jan Polák
1416
*/
1517
public class GL30Interceptor extends GLInterceptor implements GL30{
16-
1718
protected final GL30 gl30;
19+
protected volatile @Nullable Thread mainThread;
1820

1921
protected GL30Interceptor(GLProfiler glProfiler, GL30 gl30){
2022
super(glProfiler);
2123
this.gl30 = gl30;
24+
Core.app.post(() -> mainThread = Thread.currentThread());
2225
}
2326

2427
private void check(){
28+
if(mainThread != null && Thread.currentThread() != mainThread){
29+
glProfiler.getListener().onError("GL call on wrong thread: " + Thread.currentThread());
30+
}
2531
int error = gl30.glGetError();
2632
while(error != GL20.GL_NO_ERROR){
27-
glProfiler.getListener().onError(error);
33+
glProfiler.getListener().onError(resolveErrorNumber(error));
2834
error = gl30.glGetError();
2935
}
3036
}

extensions/profiling/src/arc/profiling/GLErrorListener.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import arc.util.*;
44

5-
import static arc.profiling.GLInterceptor.resolveErrorNumber;
6-
75
/**
86
* Listener for GL errors detected by {@link GLProfiler}.
97
* @author Jan Polák
@@ -16,9 +14,9 @@ public interface GLErrorListener{
1614
String place = getCallName();
1715

1816
if(place != null){
19-
Log.err(new RuntimeException(Strings.format("[GLProfiler] Error @ from @", resolveErrorNumber(error), place)));
17+
Log.err(new RuntimeException(Strings.format("[GLProfiler] Error @ from @", error, place)));
2018
}else{
21-
Log.err(new RuntimeException(Strings.format("[GLProfiler] Error @", resolveErrorNumber(error))));
19+
Log.err(new RuntimeException(Strings.format("[GLProfiler] Error @", error)));
2220
}
2321
};
2422

@@ -27,17 +25,17 @@ public interface GLErrorListener{
2725
String place = getCallName();
2826

2927
if(place != null){
30-
throw new RuntimeException(Strings.format("[GLProfiler] Error @ from @", resolveErrorNumber(error), place));
28+
throw new RuntimeException(Strings.format("[GLProfiler] Error @ from @", error, place));
3129
}else{
32-
throw new RuntimeException(Strings.format("[GLProfiler] Error @", resolveErrorNumber(error)));
30+
throw new RuntimeException(Strings.format("[GLProfiler] Error @", error));
3331
}
3432
};
3533

3634
/**
3735
* Put your error logging code here.
3836
* @see GLInterceptor#resolveErrorNumber(int)
3937
*/
40-
void onError(int error);
38+
void onError(String error);
4139

4240
static @Nullable String getCallName(){
4341
String place = null;

0 commit comments

Comments
 (0)