TimerQuery.java
com.mojang.blaze3d.systems.TimerQuery
信息
- 全限定名:com.mojang.blaze3d.systems.TimerQuery
- 类型:public class
- 包:com.mojang.blaze3d.systems
- 源码路径:src/main/java/com/mojang/blaze3d/systems/TimerQuery.java
- 起始行号:L9
- 职责:
TODO
字段/常量
-
activeEncoder- 类型:
CommandEncoder - 修饰符:
private - 源码定位:
L10 - 说明:
TODO
- 类型:
-
activeGpuQuery- 类型:
GpuQuery - 修饰符:
private - 源码定位:
L11 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
com.mojang.blaze3d.systems.TimerQuery.FrameProfile- 类型:
class - 修饰符:
public static - 源码定位:
L45 - 说明:
TODO
- 类型:
-
com.mojang.blaze3d.systems.TimerQuery.TimerQueryLazyLoader- 类型:
class - 修饰符:
private static - 源码定位:
L94 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static TimerQuery getInstance() @ L13
- 方法名:getInstance
- 源码定位:L13
- 返回类型:TimerQuery
- 修饰符:public static
参数:
- 无
说明:
TODO
public boolean isRecording() @ L17
- 方法名:isRecording
- 源码定位:L17
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public void beginProfile() @ L21
- 方法名:beginProfile
- 源码定位:L21
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public TimerQuery.FrameProfile endProfile() @ L31
- 方法名:endProfile
- 源码定位:L31
- 返回类型:TimerQuery.FrameProfile
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class TimerQuery {
private @Nullable CommandEncoder activeEncoder;
private @Nullable GpuQuery activeGpuQuery;
public static TimerQuery getInstance() {
return TimerQuery.TimerQueryLazyLoader.INSTANCE;
}
public boolean isRecording() {
return this.activeGpuQuery != null;
}
public void beginProfile() {
RenderSystem.assertOnRenderThread();
if (this.activeGpuQuery != null) {
throw new IllegalStateException("Current profile not ended");
} else {
this.activeEncoder = RenderSystem.getDevice().createCommandEncoder();
this.activeGpuQuery = this.activeEncoder.timerQueryBegin();
}
}
public TimerQuery.FrameProfile endProfile() {
RenderSystem.assertOnRenderThread();
if (this.activeGpuQuery != null && this.activeEncoder != null) {
this.activeEncoder.timerQueryEnd(this.activeGpuQuery);
TimerQuery.FrameProfile frameProfile = new TimerQuery.FrameProfile(this.activeGpuQuery);
this.activeGpuQuery = null;
this.activeEncoder = null;
return frameProfile;
} else {
throw new IllegalStateException("endProfile called before beginProfile");
}
}
@OnlyIn(Dist.CLIENT)
public static class FrameProfile {
private static final long NO_RESULT = 0L;
private static final long CANCELLED_RESULT = -1L;
private final GpuQuery gpuQuery;
private long timerResult = 0L;
private FrameProfile(GpuQuery gpuQuery) {
this.gpuQuery = gpuQuery;
}
public void cancel() {
RenderSystem.assertOnRenderThread();
if (this.timerResult == 0L) {
this.timerResult = -1L;
this.gpuQuery.close();
}
}
public boolean isDone() {
RenderSystem.assertOnRenderThread();
if (this.timerResult != 0L) {
return true;
} else {
OptionalLong value = this.gpuQuery.getValue();
if (value.isPresent()) {
this.timerResult = value.getAsLong();
this.gpuQuery.close();
return true;
} else {
return false;
}
}
}
public long get() {
RenderSystem.assertOnRenderThread();
if (this.timerResult == 0L) {
OptionalLong value = this.gpuQuery.getValue();
if (value.isPresent()) {
this.timerResult = value.getAsLong();
this.gpuQuery.close();
}
}
return this.timerResult;
}
}
@OnlyIn(Dist.CLIENT)
private static class TimerQueryLazyLoader {
private static final TimerQuery INSTANCE = instantiate();
private static TimerQuery instantiate() {
return new TimerQuery();
}
}
}引用的其他类
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderSystem.assertOnRenderThread(), RenderSystem.getDevice()
- 引用位置: