File size: 964 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.mojang.blaze3d.buffers;

import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class GpuFence implements AutoCloseable {
    private long handle = GlStateManager._glFenceSync(37143, 0);

    @Override
    public void close() {
        if (this.handle != 0L) {
            GlStateManager._glDeleteSync(this.handle);
            this.handle = 0L;
        }
    }

    public boolean awaitCompletion(long p_368162_) {
        if (this.handle == 0L) {
            return true;
        } else {
            int i = GlStateManager._glClientWaitSync(this.handle, 0, p_368162_);
            if (i == 37147) {
                return false;
            } else if (i == 37149) {
                throw new IllegalStateException("Failed to complete gpu fence");
            } else {
                return true;
            }
        }
    }
}