GpuDevice.java
com.mojang.blaze3d.systems.GpuDevice
信息
- 全限定名:com.mojang.blaze3d.systems.GpuDevice
- 类型:public class
- 包:com.mojang.blaze3d.systems
- 源码路径:src/main/java/com/mojang/blaze3d/systems/GpuDevice.java
- 起始行号:L23
- 职责:
TODO
字段/常量
backend- 类型:
GpuDeviceBackend - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public GpuDevice(GpuDeviceBackend backend) @ L26
- 构造器名:GpuDevice
- 源码定位:L26
- 修饰符:public
参数:
- backend: GpuDeviceBackend
说明:
TODO
方法
下面的方法块按源码顺序生成。
public CommandEncoder createCommandEncoder() @ L30
- 方法名:createCommandEncoder
- 源码定位:L30
- 返回类型:CommandEncoder
- 修饰符:public
参数:
- 无
说明:
TODO
public GpuSampler createSampler(AddressMode addressModeU, AddressMode addressModeV, FilterMode minFilter, FilterMode magFilter, int maxAnisotropy, OptionalDouble maxLod) @ L34
- 方法名:createSampler
- 源码定位:L34
- 返回类型:GpuSampler
- 修饰符:public
参数:
- addressModeU: AddressMode
- addressModeV: AddressMode
- minFilter: FilterMode
- magFilter: FilterMode
- maxAnisotropy: int
- maxLod: OptionalDouble
说明:
TODO
public GpuTexture createTexture(Supplier<String> label, int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels) @ L46
- 方法名:createTexture
- 源码定位:L46
- 返回类型:GpuTexture
- 修饰符:public
参数:
- label: Supplier
- usage: int
- format: TextureFormat
- width: int
- height: int
- depthOrLayers: int
- mipLevels: int
说明:
TODO
public GpuTexture createTexture(String label, int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels) @ L53
- 方法名:createTexture
- 源码定位:L53
- 返回类型:GpuTexture
- 修饰符:public
参数:
- label: String
- usage: int
- format: TextureFormat
- width: int
- height: int
- depthOrLayers: int
- mipLevels: int
说明:
TODO
private void verifyTextureCreationArgs(int usage, int width, int height, int depthOrLayers, int mipLevels) @ L60
- 方法名:verifyTextureCreationArgs
- 源码定位:L60
- 返回类型:void
- 修饰符:private
参数:
- usage: int
- width: int
- height: int
- depthOrLayers: int
- mipLevels: int
说明:
TODO
public GpuTextureView createTextureView(GpuTexture texture) @ L101
- 方法名:createTextureView
- 源码定位:L101
- 返回类型:GpuTextureView
- 修饰符:public
参数:
- texture: GpuTexture
说明:
TODO
public GpuTextureView createTextureView(GpuTexture texture, int baseMipLevel, int mipLevels) @ L106
- 方法名:createTextureView
- 源码定位:L106
- 返回类型:GpuTextureView
- 修饰符:public
参数:
- texture: GpuTexture
- baseMipLevel: int
- mipLevels: int
说明:
TODO
private void verifyTextureViewCreationArgs(GpuTexture texture, int baseMipLevel, int mipLevels) @ L111
- 方法名:verifyTextureViewCreationArgs
- 源码定位:L111
- 返回类型:void
- 修饰符:private
参数:
- texture: GpuTexture
- baseMipLevel: int
- mipLevels: int
说明:
TODO
public GpuBuffer createBuffer(Supplier<String> label, int usage, long size) @ L126
- 方法名:createBuffer
- 源码定位:L126
- 返回类型:GpuBuffer
- 修饰符:public
参数:
- label: Supplier
- usage: int
- size: long
说明:
TODO
public GpuBuffer createBuffer(Supplier<String> label, int usage, ByteBuffer data) @ L134
- 方法名:createBuffer
- 源码定位:L134
- 返回类型:GpuBuffer
- 修饰符:public
参数:
- label: Supplier
- usage: int
- data: ByteBuffer
说明:
TODO
public String getImplementationInformation() @ L142
- 方法名:getImplementationInformation
- 源码定位:L142
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public List<String> getLastDebugMessages() @ L146
- 方法名:getLastDebugMessages
- 源码定位:L146
- 返回类型:List
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isDebuggingEnabled() @ L150
- 方法名:isDebuggingEnabled
- 源码定位:L150
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public String getVendor() @ L154
- 方法名:getVendor
- 源码定位:L154
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public String getBackendName() @ L158
- 方法名:getBackendName
- 源码定位:L158
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public String getVersion() @ L162
- 方法名:getVersion
- 源码定位:L162
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public String getRenderer() @ L166
- 方法名:getRenderer
- 源码定位:L166
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public int getMaxTextureSize() @ L170
- 方法名:getMaxTextureSize
- 源码定位:L170
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int getUniformOffsetAlignment() @ L174
- 方法名:getUniformOffsetAlignment
- 源码定位:L174
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public CompiledRenderPipeline precompilePipeline(RenderPipeline pipeline) @ L178
- 方法名:precompilePipeline
- 源码定位:L178
- 返回类型:CompiledRenderPipeline
- 修饰符:public
参数:
- pipeline: RenderPipeline
说明:
TODO
public CompiledRenderPipeline precompilePipeline(RenderPipeline pipeline, ShaderSource shaderSource) @ L182
- 方法名:precompilePipeline
- 源码定位:L182
- 返回类型:CompiledRenderPipeline
- 修饰符:public
参数:
- pipeline: RenderPipeline
- shaderSource: ShaderSource
说明:
TODO
public void clearPipelineCache() @ L186
- 方法名:clearPipelineCache
- 源码定位:L186
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public List<String> getEnabledExtensions() @ L190
- 方法名:getEnabledExtensions
- 源码定位:L190
- 返回类型:List
- 修饰符:public
参数:
- 无
说明:
TODO
public int getMaxSupportedAnisotropy() @ L194
- 方法名:getMaxSupportedAnisotropy
- 源码定位:L194
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public void close() @ L198
- 方法名:close
- 源码定位:L198
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void setVsync(boolean enabled) @ L202
- 方法名:setVsync
- 源码定位:L202
- 返回类型:void
- 修饰符:public
参数:
- enabled: boolean
说明:
TODO
public void presentFrame() @ L206
- 方法名:presentFrame
- 源码定位:L206
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isZZeroToOne() @ L210
- 方法名:isZZeroToOne
- 源码定位:L210
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class GpuDevice {
private final GpuDeviceBackend backend;
public GpuDevice(GpuDeviceBackend backend) {
this.backend = backend;
}
public CommandEncoder createCommandEncoder() {
return new CommandEncoder(this.backend, this.backend.createCommandEncoder());
}
public GpuSampler createSampler(
AddressMode addressModeU, AddressMode addressModeV, FilterMode minFilter, FilterMode magFilter, int maxAnisotropy, OptionalDouble maxLod
) {
if (maxAnisotropy >= 1 && maxAnisotropy <= this.backend.getMaxSupportedAnisotropy()) {
return this.backend.createSampler(addressModeU, addressModeV, minFilter, magFilter, maxAnisotropy, maxLod);
} else {
throw new IllegalArgumentException(
"maxAnisotropy out of range; must be >= 1 and <= " + this.getMaxSupportedAnisotropy() + ", but was " + maxAnisotropy
);
}
}
public GpuTexture createTexture(
@Nullable Supplier<String> label, @GpuTexture.Usage int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels
) {
this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels);
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
}
public GpuTexture createTexture(
@Nullable String label, @GpuTexture.Usage int usage, TextureFormat format, int width, int height, int depthOrLayers, int mipLevels
) {
this.verifyTextureCreationArgs(usage, width, height, depthOrLayers, mipLevels);
return this.backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
}
private void verifyTextureCreationArgs(@GpuTexture.Usage int usage, int width, int height, int depthOrLayers, int mipLevels) {
if (mipLevels < 1) {
throw new IllegalArgumentException("mipLevels must be at least 1");
} else {
int maxDimension = Math.max(width, height);
int maxMipSupported = Mth.log2(maxDimension) + 1;
if (mipLevels > maxMipSupported) {
throw new IllegalArgumentException(
"mipLevels must be at most "
+ maxMipSupported
+ " for a texture of width "
+ width
+ " and height "
+ height
+ " (asked for "
+ mipLevels
+ " mipLevels)"
);
} else if (depthOrLayers < 1) {
throw new IllegalArgumentException("depthOrLayers must be at least 1");
} else {
boolean isCubemap = (usage & 16) != 0;
if (isCubemap) {
if (width != height) {
throw new IllegalArgumentException("Cubemap compatible textures must be square, but size is " + width + "x" + height);
}
if (depthOrLayers % 6 != 0) {
throw new IllegalArgumentException("Cubemap compatible textures must have a layer count with a multiple of 6, was " + depthOrLayers);
}
if (depthOrLayers > 6) {
throw new UnsupportedOperationException("Array textures are not yet supported");
}
} else if (depthOrLayers > 1) {
throw new UnsupportedOperationException("Array or 3D textures are not yet supported");
}
}
}
}
public GpuTextureView createTextureView(GpuTexture texture) {
this.verifyTextureViewCreationArgs(texture, 0, texture.getMipLevels());
return this.backend.createTextureView(texture, 0, texture.getMipLevels());
}
public GpuTextureView createTextureView(GpuTexture texture, int baseMipLevel, int mipLevels) {
this.verifyTextureViewCreationArgs(texture, baseMipLevel, mipLevels);
return this.backend.createTextureView(texture, baseMipLevel, mipLevels);
}
private void verifyTextureViewCreationArgs(GpuTexture texture, int baseMipLevel, int mipLevels) {
if (texture.isClosed()) {
throw new IllegalArgumentException("Can't create texture view with closed texture");
} else if (baseMipLevel < 0 || baseMipLevel + mipLevels > texture.getMipLevels()) {
throw new IllegalArgumentException(
mipLevels
+ " mip levels starting from "
+ baseMipLevel
+ " would be out of range for texture with only "
+ texture.getMipLevels()
+ " mip levels"
);
}
}
public GpuBuffer createBuffer(@Nullable Supplier<String> label, @GpuBuffer.Usage int usage, long size) {
if (size <= 0L) {
throw new IllegalArgumentException("Buffer size must be greater than zero");
} else {
return this.backend.createBuffer(label, usage, size);
}
}
public GpuBuffer createBuffer(@Nullable Supplier<String> label, @GpuBuffer.Usage int usage, ByteBuffer data) {
if (!data.hasRemaining()) {
throw new IllegalArgumentException("Buffer source must not be empty");
} else {
return this.backend.createBuffer(label, usage, data);
}
}
public String getImplementationInformation() {
return this.backend.getImplementationInformation();
}
public List<String> getLastDebugMessages() {
return this.backend.getLastDebugMessages();
}
public boolean isDebuggingEnabled() {
return this.backend.isDebuggingEnabled();
}
public String getVendor() {
return this.backend.getVendor();
}
public String getBackendName() {
return this.backend.getBackendName();
}
public String getVersion() {
return this.backend.getVersion();
}
public String getRenderer() {
return this.backend.getRenderer();
}
public int getMaxTextureSize() {
return this.backend.getMaxTextureSize();
}
public int getUniformOffsetAlignment() {
return this.backend.getUniformOffsetAlignment();
}
public CompiledRenderPipeline precompilePipeline(RenderPipeline pipeline) {
return this.precompilePipeline(pipeline, null);
}
public CompiledRenderPipeline precompilePipeline(RenderPipeline pipeline, @Nullable ShaderSource shaderSource) {
return this.backend.precompilePipeline(pipeline, shaderSource);
}
public void clearPipelineCache() {
this.backend.clearPipelineCache();
}
public List<String> getEnabledExtensions() {
return this.backend.getEnabledExtensions();
}
public int getMaxSupportedAnisotropy() {
return this.backend.getMaxSupportedAnisotropy();
}
public void close() {
this.backend.close();
}
public void setVsync(boolean enabled) {
this.backend.setVsync(enabled);
}
public void presentFrame() {
this.backend.presentFrame();
}
public boolean isZZeroToOne() {
return this.backend.isZZeroToOne();
}
}引用的其他类
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用/返回值 - 关联成员:
CommandEncoder()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.log2()
- 引用位置: