GraphicsWorkarounds.java
com.mojang.blaze3d.GraphicsWorkarounds
信息
- 全限定名:com.mojang.blaze3d.GraphicsWorkarounds
- 类型:public class
- 包:com.mojang.blaze3d
- 源码路径:src/main/java/com/mojang/blaze3d/GraphicsWorkarounds.java
- 起始行号:L14
- 职责:
TODO
字段/常量
-
INTEL_GEN11_CORE- 类型:
List<String> - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
INTEL_GEN11_ATOM- 类型:
List<String> - 修饰符:
private static final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
INTEL_GEN11_CELERON- 类型:
List<String> - 修饰符:
private static final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
INTEL_GEN11_PENTIUM- 类型:
List<String> - 修饰符:
private static final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
instance- 类型:
GraphicsWorkarounds - 修饰符:
private static - 源码定位:
L39 - 说明:
TODO
- 类型:
-
gpuDevice- 类型:
WeakReference<GpuDevice> - 修饰符:
private final - 源码定位:
L40 - 说明:
TODO
- 类型:
-
alwaysCreateFreshImmediateBuffer- 类型:
boolean - 修饰符:
private final - 源码定位:
L41 - 说明:
TODO
- 类型:
-
isGlOnDx12- 类型:
boolean - 修饰符:
private final - 源码定位:
L42 - 说明:
TODO
- 类型:
-
isAmd- 类型:
boolean - 修饰符:
private final - 源码定位:
L43 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private GraphicsWorkarounds(GpuDevice gpuDevice) @ L45
- 构造器名:GraphicsWorkarounds
- 源码定位:L45
- 修饰符:private
参数:
- gpuDevice: GpuDevice
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static GraphicsWorkarounds get(GpuDevice gpuDevice) @ L52
- 方法名:get
- 源码定位:L52
- 返回类型:GraphicsWorkarounds
- 修饰符:public static
参数:
- gpuDevice: GpuDevice
说明:
TODO
public boolean alwaysCreateFreshImmediateBuffer() @ L61
- 方法名:alwaysCreateFreshImmediateBuffer
- 源码定位:L61
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isGlOnDx12() @ L65
- 方法名:isGlOnDx12
- 源码定位:L65
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isAmd() @ L69
- 方法名:isAmd
- 源码定位:L69
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
private static boolean isIntelGen11(GpuDevice gpuDevice) @ L73
- 方法名:isIntelGen11
- 源码定位:L73
- 返回类型:boolean
- 修饰符:private static
参数:
- gpuDevice: GpuDevice
说明:
TODO
private static boolean isGlOnDx12(GpuDevice gpuDevice) @ L90
- 方法名:isGlOnDx12
- 源码定位:L90
- 返回类型:boolean
- 修饰符:private static
参数:
- gpuDevice: GpuDevice
说明:
TODO
private static boolean isAmd(GpuDevice gpuDevice) @ L95
- 方法名:isAmd
- 源码定位:L95
- 返回类型:boolean
- 修饰符:private static
参数:
- gpuDevice: GpuDevice
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class GraphicsWorkarounds {
private static final List<String> INTEL_GEN11_CORE = List.of(
"i3-1000g1",
"i3-1000g4",
"i3-1000ng4",
"i3-1005g1",
"i3-l13g4",
"i5-1030g4",
"i5-1030g7",
"i5-1030ng7",
"i5-1034g1",
"i5-1035g1",
"i5-1035g4",
"i5-1035g7",
"i5-1038ng7",
"i5-l16g7",
"i7-1060g7",
"i7-1060ng7",
"i7-1065g7",
"i7-1068g7",
"i7-1068ng7"
);
private static final List<String> INTEL_GEN11_ATOM = List.of("x6211e", "x6212re", "x6214re", "x6413e", "x6414re", "x6416re", "x6425e", "x6425re", "x6427fe");
private static final List<String> INTEL_GEN11_CELERON = List.of("j6412", "j6413", "n4500", "n4505", "n5095", "n5095a", "n5100", "n5105", "n6210", "n6211");
private static final List<String> INTEL_GEN11_PENTIUM = List.of("6805", "j6426", "n6415", "n6000", "n6005");
private static @Nullable GraphicsWorkarounds instance;
private final WeakReference<GpuDevice> gpuDevice;
private final boolean alwaysCreateFreshImmediateBuffer;
private final boolean isGlOnDx12;
private final boolean isAmd;
private GraphicsWorkarounds(GpuDevice gpuDevice) {
this.gpuDevice = new WeakReference<>(gpuDevice);
this.alwaysCreateFreshImmediateBuffer = isIntelGen11(gpuDevice);
this.isGlOnDx12 = isGlOnDx12(gpuDevice);
this.isAmd = isAmd(gpuDevice);
}
public static GraphicsWorkarounds get(GpuDevice gpuDevice) {
GraphicsWorkarounds instance = GraphicsWorkarounds.instance;
if (instance == null || instance.gpuDevice.get() != gpuDevice) {
GraphicsWorkarounds.instance = instance = new GraphicsWorkarounds(gpuDevice);
}
return instance;
}
public boolean alwaysCreateFreshImmediateBuffer() {
return this.alwaysCreateFreshImmediateBuffer;
}
public boolean isGlOnDx12() {
return this.isGlOnDx12;
}
public boolean isAmd() {
return this.isAmd;
}
private static boolean isIntelGen11(GpuDevice gpuDevice) {
String cpuInfo = GLX._getCpuInfo().toLowerCase(Locale.ROOT);
String renderer = gpuDevice.getRenderer().toLowerCase(Locale.ROOT);
if (!cpuInfo.contains("intel") || !renderer.contains("intel") || renderer.contains("mesa")) {
return false;
} else if (renderer.endsWith("gen11")) {
return true;
} else {
return !renderer.contains("uhd graphics") && !renderer.contains("iris")
? false
: cpuInfo.contains("atom") && INTEL_GEN11_ATOM.stream().anyMatch(cpuInfo::contains)
|| cpuInfo.contains("celeron") && INTEL_GEN11_CELERON.stream().anyMatch(cpuInfo::contains)
|| cpuInfo.contains("pentium") && INTEL_GEN11_PENTIUM.stream().anyMatch(cpuInfo::contains)
|| INTEL_GEN11_CORE.stream().anyMatch(cpuInfo::contains);
}
}
private static boolean isGlOnDx12(GpuDevice gpuDevice) {
boolean isWindowsArm64 = Util.getPlatform() == Util.OS.WINDOWS && Util.isAarch64();
return isWindowsArm64 || gpuDevice.getRenderer().startsWith("D3D12");
}
private static boolean isAmd(GpuDevice gpuDevice) {
return gpuDevice.getRenderer().contains("AMD");
}
}